1 Return-Path: <wsh@resox.2x.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 CDCB540D16B
\r
6 for <notmuch@notmuchmail.org>; Sun, 31 Oct 2010 14:49:04 -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=unavailable
\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 055PvEuhsgn7 for <notmuch@notmuchmail.org>;
\r
16 Sun, 31 Oct 2010 14:48:49 -0700 (PDT)
\r
17 Received: from smtp.nextra.cz (smtp.nextra.cz [212.65.193.3])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 7554240D16C
\r
19 for <notmuch@notmuchmail.org>; Sun, 31 Oct 2010 14:48:02 -0700 (PDT)
\r
20 Received: from resox.2x.cz (unknown [213.29.198.144])
\r
21 by smtp.nextra.cz (Postfix) with ESMTP id A3D2188D35;
\r
22 Sun, 31 Oct 2010 22:30:36 +0100 (CET)
\r
23 Received: from wsh by resox.2x.cz with local (Exim 4.72)
\r
24 (envelope-from <wsh@resox.2x.cz>)
\r
25 id 1PCfTu-0004wr-Dp; Sun, 31 Oct 2010 22:30:26 +0100
\r
26 From: Michal Sojka <sojkam1@fel.cvut.cz>
\r
27 To: notmuch@notmuchmail.org
\r
28 Subject: [PATCH v4 4/4] Tests for maildir synchronization
\r
29 Date: Sun, 31 Oct 2010 22:29:18 +0100
\r
30 Message-Id: <1288560558-18915-5-git-send-email-sojkam1@fel.cvut.cz>
\r
31 X-Mailer: git-send-email 1.7.1
\r
32 In-Reply-To: <87tyk3vpxd.fsf@wsheee.2x.cz>
\r
33 References: <87tyk3vpxd.fsf@wsheee.2x.cz>
\r
34 X-BeenThere: notmuch@notmuchmail.org
\r
35 X-Mailman-Version: 2.1.13
\r
37 List-Id: "Use and development of the notmuch mail system."
\r
38 <notmuch.notmuchmail.org>
\r
39 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
40 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
41 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
42 List-Post: <mailto:notmuch@notmuchmail.org>
\r
43 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
44 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
46 X-List-Received-Date: Sun, 31 Oct 2010 21:49:05 -0000
\r
48 Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
\r
50 test/maildir-sync | 231 +++++++++++++++++++++++++++++++++++++++++++++++++++++
\r
51 test/notmuch-test | 2 +-
\r
52 test/test-lib.sh | 14 +++-
\r
53 3 files changed, 244 insertions(+), 3 deletions(-)
\r
54 create mode 100755 test/maildir-sync
\r
56 diff --git a/test/maildir-sync b/test/maildir-sync
\r
57 new file mode 100755
\r
58 index 0000000..23d612e
\r
60 +++ b/test/maildir-sync
\r
64 +test_description="Test maildir synchronization"
\r
69 + sed -e 's/, /,\n/g'|sed -e "s|${MAIL_DIR}/||" -e '/^"tags"/d'
\r
73 +cat >> "$NOTMUCH_CONFIG" <<EOF
\r
75 +synchronize_flags=true
\r
78 +test_begin_subtest "No new messages"
\r
79 +output=$(NOTMUCH_NEW)
\r
80 +test_expect_equal "$output" "No new mail."
\r
82 +cat > expected <<EOF
\r
83 +Added 1 new message to the database.
\r
85 +test_expect_success "Add a message, no flags" '
\r
86 +generate_message [subject]="\"test message\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-001:2,\"" &&
\r
87 +NOTMUCH_NEW > actual &&
\r
88 +test_cmp expected actual
\r
89 +#emacs --eval "(gdb \"gdb --annotate=3 --args $(which notmuch) new\")"
\r
91 +cat > expected <<EOF
\r
92 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox unread)
\r
94 +test_expect_success 'Search for the message' '
\r
95 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&
\r
96 +test_cmp expected actual
\r
98 +cat > expected <<EOF
\r
99 +No new mail. Detected 1 file rename.
\r
101 +test_expect_success 'Add seen flag' '
\r
102 +mv "${gen_msg_filename}" "${gen_msg_filename}S" &&
\r
103 +increment_mtime "$(dirname "${gen_msg_filename}")" &&
\r
104 +NOTMUCH_NEW > actual &&
\r
105 +test_cmp expected actual
\r
107 +cat > expected <<EOF
\r
108 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)
\r
110 +test_expect_success 'Check that tags were updated' '
\r
111 +notmuch search tag:inbox and not tag:unread | notmuch_search_sanitize > actual &&
\r
112 +test_cmp expected actual
\r
114 +cat > expected <<EOF
\r
115 +Added 1 new message to the database.
\r
117 +test_expect_success "Add a seen message" '
\r
118 +generate_message [subject]="\"test message 2\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [filename]="\"msg-002:2,S\"" &&
\r
119 +NOTMUCH_NEW > actual &&
\r
120 +test_cmp expected actual
\r
122 +cat > expected <<EOF
\r
123 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message (inbox)
\r
124 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 2 (inbox)
\r
126 +test_expect_success 'Check that the seen message is not tagged unread' '
\r
127 +notmuch search tag:inbox and not tag:unread | notmuch_search_sanitize > actual &&
\r
128 +test_cmp expected actual
\r
130 +test_expect_success 'Tag the seen messages as replied' '
\r
131 +notmuch tag +replied -inbox tag:inbox and not tag:unread
\r
134 +cat > expected <<EOF
\r
138 +test_expect_success 'Check that R flag was added' '
\r
139 +ls -1 "${MAIL_DIR}" > actual &&
\r
140 +test_cmp expected actual
\r
142 +cat <<EOF > show-expected
\r
143 +[[[{"id": "msg-001@notmuch-test-suite",
\r
145 +"filename": "msg-001:2,RS",
\r
146 +"timestamp": 946728000,
\r
147 +"date_relative": "2000-01-01",
\r
148 +"headers": {"Subject": "test message",
\r
149 +"From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
150 +"To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
154 +01 Jan 2000 12:00:00 -0000"},
\r
155 +"body": [{"id": 1,
\r
156 +"content-type": "text/plain",
\r
157 +"content": "This is just a test message (#1)\n"}]},
\r
161 +test_expect_success 'Message renamed due to changed flags can be shown without running notmuch new' '
\r
162 +notmuch show --format=json id:msg-001@notmuch-test-suite | filter_show > show-actual &&
\r
163 +test_cmp show-expected show-actual
\r
166 +test_expect_success 'Test that we can reply to the renamed message' '
\r
167 +notmuch reply id:msg-001@notmuch-test-suite
\r
170 +echo "No new mail." > expected
\r
171 +test_expect_success 'No rename should be detected by notmuch new' '
\r
172 +increment_mtime "$(dirname "${gen_msg_filename}")" &&
\r
173 +notmuch new > actual &&
\r
174 +test_cmp expected actual
\r
176 +test_expect_success "Add a message to new/ without info" '
\r
177 +generate_message [subject]="\"test message 3\"" [date]="\"Sat, 01 Jan 2000 12:00:00 -0000\"" [dir]=new &&
\r
178 +NOTMUCH_NEW > actual &&
\r
179 +test_cmp - actual <<EOF
\r
180 +Added 1 new message to the database.
\r
183 +test_expect_success "Check that the message has inbox and unread tags" '
\r
184 +notmuch search tag:inbox and tag:unread | notmuch_search_sanitize > actual &&
\r
185 +test_cmp - actual <<EOF
\r
186 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox unread)
\r
189 +test_expect_success "Tag the message with 'tmp' tag" '
\r
190 +notmuch tag +tmp tag:inbox and tag:unread'
\r
192 +test_expect_success "Check that the message was not moved from new/ to cur/" '
\r
193 +echo filename:$gen_msg_filename > expected &&
\r
194 +notmuch show id:$gen_msg_id|grep -o "filename:.*$" > actual &&
\r
195 +test_cmp expected actual &&
\r
196 +test -f "$gen_msg_filename"
\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 | notmuch_search_sanitize > actual &&
\r
209 +test_cmp - actual <<EOF
\r
210 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox tmp 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 > 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 | notmuch_search_sanitize > actual &&
\r
252 +test_cmp - actual <<EOF
\r
253 +thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; test message 3 (inbox tmp)
\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 > 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 | notmuch_search_sanitize > 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
277 +test_expect_success 'Make maildir flags out of sync with the database' '
\r
278 +ls $MAIL_DIR > expected &&
\r
279 +mv $MAIL_DIR/msg-001:2,RS $MAIL_DIR/msg-001:2, &&
\r
280 +mv $MAIL_DIR/msg-002:2,RS $MAIL_DIR/msg-002:2, &&
\r
281 +increment_mtime $MAIL_DIR
\r
284 +test_expect_success 'Test whether dump/new/restore synchronizes the maildir flags with the database' '
\r
285 +notmuch dump dump.txt &&
\r
287 +notmuch restore dump.txt &&
\r
288 +ls $MAIL_DIR > actual &&
\r
289 +test_cmp expected actual
\r
293 diff --git a/test/notmuch-test b/test/notmuch-test
\r
294 index 60c3ecb..3691f0d 100755
\r
295 --- a/test/notmuch-test
\r
296 +++ b/test/notmuch-test
\r
297 @@ -16,7 +16,7 @@ fi
\r
301 -TESTS="basic new search json thread-naming reply dump-restore uuencode thread-order author-order from-guessing long-id encoding emacs"
\r
302 +TESTS="basic new search json thread-naming reply dump-restore uuencode thread-order author-order from-guessing long-id encoding emacs maildir-sync"
\r
304 # Clean up any results from a previous run
\r
305 rm -r test-results >/dev/null 2>/dev/null
\r
306 diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
307 index 8f39aa7..43a1314 100644
\r
308 --- a/test/test-lib.sh
\r
309 +++ b/test/test-lib.sh
\r
310 @@ -245,6 +245,12 @@ increment_mtime ()
\r
311 # Generate the message in directory 'directory/of/choice' within
\r
312 # the mail store. The directory will be created if necessary.
\r
316 +# Store the message in file 'name'. The default is to store it
\r
317 +# in 'msg-<count>', where <count> is three-digit number of the
\r
322 # Text to use as the body of the email message
\r
323 @@ -281,10 +287,14 @@ generate_message ()
\r
324 local additional_headers
\r
326 gen_msg_cnt=$((gen_msg_cnt + 1))
\r
327 - gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
\r
328 + if [ -z "${template[filename]}" ]; then
\r
329 + gen_msg_name="msg-$(printf "%03d" $gen_msg_cnt)"
\r
331 + gen_msg_name=${template[filename]}
\r
334 if [ -z "${template[id]}" ]; then
\r
335 - gen_msg_id="${gen_msg_name}@notmuch-test-suite"
\r
336 + gen_msg_id="${gen_msg_name%:2,*}@notmuch-test-suite"
\r
338 gen_msg_id="${template[id]}"
\r