1 Return-Path: <sojkam1@fel.cvut.cz>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 7870C41733A
\r
6 for <notmuch@notmuchmail.org>; Fri, 26 Mar 2010 14:43:18 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5
\r
12 tests=[BAYES_00=-1.9] autolearn=ham
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id hjZ5BTCcccHC for <notmuch@notmuchmail.org>;
\r
16 Fri, 26 Mar 2010 14:43:15 -0700 (PDT)
\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 087374196F4
\r
19 for <notmuch@notmuchmail.org>; Fri, 26 Mar 2010 14:43:13 -0700 (PDT)
\r
20 Received: from localhost (unknown [192.168.200.4])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id 0C20219F3404;
\r
22 Fri, 26 Mar 2010 22:43:12 +0100 (CET)
\r
23 X-Virus-Scanned: IMAP AMAVIS
\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])
\r
25 by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,
\r
27 with ESMTP id DqCIUdCulJxQ; Fri, 26 Mar 2010 22:43:10 +0100 (CET)
\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])
\r
29 by max.feld.cvut.cz (Postfix) with ESMTP id 56DDD19F35F8;
\r
30 Fri, 26 Mar 2010 22:43:10 +0100 (CET)
\r
31 Received: from steelpick.2x.cz (r5da224.net.upc.cz [86.49.116.224])
\r
32 (Authenticated sender: sojkam1)
\r
33 by imap.feld.cvut.cz (Postfix) with ESMTPSA id 469BAFA003;
\r
34 Fri, 26 Mar 2010 22:43:10 +0100 (CET)
\r
35 Received: from wsh by steelpick.2x.cz with local (Exim 4.71)
\r
36 (envelope-from <sojkam1@fel.cvut.cz>)
\r
37 id 1NvHJ7-0006iF-G5; Fri, 26 Mar 2010 22:43:09 +0100
\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
39 To: notmuch@notmuchmail.org
\r
40 Date: Fri, 26 Mar 2010 22:42:57 +0100
\r
41 Message-Id: <1269639777-25765-4-git-send-email-sojkam1@fel.cvut.cz>
\r
42 X-Mailer: git-send-email 1.7.0.2
\r
43 In-Reply-To: <87tys292w7.fsf@steelpick.2x.cz>
\r
44 References: <87tys292w7.fsf@steelpick.2x.cz>
\r
45 Subject: [notmuch] [PATCH v2 4/4] Tests for maildir-based mailstore
\r
46 X-BeenThere: notmuch@notmuchmail.org
\r
47 X-Mailman-Version: 2.1.13
\r
49 List-Id: "Use and development of the notmuch mail system."
\r
50 <notmuch.notmuchmail.org>
\r
51 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
52 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
53 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
54 List-Post: <mailto:notmuch@notmuchmail.org>
\r
55 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
56 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
57 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
58 X-List-Received-Date: Fri, 26 Mar 2010 21:43:18 -0000
\r
60 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
\r
62 test/t0006-maildir.sh | 205 +++++++++++++++++++++++++++++++++++++++++++++++++
\r
63 test/test-lib.sh | 7 +-
\r
64 2 files changed, 210 insertions(+), 2 deletions(-)
\r
65 create mode 100755 test/t0006-maildir.sh
\r
67 diff --git a/test/t0006-maildir.sh b/test/t0006-maildir.sh
\r
68 new file mode 100755
\r
69 index 0000000..ced1d05
\r
71 +++ b/test/t0006-maildir.sh
\r
75 +test_description="Test maildir mailstore"
\r
80 + grep -v -E -e "$NOTMUCH_IGNORED_OUTPUT_REGEXP" | sed -e "$NOTMUCH_THREAD_ID_SQUELCH"
\r
84 + sed -e 's/, /,\n/g'|sed -e '/^"filename"/ s/:2,[A-Z]*//' -e '/^"tags"/d'
\r
87 +cat >> "$NOTMUCH_CONFIG" <<EOF
\r
92 +test_expect_success "No new mail" '
\r
93 +execute_expecting new "No new mail."
\r
95 +cat > expected <<EOF
\r
96 +Added 1 new message to the database.
\r
98 +test_expect_success "Add a message, no flags" '
\r
99 +generate_message [subject]="\"test message\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-001:2,\"" &&
\r
100 +notmuch new | filter_output > actual &&
\r
101 +test_cmp expected actual
\r
102 +#emacs --eval "(gdb \"gdb --annotate=3 --args $(which notmuch) new\")"
\r
104 +cat > expected <<EOF
\r
105 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread)
\r
107 +test_expect_success 'Search for the message' '
\r
108 +notmuch search tag:inbox and tag:unread | filter_output > actual &&
\r
109 +test_cmp expected actual
\r
111 +cat > expected <<EOF
\r
112 +No new mail. Detected 1 file rename.
\r
114 +test_expect_success 'Add seen flag' '
\r
115 +mv "${gen_msg_filename}" "${gen_msg_filename}S" &&
\r
116 +increment_mtime "$(dirname "${gen_msg_filename}")" &&
\r
117 +notmuch new | filter_output > actual &&
\r
118 +test_cmp expected actual
\r
120 +cat > expected <<EOF
\r
121 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)
\r
123 +test_expect_success 'Check that tags were updated' '
\r
124 +notmuch search tag:inbox and not tag:unread | filter_output > actual &&
\r
125 +test_cmp expected actual
\r
127 +cat > expected <<EOF
\r
128 +Added 1 new message to the database.
\r
130 +test_expect_success "Add a seen message" '
\r
131 +generate_message [subject]="\"test message 2\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-002:2,S\"" &&
\r
132 +notmuch new | filter_output > actual &&
\r
133 +test_cmp expected actual
\r
135 +cat > expected <<EOF
\r
136 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)
\r
137 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 2 (inbox)
\r
139 +test_expect_success 'Check that the seen message is not tagged unread' '
\r
140 +notmuch search tag:inbox and not tag:unread | filter_output > actual &&
\r
141 +test_cmp expected actual
\r
143 +test_expect_success 'Tag the seen messages as replied' '
\r
144 +notmuch tag +replied -inbox tag:inbox and not tag:unread
\r
147 +cat > expected <<EOF
\r
151 +test_expect_success 'Check that R flag was added' '
\r
152 +ls -1 "${MAIL_DIR}" > actual &&
\r
153 +test_cmp expected actual
\r
155 +echo -n '[[[{"id": "msg-001@notmuch-test-suite",
\r
157 +"filename": "/home/wsh/src/notmuch/test/trash directory.t0006-maildir/mail/msg-001",
\r
158 +"headers": {"Subject": "test message",
\r
159 +"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
160 +"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
164 +01 Jan 2000 12:00:00 -0000"},
\r
165 +"body": [{"id": 1,
\r
166 +"content-type": "text/plain",
\r
167 +"content": "This is just a test message at /home/wsh/src/notmuch/test/trash directory.t0006-maildir/mail/msg-001:2,\n"}]},
\r
168 +[]]]]' > show-expected
\r
170 +test_expect_success 'Renamed message can be shown without running notmuch new' '
\r
171 +notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show > show-actual &&
\r
172 +test_cmp show-expected show-actual
\r
175 +test_expect_success 'Test that we can reply to the renamed message' '
\r
176 +notmuch reply id:msg-001@notmuch-test-suite
\r
179 +echo "No new mail." > expected
\r
180 +test_expect_success 'No rename should be detected by notmuch new' '
\r
181 +increment_mtime "$(dirname "${gen_msg_filename}")" &&
\r
182 +notmuch new > actual &&
\r
183 +test_cmp expected actual
\r
185 +test_expect_success "Add a message to new/ without info" '
\r
186 +generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=new &&
\r
187 +notmuch new | filter_output > actual &&
\r
188 +test_cmp - actual <<EOF
\r
189 +Added 1 new message to the database.
\r
192 +test_expect_success "Check that the message has inbox and unread tags" '
\r
193 +notmuch search tag:inbox and tag:unread | filter_output > actual &&
\r
194 +test_cmp - actual <<EOF
\r
195 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread)
\r
198 +test_expect_success "Check that the message was not renamed" '
\r
199 +ls "${MAIL_DIR}/new" > actual &&
\r
200 +test_cmp - actual <<EOF
\r
204 +test_expect_success 'Removing of unread tag should fail without cur/' '
\r
205 +test_must_fail notmuch tag -unread tag:inbox and tag:unread
\r
207 +test_expect_success "Check that the tags were not changed" '
\r
208 +notmuch search tag:inbox and tag:unread | filter_output > actual &&
\r
209 +test_cmp - actual <<EOF
\r
210 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread)
\r
214 +# notmuch new is not necessary here, but we run it in order to check
\r
215 +# for 'no rename' later (*).
\r
216 +test_expect_success 'Create cur/ and let notmuch know about it' '
\r
217 +mkdir "$MAIL_DIR/cur" &&
\r
220 +test_expect_success 'Removing of unread tag should pass with cur/' '
\r
221 +notmuch tag -unread tag:inbox and tag:unread
\r
223 +test_expect_success 'Check that the message was moved to cur/' '\
\r
224 +ls "$MAIL_DIR/cur" > actual &&
\r
225 +test_cmp - actual <<EOF
\r
229 +test_expect_success 'No rename should be detected by notmuch new' '
\r
230 +increment_mtime "$MAIL_DIR/cur" &&
\r
231 +notmuch new > actual &&
\r
232 +test_cmp - actual <<EOF
\r
236 +# (*) If notmuch new was not run we've got "Processed 1 file in almost
\r
237 +# no time" here. The reason is that removing unread tag in a previous
\r
238 +# test created directory document in the database but this document
\r
239 +# was not linked as subdirectory of $MAIL_DIR. Therefore notmuch new
\r
240 +# could not reach the cur/ directory and its files in it during
\r
241 +# recurive traversal.
\r
242 +test_expect_success 'Remove info from file name' '
\r
243 +mv "$MAIL_DIR/cur/msg-003:2,S" "$MAIL_DIR/cur/msg-003" &&
\r
244 +increment_mtime "$MAIL_DIR/cur" &&
\r
245 +notmuch new | filter_output > actual
\r
246 +test_cmp - actual <<EOF
\r
247 +No new mail. Detected 1 file rename.
\r
250 +test_expect_success "Check that removing info did not change tags" '
\r
251 +notmuch search tag:inbox | filter_output > actual &&
\r
252 +test_cmp - actual <<EOF
\r
253 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox)
\r
256 +test_expect_success "Add a message to fakenew/ without info" '
\r
257 +generate_message [subject]="\"test message 4\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=fakenew &&
\r
258 +notmuch new | filter_output > actual &&
\r
259 +test_cmp - actual <<EOF
\r
260 +Added 1 new message to the database.
\r
263 +test_expect_success "Check that the message has inbox and unread tags" '
\r
264 +notmuch search tag:inbox and tag:unread | filter_output > actual &&
\r
265 +test_cmp - actual <<EOF
\r
266 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 4 (inbox unread)
\r
269 +test_expect_success 'Removing of unread tag should leave the message in fakenew/' '
\r
270 +notmuch tag -unread tag:inbox and tag:unread &&
\r
271 +ls "$MAIL_DIR/fakenew" > actual &&
\r
272 +test_cmp - actual <<EOF
\r
278 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
279 index 5417fe7..917631b 100755
\r
280 --- a/test/test-lib.sh
\r
281 +++ b/test/test-lib.sh
\r
282 @@ -257,8 +257,11 @@ generate_message ()
\r
283 local additional_headers
\r
285 gen_msg_cnt=$((gen_msg_cnt + 1))
\r
286 - gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
\r
287 - gen_msg_id="${gen_msg_name}@notmuch-test-suite"
\r
288 + if [ -z "${template[filename]}" ]; then
\r
289 + template[filename]="msg-$(printf "%03d" $gen_msg_cnt)"
\r
291 + gen_msg_name=${template[filename]}
\r
292 + gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite"
\r
294 if [ -z "${template[dir]}" ]; then
\r
295 gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
\r