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 33D58409DE6
\r
6 for <notmuch@notmuchmail.org>; Tue, 11 May 2010 05:15:16 -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 uh08dxlZQ6-d for <notmuch@notmuchmail.org>;
\r
16 Tue, 11 May 2010 05:15:01 -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 4F782418C25
\r
19 for <notmuch@notmuchmail.org>; Tue, 11 May 2010 05:14:38 -0700 (PDT)
\r
20 Received: from localhost (unknown [192.168.200.4])
\r
21 by max.feld.cvut.cz (Postfix) with ESMTP id A2CC819F33F8;
\r
22 Tue, 11 May 2010 14:14:37 +0200 (CEST)
\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 auSlytIHSLgM; Tue, 11 May 2010 14:14:33 +0200 (CEST)
\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 F28B719F33FB;
\r
30 Tue, 11 May 2010 14:14:31 +0200 (CEST)
\r
31 Received: from steelpick.2x.cz (k335-30.felk.cvut.cz [147.32.86.30])
\r
32 (Authenticated sender: sojkam1)
\r
33 by imap.feld.cvut.cz (Postfix) with ESMTPSA id C22C3FA004;
\r
34 Tue, 11 May 2010 14:14:31 +0200 (CEST)
\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 1OBoM3-0005t2-K3; Tue, 11 May 2010 14:14:31 +0200
\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
39 To: notmuch@notmuchmail.org
\r
40 Subject: [PATCH 4/4] Tests for maildir synchronization
\r
41 Date: Tue, 11 May 2010 14:14:21 +0200
\r
42 Message-Id: <1273580061-22580-5-git-send-email-sojkam1@fel.cvut.cz>
\r
43 X-Mailer: git-send-email 1.7.1
\r
44 In-Reply-To: <1273580061-22580-1-git-send-email-sojkam1@fel.cvut.cz>
\r
45 References: <1273580061-22580-1-git-send-email-sojkam1@fel.cvut.cz>
\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: Tue, 11 May 2010 12:15:16 -0000
\r
60 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
\r
62 test/t0011-maildir-sync.sh | 216 ++++++++++++++++++++++++++++++++++++++++++++
\r
63 test/test-lib.sh | 11 ++-
\r
64 2 files changed, 223 insertions(+), 4 deletions(-)
\r
65 create mode 100755 test/t0011-maildir-sync.sh
\r
67 diff --git a/test/t0011-maildir-sync.sh b/test/t0011-maildir-sync.sh
\r
68 new file mode 100755
\r
69 index 0000000..6bdee2d
\r
71 +++ b/test/t0011-maildir-sync.sh
\r
75 +test_description="Test maildir synchronization"
\r
80 + sed -e 's/, /,\n/g'|sed -e "s|${MAIL_DIR}/||" -e '/^"tags"/d'
\r
84 +cat >> "$NOTMUCH_CONFIG" <<EOF
\r
89 +test_expect_success "No new mail" '
\r
90 +output=$(NOTMUCH_NEW) &&
\r
91 +pass_if_equal "$output" "No new mail."
\r
93 +cat > expected <<EOF
\r
94 +Added 1 new message to the database.
\r
96 +test_expect_success "Add a message, no flags" '
\r
97 +generate_message [subject]="\"test message\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-001:2,\"" &&
\r
98 +NOTMUCH_NEW > actual &&
\r
99 +test_cmp expected actual
\r
100 +#emacs --eval "(gdb \"gdb --annotate=3 --args $(which notmuch) new\")"
\r
102 +cat > expected <<EOF
\r
103 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread)
\r
105 +test_expect_success 'Search for the message' '
\r
106 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&
\r
107 +test_cmp expected actual
\r
109 +cat > expected <<EOF
\r
110 +No new mail. Detected 1 file rename.
\r
112 +test_expect_success 'Add seen flag' '
\r
113 +mv "${gen_msg_filename}" "${gen_msg_filename}S" &&
\r
114 +increment_mtime "$(dirname "${gen_msg_filename}")" &&
\r
115 +NOTMUCH_NEW > actual &&
\r
116 +test_cmp expected actual
\r
118 +cat > expected <<EOF
\r
119 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)
\r
121 +test_expect_success 'Check that tags were updated' '
\r
122 +notmuch search tag:inbox and not tag:unread | notmuch_search_sanitize > actual &&
\r
123 +test_cmp expected actual
\r
125 +cat > expected <<EOF
\r
126 +Added 1 new message to the database.
\r
128 +test_expect_success "Add a seen message" '
\r
129 +generate_message [subject]="\"test message 2\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-002:2,S\"" &&
\r
130 +NOTMUCH_NEW > actual &&
\r
131 +test_cmp expected actual
\r
133 +cat > expected <<EOF
\r
134 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)
\r
135 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 2 (inbox)
\r
137 +test_expect_success 'Check that the seen message is not tagged unread' '
\r
138 +notmuch search tag:inbox and not tag:unread | notmuch_search_sanitize > actual &&
\r
139 +test_cmp expected actual
\r
141 +test_expect_success 'Tag the seen messages as replied' '
\r
142 +notmuch tag +replied -inbox tag:inbox and not tag:unread
\r
145 +cat > expected <<EOF
\r
149 +test_expect_success 'Check that R flag was added' '
\r
150 +ls -1 "${MAIL_DIR}" > actual &&
\r
151 +test_cmp expected actual
\r
153 +cat <<EOF > show-expected
\r
154 +[[[{"id": "msg-001@notmuch-test-suite",
\r
156 +"filename": "msg-001:2,RS",
\r
157 +"timestamp": 946728000,
\r
158 +"date_relative": "2000-01-01",
\r
159 +"headers": {"Subject": "test message",
\r
160 +"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
161 +"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
165 +01 Jan 2000 12:00:00 -0000"},
\r
166 +"body": [{"id": 1,
\r
167 +"content-type": "text/plain",
\r
168 +"content": "This is just a test message (#1)\n"}]},
\r
172 +test_expect_success 'Renamed message can be shown without running notmuch new' '
\r
173 +notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show > show-actual &&
\r
174 +test_cmp show-expected show-actual
\r
177 +test_expect_success 'Test that we can reply to the renamed message' '
\r
178 +notmuch reply id:msg-001@notmuch-test-suite
\r
181 +echo "No new mail." > expected
\r
182 +test_expect_success 'No rename should be detected by notmuch new' '
\r
183 +increment_mtime "$(dirname "${gen_msg_filename}")" &&
\r
184 +notmuch new > actual &&
\r
185 +test_cmp expected actual
\r
187 +test_expect_success "Add a message to new/ without info" '
\r
188 +generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=new &&
\r
189 +NOTMUCH_NEW > actual &&
\r
190 +test_cmp - actual <<EOF
\r
191 +Added 1 new message to the database.
\r
194 +test_expect_success "Check that the message has inbox and unread tags" '
\r
195 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&
\r
196 +test_cmp - actual <<EOF
\r
197 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread)
\r
200 +test_expect_success "Tag the message with 'tmp' tag" '
\r
201 +notmuch tag +tmp tag:inbox and tag:unread'
\r
203 +test_expect_success "Check that the message was not moved from new/ to cur/" '
\r
204 +echo filename:$gen_msg_filename > expected &&
\r
205 +notmuch show id:$gen_msg_id|grep -o "filename:.*$" > actual &&
\r
206 +test_cmp expected actual &&
\r
207 +test -f "$gen_msg_filename"
\r
209 +test_expect_success "Check that the message was not renamed" '
\r
210 +ls "${MAIL_DIR}/new" > actual &&
\r
211 +test_cmp - actual <<EOF
\r
215 +test_expect_success 'Removing of unread tag should fail without cur/' '
\r
216 +test_must_fail notmuch tag -unread tag:inbox and tag:unread
\r
218 +test_expect_success "Check that the tags were not changed" '
\r
219 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&
\r
220 +test_cmp - actual <<EOF
\r
221 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox tmp unread)
\r
225 +# notmuch new is not necessary here, but we run it in order to check
\r
226 +# for 'no rename' later (*).
\r
227 +test_expect_success 'Create cur/ and let notmuch know about it' '
\r
228 +mkdir "$MAIL_DIR/cur" &&
\r
231 +test_expect_success 'Removing of unread tag should pass with cur/' '
\r
232 +notmuch tag -unread tag:inbox and tag:unread
\r
234 +test_expect_success 'Check that the message was moved to cur/' '\
\r
235 +ls "$MAIL_DIR/cur" > actual &&
\r
236 +test_cmp - actual <<EOF
\r
240 +test_expect_success 'No rename should be detected by notmuch new' '
\r
241 +increment_mtime "$MAIL_DIR/cur" &&
\r
242 +notmuch new > actual &&
\r
243 +test_cmp - actual <<EOF
\r
247 +# (*) If notmuch new was not run we've got "Processed 1 file in almost
\r
248 +# no time" here. The reason is that removing unread tag in a previous
\r
249 +# test created directory document in the database but this document
\r
250 +# was not linked as subdirectory of $MAIL_DIR. Therefore notmuch new
\r
251 +# could not reach the cur/ directory and its files in it during
\r
252 +# recurive traversal.
\r
253 +test_expect_success 'Remove info from file name' '
\r
254 +mv "$MAIL_DIR/cur/msg-003:2,S" "$MAIL_DIR/cur/msg-003" &&
\r
255 +increment_mtime "$MAIL_DIR/cur" &&
\r
256 +NOTMUCH_NEW > actual
\r
257 +test_cmp - actual <<EOF
\r
258 +No new mail. Detected 1 file rename.
\r
261 +test_expect_success "Check that removing info did not change tags" '
\r
262 +notmuch search tag:inbox | notmuch_search_sanitize > actual &&
\r
263 +test_cmp - actual <<EOF
\r
264 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox tmp)
\r
267 +test_expect_success "Add a message to fakenew/ without info" '
\r
268 +generate_message [subject]="\"test message 4\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=fakenew &&
\r
269 +NOTMUCH_NEW > actual &&
\r
270 +test_cmp - actual <<EOF
\r
271 +Added 1 new message to the database.
\r
274 +test_expect_success "Check that the message has inbox and unread tags" '
\r
275 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&
\r
276 +test_cmp - actual <<EOF
\r
277 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 4 (inbox unread)
\r
280 +test_expect_success 'Removing of unread tag should leave the message in fakenew/' '
\r
281 +notmuch tag -unread tag:inbox and tag:unread &&
\r
282 +ls "$MAIL_DIR/fakenew" > actual &&
\r
283 +test_cmp - actual <<EOF
\r
289 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
290 index 06559cd..3c288a5 100755
\r
291 --- a/test/test-lib.sh
\r
292 +++ b/test/test-lib.sh
\r
293 @@ -276,12 +276,15 @@ generate_message ()
\r
294 local -A template="($@)"
\r
295 local additional_headers
\r
297 + gen_msg_cnt=$((gen_msg_cnt + 1))
\r
298 + if [ -z "${template[filename]}" ]; then
\r
299 + template[filename]="msg-$(printf "%03d" $gen_msg_cnt)"
\r
301 + gen_msg_name=${template[filename]}
\r
303 if [ -z "${template[id]}" ]; then
\r
304 - gen_msg_cnt=$((gen_msg_cnt + 1))
\r
305 - gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
\r
306 - gen_msg_id="${gen_msg_name}@notmuch-test-suite"
\r
307 + gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite"
\r
309 - gen_msg_name="msg-${template[id]}"
\r
310 gen_msg_id="${template[id]}"
\r