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 BF83A41733B
\r
6 for <notmuch@notmuchmail.org>; Sat, 27 Mar 2010 13:44:35 -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 MWsC4mn4ddEg for <notmuch@notmuchmail.org>;
\r
16 Sat, 27 Mar 2010 13:44:33 -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 7A19E4196F3
\r
19 for <notmuch@notmuchmail.org>; Sat, 27 Mar 2010 13:44:33 -0700 (PDT)
\r
20 Received: from localhost (unknown [192.168.200.4])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id DBF9919F3395;
\r
22 Sat, 27 Mar 2010 21:44:32 +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 CLQBMFeYqxQR; Sat, 27 Mar 2010 21:44:31 +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 5271A19F341A;
\r
30 Sat, 27 Mar 2010 21:44:31 +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 04BD9FA005;
\r
34 Sat, 27 Mar 2010 21:44:31 +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 1Nvcrt-0001nv-VG; Sat, 27 Mar 2010 21:44:30 +0100
\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
39 To: notmuch@notmuchmail.org
\r
40 Date: Sat, 27 Mar 2010 21:44:19 +0100
\r
41 Message-Id: <1269722661-6894-4-git-send-email-sojkam1@fel.cvut.cz>
\r
42 X-Mailer: git-send-email 1.7.0.2
\r
43 In-Reply-To: <8739zlijhp.fsf@steelpick.2x.cz>
\r
44 References: <8739zlijhp.fsf@steelpick.2x.cz>
\r
45 Subject: [notmuch] [PATCH v3 4/6] 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: Sat, 27 Mar 2010 20:44:36 -0000
\r
60 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
\r
62 test/t0006-maildir.sh | 208 +++++++++++++++++++++++++++++++++++++++++++++++++
\r
63 test/test-lib.sh | 7 +-
\r
64 2 files changed, 213 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..03a2a35
\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 "s|${MAIL_DIR}/||" -e '/^"tags"/d'
\r
88 +cat >> "$NOTMUCH_CONFIG" <<EOF
\r
93 +test_expect_success "No new mail" '
\r
94 +execute_expecting new "No new mail."
\r
96 +cat > expected <<EOF
\r
97 +Added 1 new message to the database.
\r
99 +test_expect_success "Add a message, no flags" '
\r
100 +generate_message [subject]="\"test message\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-001:2,\"" &&
\r
101 +notmuch new | filter_output > actual &&
\r
102 +test_cmp expected actual
\r
103 +#emacs --eval "(gdb \"gdb --annotate=3 --args $(which notmuch) new\")"
\r
105 +cat > expected <<EOF
\r
106 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread)
\r
108 +test_expect_success 'Search for the message' '
\r
109 +notmuch search tag:inbox and tag:unread | filter_output > actual &&
\r
110 +test_cmp expected actual
\r
112 +cat > expected <<EOF
\r
113 +No new mail. Detected 1 file rename.
\r
115 +test_expect_success 'Add seen flag' '
\r
116 +mv "${gen_msg_filename}" "${gen_msg_filename}S" &&
\r
117 +increment_mtime "$(dirname "${gen_msg_filename}")" &&
\r
118 +notmuch new | filter_output > actual &&
\r
119 +test_cmp expected actual
\r
121 +cat > expected <<EOF
\r
122 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)
\r
124 +test_expect_success 'Check that tags were updated' '
\r
125 +notmuch search tag:inbox and not tag:unread | filter_output > actual &&
\r
126 +test_cmp expected actual
\r
128 +cat > expected <<EOF
\r
129 +Added 1 new message to the database.
\r
131 +test_expect_success "Add a seen message" '
\r
132 +generate_message [subject]="\"test message 2\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-002:2,S\"" &&
\r
133 +notmuch new | filter_output > actual &&
\r
134 +test_cmp expected actual
\r
136 +cat > expected <<EOF
\r
137 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)
\r
138 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 2 (inbox)
\r
140 +test_expect_success 'Check that the seen message is not tagged unread' '
\r
141 +notmuch search tag:inbox and not tag:unread | filter_output > actual &&
\r
142 +test_cmp expected actual
\r
144 +test_expect_success 'Tag the seen messages as replied' '
\r
145 +notmuch tag +replied -inbox tag:inbox and not tag:unread
\r
148 +cat > expected <<EOF
\r
152 +test_expect_success 'Check that R flag was added' '
\r
153 +ls -1 "${MAIL_DIR}" > actual &&
\r
154 +test_cmp expected actual
\r
156 +cat <<EOF > show-expected
\r
157 +[[[{"id": "msg-001@notmuch-test-suite",
\r
159 +"filename": "msg-001:2,RS",
\r
160 +"headers": {"Subject": "test message",
\r
161 +"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
162 +"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
166 +01 Jan 2000 12:00:00 -0000"},
\r
167 +"body": [{"id": 1,
\r
168 +"content-type": "text/plain",
\r
169 +"content": "This is just a test message at msg-001:2,\n"}]},
\r
173 +test_expect_success 'Renamed message can be shown without running notmuch new' '
\r
174 +notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show > show-actual &&
\r
175 +test_cmp show-expected show-actual
\r
178 +test_expect_success 'Test that we can reply to the renamed message' '
\r
179 +notmuch reply id:msg-001@notmuch-test-suite
\r
182 +echo "No new mail." > expected
\r
183 +test_expect_success 'No rename should be detected by notmuch new' '
\r
184 +increment_mtime "$(dirname "${gen_msg_filename}")" &&
\r
185 +notmuch new > actual &&
\r
186 +test_cmp expected actual
\r
188 +test_expect_success "Add a message to new/ without info" '
\r
189 +generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=new &&
\r
190 +notmuch new | filter_output > actual &&
\r
191 +test_cmp - actual <<EOF
\r
192 +Added 1 new message to the database.
\r
195 +test_expect_success "Check that the message has inbox and unread tags" '
\r
196 +notmuch search tag:inbox and tag:unread | filter_output > actual &&
\r
197 +test_cmp - actual <<EOF
\r
198 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread)
\r
201 +test_expect_success "Check that the message was not renamed" '
\r
202 +ls "${MAIL_DIR}/new" > actual &&
\r
203 +test_cmp - actual <<EOF
\r
207 +test_expect_success 'Removing of unread tag should fail without cur/' '
\r
208 +test_must_fail notmuch tag -unread tag:inbox and tag:unread
\r
210 +test_expect_success "Check that the tags were not changed" '
\r
211 +notmuch search tag:inbox and tag:unread | filter_output > actual &&
\r
212 +test_cmp - actual <<EOF
\r
213 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread)
\r
217 +# notmuch new is not necessary here, but we run it in order to check
\r
218 +# for 'no rename' later (*).
\r
219 +test_expect_success 'Create cur/ and let notmuch know about it' '
\r
220 +mkdir "$MAIL_DIR/cur" &&
\r
223 +test_expect_success 'Removing of unread tag should pass with cur/' '
\r
224 +notmuch tag -unread tag:inbox and tag:unread
\r
226 +test_expect_success 'Check that the message was moved to cur/' '\
\r
227 +ls "$MAIL_DIR/cur" > actual &&
\r
228 +test_cmp - actual <<EOF
\r
232 +test_expect_success 'No rename should be detected by notmuch new' '
\r
233 +increment_mtime "$MAIL_DIR/cur" &&
\r
234 +notmuch new > actual &&
\r
235 +test_cmp - actual <<EOF
\r
239 +# (*) If notmuch new was not run we've got "Processed 1 file in almost
\r
240 +# no time" here. The reason is that removing unread tag in a previous
\r
241 +# test created directory document in the database but this document
\r
242 +# was not linked as subdirectory of $MAIL_DIR. Therefore notmuch new
\r
243 +# could not reach the cur/ directory and its files in it during
\r
244 +# recurive traversal.
\r
245 +test_expect_success 'Remove info from file name' '
\r
246 +mv "$MAIL_DIR/cur/msg-003:2,S" "$MAIL_DIR/cur/msg-003" &&
\r
247 +increment_mtime "$MAIL_DIR/cur" &&
\r
248 +notmuch new | filter_output > actual
\r
249 +test_cmp - actual <<EOF
\r
250 +No new mail. Detected 1 file rename.
\r
253 +test_expect_success "Check that removing info did not change tags" '
\r
254 +notmuch search tag:inbox | filter_output > actual &&
\r
255 +test_cmp - actual <<EOF
\r
256 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox)
\r
259 +test_expect_success "Add a message to fakenew/ without info" '
\r
260 +generate_message [subject]="\"test message 4\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=fakenew &&
\r
261 +notmuch new | filter_output > actual &&
\r
262 +test_cmp - actual <<EOF
\r
263 +Added 1 new message to the database.
\r
266 +test_expect_success "Check that the message has inbox and unread tags" '
\r
267 +notmuch search tag:inbox and tag:unread | filter_output > actual &&
\r
268 +test_cmp - actual <<EOF
\r
269 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 4 (inbox unread)
\r
272 +test_expect_success 'Removing of unread tag should leave the message in fakenew/' '
\r
273 +notmuch tag -unread tag:inbox and tag:unread &&
\r
274 +ls "$MAIL_DIR/fakenew" > actual &&
\r
275 +test_cmp - actual <<EOF
\r
281 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
282 index 5417fe7..917631b 100755
\r
283 --- a/test/test-lib.sh
\r
284 +++ b/test/test-lib.sh
\r
285 @@ -257,8 +257,11 @@ generate_message ()
\r
286 local additional_headers
\r
288 gen_msg_cnt=$((gen_msg_cnt + 1))
\r
289 - gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
\r
290 - gen_msg_id="${gen_msg_name}@notmuch-test-suite"
\r
291 + if [ -z "${template[filename]}" ]; then
\r
292 + template[filename]="msg-$(printf "%03d" $gen_msg_cnt)"
\r
294 + gen_msg_name=${template[filename]}
\r
295 + gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite"
\r
297 if [ -z "${template[dir]}" ]; then
\r
298 gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
\r