]> git.notmuchmail.org Git - notmuch/blob - test/notmuch-test
fix expected test result to include Bcc lines
[notmuch] / test / notmuch-test
1 #!/bin/bash
2 set -e
3
4 export TZ=UTC+8
5
6 find_notmuch_binary ()
7 {
8     dir=$1
9
10     while [ -n "$dir" ]; do
11         bin=$dir/notmuch
12         if [ -x $bin ]; then
13             echo $bin
14             return
15         fi
16         dir=$(dirname $dir)
17         if [ "$dir" = "/" ]; then
18             break
19         fi
20     done
21
22     echo notmuch
23 }
24
25 increment_mtime_amount=0
26 increment_mtime ()
27 {
28     dir=$1
29
30     increment_mtime_amount=$((increment_mtime_amount + 1))
31     touch -d "+${increment_mtime_amount} seconds" $dir
32 }
33
34 # Generate a new message in the mail directory, with a unique message
35 # ID and subject. The message is not added to the index.
36 #
37 # After this function returns, the filename of the generated message
38 # is available as $gen_msg_filename and the message ID is available as
39 # $gen_msg_id .
40 #
41 # This function supports named parameters with the bash syntax for
42 # assigning a value to an associative array ([name]=value). The
43 # supported parameters are:
44 #
45 #  [dir]=directory/of/choice
46 #
47 #       Generate the message in directory 'directory/of/choice' within
48 #       the mail store. The directory will be created if necessary.
49 #
50 #  [body]=text
51 #
52 #       Text to use as the body of the email message
53 #
54 #  '[from]="Some User <user@example.com>"'
55 #  '[to]="Some User <user@example.com>"'
56 #  '[subject]="Subject of email message"'
57 #  '[date]="RFC 822 Date"'
58 #
59 #       Values for email headers. If not provided, default values will
60 #       be generated instead.
61 #
62 #  '[cc]="Some User <user@example.com>"'
63 #  [reply-to]=some-address
64 #  [in-reply-to]=<message-id>
65 #  '[header]=full header line, including keyword'
66 #
67 #       Additional values for email headers. If these are not provided
68 #       then the relevant headers will simply not appear in the
69 #       message.
70 #
71 #  '[id]=<message-id>'
72 #
73 #       Controls the message-id of the created message.
74 gen_msg_cnt=0
75 gen_msg_filename=""
76 gen_msg_id=""
77 generate_message ()
78 {
79     # This is our (bash-specific) magic for doing named parameters
80     local -A template="($@)"
81     local additional_headers
82
83     if [ -z "${template[id]}" ]; then
84         gen_msg_cnt=$((gen_msg_cnt + 1))
85         gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
86         gen_msg_id="${gen_msg_name}@notmuch-test-suite"
87     else
88         gen_msg_name="msg-${template[id]}"
89         gen_msg_id="${template[id]}"
90     fi
91
92     if [ -z "${template[dir]}" ]; then
93         gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
94     else
95         gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
96         mkdir -p $(dirname $gen_msg_filename)
97     fi
98
99     if [ -z "${template[body]}" ]; then
100         template[body]="This is just a test message (#${gen_msg_cnt})"
101     fi
102
103     if [ -z "${template[from]}" ]; then
104         template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"
105     fi
106
107     if [ -z "${template[to]}" ]; then
108         template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"
109     fi
110
111     if [ -z "${template[subject]}" ]; then
112         template[subject]="Test message #${gen_msg_cnt}"
113     fi
114
115     if [ -z "${template[date]}" ]; then
116         template[date]="Tue, 05 Jan 2001 15:43:57 -0800"
117     fi
118
119     additional_headers=""
120     if [ ! -z "${template[header]}" ]; then
121         additional_headers="${template[header]}
122 ${additional_headers}"
123     fi
124
125     if [ ! -z "${template[reply-to]}" ]; then
126         additional_headers="Reply-To: ${template[reply-to]}
127 ${additional_headers}"
128     fi
129
130     if [ ! -z "${template[in-reply-to]}" ]; then
131         additional_headers="In-Reply-To: ${template[in-reply-to]}
132 ${additional_headers}"
133     fi
134
135     if [ ! -z "${template[cc]}" ]; then
136         additional_headers="Cc: ${template[cc]}
137 ${additional_headers}"
138     fi
139
140
141 cat <<EOF >$gen_msg_filename
142 From: ${template[from]}
143 To: ${template[to]}
144 Message-Id: <${gen_msg_id}>
145 Subject: ${template[subject]}
146 Date: ${template[date]}
147 ${additional_headers}
148 ${template[body]}
149 EOF
150
151     # Ensure that the mtime of the containing directory is updated
152     increment_mtime $(dirname ${gen_msg_filename})
153 }
154
155 # Generate a new message and add it to the index.
156 #
157 # All of the arguments and return values supported by generate_message
158 # are also supported here, so see that function for details.
159 add_message ()
160 {
161     generate_message "$@"
162
163     $NOTMUCH new > /dev/null
164 }
165
166 tests=0
167 test_failures=0
168
169 pass_if_equal ()
170 {
171     output=$1
172     expected=$2
173
174     tests=$((tests + 1))
175
176     if [ "$output" = "$expected" ]; then
177         echo "  PASS"
178     else
179         echo "  FAIL"
180         testname=test-$(printf "%03d" $tests)
181         echo "$expected" > $testname.expected
182         echo "$output" > $testname.output
183         diff -u $testname.expected $testname.output || true
184         test_failures=$((test_failures + 1))
185     fi
186 }
187
188 TEST_DIR=$(pwd)/test.$$
189 MAIL_DIR=${TEST_DIR}/mail
190 export NOTMUCH_CONFIG=${TEST_DIR}/notmuch-config
191 NOTMUCH=$(find_notmuch_binary $(pwd))
192
193 NOTMUCH_NEW ()
194 {
195     $NOTMUCH new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
196 }
197
198 notmuch_search_sanitize ()
199 {
200     sed -r -e 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
201 }
202
203 NOTMUCH_SHOW_FILENAME_SQUELCH='s,filename:.*/mail,filename:/XXX/mail,'
204 notmuch_show_sanitize ()
205 {
206     sed -e "$NOTMUCH_SHOW_FILENAME_SQUELCH"
207 }
208
209 rm -rf ${TEST_DIR}
210 mkdir ${TEST_DIR}
211 cd ${TEST_DIR}
212
213 mkdir ${MAIL_DIR}
214
215 cat <<EOF > ${NOTMUCH_CONFIG}
216 [database]
217 path=${MAIL_DIR}
218
219 [user]
220 name=Notmuch Test Suite
221 primary_email=test_suite@notmuchmail.org
222 other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
223 EOF
224
225 printf "Testing \"notmuch new\" in several variations:\n"
226 printf " No new messages...\t\t\t\t"
227 output=$(NOTMUCH_NEW)
228 pass_if_equal "$output" "No new mail."
229
230 printf " Single new message...\t\t\t\t"
231 generate_message
232 output=$(NOTMUCH_NEW)
233 pass_if_equal "$output" "Added 1 new message to the database."
234
235 printf " Multiple new messages...\t\t\t"
236 generate_message
237 generate_message
238 output=$(NOTMUCH_NEW)
239 pass_if_equal "$output" "Added 2 new messages to the database."
240
241 printf " No new messages (non-empty DB)...\t\t"
242 output=$(NOTMUCH_NEW)
243 pass_if_equal "$output" "No new mail."
244
245 printf " New directories...\t\t\t\t"
246 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
247 mkdir ${MAIL_DIR}/def
248 mkdir ${MAIL_DIR}/ghi
249 generate_message [dir]=def
250
251 output=$(NOTMUCH_NEW)
252 pass_if_equal "$output" "Added 1 new message to the database."
253
254 printf " Alternate inode order...\t\t\t"
255
256 rm -rf ${MAIL_DIR}/.notmuch
257 mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc
258 rm ${MAIL_DIR}/def/*
259 generate_message [dir]=abc
260
261 output=$(NOTMUCH_NEW)
262 pass_if_equal "$output" "Added 1 new message to the database."
263
264 printf " Message moved in...\t\t\t\t"
265 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
266 generate_message
267 tmp_msg_filename=tmp/$gen_msg_filename
268 mkdir -p $(dirname $tmp_msg_filename)
269 mv $gen_msg_filename $tmp_msg_filename
270 increment_mtime ${MAIL_DIR}
271 $NOTMUCH new > /dev/null
272 mv $tmp_msg_filename $gen_msg_filename
273 increment_mtime ${MAIL_DIR}
274 output=$(NOTMUCH_NEW)
275 pass_if_equal "$output" "Added 1 new message to the database."
276
277 printf " Renamed message...\t\t\t\t"
278
279 generate_message
280 $NOTMUCH new > /dev/null
281 mv $gen_msg_filename ${gen_msg_filename}-renamed
282 increment_mtime ${MAIL_DIR}
283 output=$(NOTMUCH_NEW)
284 pass_if_equal "$output" "No new mail. Detected 1 file rename."
285
286 printf " Deleted message...\t\t\t\t"
287
288 rm ${gen_msg_filename}-renamed
289 increment_mtime ${MAIL_DIR}
290 output=$(NOTMUCH_NEW)
291 pass_if_equal "$output" "No new mail. Removed 1 message."
292
293 printf " Renamed directory...\t\t\t\t"
294
295 generate_message [dir]=dir
296 generate_message [dir]=dir
297 generate_message [dir]=dir
298
299 $NOTMUCH new > /dev/null
300
301 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
302 increment_mtime ${MAIL_DIR}
303
304 output=$(NOTMUCH_NEW)
305 pass_if_equal "$output" "No new mail. Detected 3 file renames."
306
307 printf " Deleted directory...\t\t\t\t"
308
309 rm -rf ${MAIL_DIR}/dir-renamed
310 increment_mtime ${MAIL_DIR}
311
312 output=$(NOTMUCH_NEW)
313 pass_if_equal "$output" "No new mail. Removed 3 messages."
314
315 printf " New directory (at end of list)...\t\t"
316
317 generate_message [dir]=zzz
318 generate_message [dir]=zzz
319 generate_message [dir]=zzz
320
321 output=$(NOTMUCH_NEW)
322 pass_if_equal "$output" "Added 3 new messages to the database."
323
324 printf " Deleted directory (end of list)...\t\t"
325
326 rm -rf ${MAIL_DIR}/zzz
327 increment_mtime ${MAIL_DIR}
328
329 output=$(NOTMUCH_NEW)
330 pass_if_equal "$output" "No new mail. Removed 3 messages."
331
332 printf " New symlink to directory...\t\t\t"
333
334 rm -rf ${MAIL_DIR}/.notmuch
335 mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir
336
337 mkdir ${MAIL_DIR}
338 ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink
339
340 output=$(NOTMUCH_NEW)
341 pass_if_equal "$output" "Added 1 new message to the database."
342
343 printf " New symlink to a file...\t\t\t"
344 generate_message
345 external_msg_filename=${TEST_DIR}/external/$(basename $gen_msg_filename)
346 mkdir -p $(dirname $external_msg_filename)
347 mv $gen_msg_filename $external_msg_filename
348 ln -s $external_msg_filename $gen_msg_filename
349 increment_mtime ${MAIL_DIR}
350 output=$(NOTMUCH_NEW)
351 pass_if_equal "$output" "Added 1 new message to the database."
352
353 printf " New two-level directory...\t\t\t"
354
355 generate_message [dir]=two/levels
356 generate_message [dir]=two/levels
357 generate_message [dir]=two/levels
358
359 output=$(NOTMUCH_NEW)
360 pass_if_equal "$output" "Added 3 new messages to the database."
361
362 printf " Deleted two-level directory...\t\t\t"
363
364 rm -rf ${MAIL_DIR}/two
365 increment_mtime ${MAIL_DIR}
366
367 output=$(NOTMUCH_NEW)
368 pass_if_equal "$output" "No new mail. Removed 3 messages."
369
370 printf "\nTesting \"notmuch search\" in several variations:\n"
371
372 printf " Search body...\t\t\t\t\t"
373 add_message '[subject]="body search"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [body]=bodysearchtest
374 output=$($NOTMUCH search bodysearchtest | notmuch_search_sanitize)
375 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)"
376
377 printf " Search by from:...\t\t\t\t"
378 add_message '[subject]="search by from"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom
379 output=$($NOTMUCH search from:searchbyfrom | notmuch_search_sanitize)
380 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)"
381
382 printf " Search by to:...\t\t\t\t"
383 add_message '[subject]="search by to"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto
384 output=$($NOTMUCH search to:searchbyto | notmuch_search_sanitize)
385 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)"
386
387 printf " Search by subject:...\t\t\t\t"
388 add_message [subject]=subjectsearchtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
389 output=$($NOTMUCH search subject:subjectsearchtest | notmuch_search_sanitize)
390 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)"
391
392 printf " Search by id:...\t\t\t\t"
393 add_message '[subject]="search by id"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
394 output=$($NOTMUCH search id:${gen_msg_id} | notmuch_search_sanitize)
395 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)"
396
397 printf " Search by tag:...\t\t\t\t"
398 add_message '[subject]="search by tag"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
399 $NOTMUCH tag +searchbytag id:${gen_msg_id}
400 output=$($NOTMUCH search tag:searchbytag | notmuch_search_sanitize)
401 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)"
402
403 printf " Search by thread:...\t\t\t\t"
404 add_message '[subject]="search by thread"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
405 thread_id=$($NOTMUCH search id:${gen_msg_id} | sed -e 's/thread:\([a-f0-9]*\).*/\1/')
406 output=$($NOTMUCH search thread:${thread_id} | notmuch_search_sanitize)
407 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)"
408
409 printf " Search body (phrase)...\t\t\t"
410 add_message '[subject]="body search (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="body search (phrase)"'
411 add_message '[subject]="negative result"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="This phrase should not match the body search"'
412 output=$($NOTMUCH search '\"body search (phrase)\"' | notmuch_search_sanitize)
413 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)"
414
415 printf " Search by from: (address)...\t\t\t"
416 add_message '[subject]="search by from (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom@example.com
417 output=$($NOTMUCH search from:searchbyfrom@example.com | notmuch_search_sanitize)
418 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)"
419
420 printf " Search by from: (name)...\t\t\t"
421 add_message '[subject]="search by from (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]="Search By From Name <test@example.com>"'
422 output=$($NOTMUCH search from:'Search By From Name' | notmuch_search_sanitize)
423 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"
424
425 printf " Search by to: (address)...\t\t\t"
426 add_message '[subject]="search by to (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto@example.com
427 output=$($NOTMUCH search to:searchbyto@example.com | notmuch_search_sanitize)
428 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)"
429
430 printf " Search by to: (name)...\t\t\t"
431 add_message '[subject]="search by to (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[to]="Search By To Name <test@example.com>"'
432 output=$($NOTMUCH search to:'Search By To Name' | notmuch_search_sanitize)
433 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"
434
435 printf " Search by subject: (phrase)...\t\t\t"
436 add_message '[subject]="subject search test (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
437 add_message '[subject]="this phrase should not match the subject search test"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
438 output=$($NOTMUCH search 'subject:\"subject search test (phrase)\"' | notmuch_search_sanitize)
439 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)"
440
441 printf " Search for all messages (\"*\"):...\t\t"
442 output=$($NOTMUCH search '*' | notmuch_search_sanitize)
443 pass_if_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Test message #6 (inbox unread)
444 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Test message #14 (inbox unread)
445 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)
446 thread:XXX   2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)
447 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)
448 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)
449 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)
450 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)
451 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)
452 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)
453 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; negative result (inbox unread)
454 thread:XXX   2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)
455 thread:XXX   2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)
456 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)
457 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)
458 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)
459 thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match the subject search test (inbox unread)"
460
461 printf " Search body (utf-8):...\t\t\t"
462 add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="message body utf8: bödý"'
463 output=$($NOTMUCH search 'bödý' | notmuch_search_sanitize)
464 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)"
465
466 printf "\nTesting --format=json output:\n"
467
468 printf " Show message: json...\t\t\t\t"
469 add_message '[subject]="json-show-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="json-show-message"'
470 output=$($NOTMUCH show --format=json 'json-show-message')
471 pass_if_equal "$output" '[[[{"id": "'${gen_msg_id}'", "match": true, "filename": "'${gen_msg_filename}'", "timestamp": 946728000, "date_relative": "2000-01-01", "tags": ["inbox","unread"], "headers": {"Subject": "json-show-subject", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@notmuchmail.org>", "Cc": "", "Bcc": "", "Date": "Sat, 01 Jan 2000 12:00:00 -0000"}, "body": [{"id": 1, "content-type": "text/plain", "content": "json-show-message\n"}]}, []]]]'
472
473 printf " Search message: json...\t\t\t"
474 add_message '[subject]="json-search-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="json-search-message"'
475 output=$($NOTMUCH search --format=json 'json-search-message' | notmuch_search_sanitize)
476 pass_if_equal "$output" '[{"thread": "XXX",
477 "timestamp": 946728000,
478 "matched": 1,
479 "total": 1,
480 "authors": "Notmuch Test Suite",
481 "subject": "json-search-subject",
482 "tags": ["inbox", "unread"]}]'
483
484 printf " Search by subject (utf-8):...\t\t\t"
485 add_message [subject]=utf8-sübjéct '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
486 output=$($NOTMUCH search subject:utf8-sübjéct | notmuch_search_sanitize)
487 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; utf8-sübjéct (inbox unread)"
488
489 printf " Show message: json, utf-8...\t\t\t"
490 add_message '[subject]="json-show-utf8-body-sübjéct"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="jsön-show-méssage"'
491 output=$($NOTMUCH show --format=json 'jsön-show-méssage')
492 pass_if_equal "$output" '[[[{"id": "'${gen_msg_id}'", "match": true, "filename": "'${gen_msg_filename}'", "timestamp": 946728000, "date_relative": "2000-01-01", "tags": ["inbox","unread"], "headers": {"Subject": "json-show-utf8-body-sübjéct", "From": "Notmuch Test Suite <test_suite@notmuchmail.org>", "To": "Notmuch Test Suite <test_suite@notmuchmail.org>", "Cc": "", "Bcc": "", "Date": "Sat, 01 Jan 2000 12:00:00 -0000"}, "body": [{"id": 1, "content-type": "text/plain", "content": "jsön-show-méssage\n"}]}, []]]]'
493
494 printf " Search message: json, utf-8...\t\t\t"
495 add_message '[subject]="json-search-utf8-body-sübjéct"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="jsön-search-méssage"'
496 output=$($NOTMUCH search --format=json 'jsön-search-méssage' | notmuch_search_sanitize)
497 pass_if_equal "$output" '[{"thread": "XXX",
498 "timestamp": 946728000,
499 "matched": 1,
500 "total": 1,
501 "authors": "Notmuch Test Suite",
502 "subject": "json-search-utf8-body-sübjéct",
503 "tags": ["inbox", "unread"]}]'
504
505 printf "\nTesting naming of threads with changing subject:\n"
506 add_message '[subject]="thread-naming: Initial thread subject"' \
507             '[date]="Fri, 05 Jan 2001 15:43:56 -0800"'
508 first=${gen_msg_cnt}
509 parent=${gen_msg_id}
510 add_message '[subject]="thread-naming: Older changed subject"' \
511             '[date]="Sat, 06 Jan 2001 15:43:56 -0800"' \
512             "[in-reply-to]=\<$parent\>"
513 add_message '[subject]="thread-naming: Newer changed subject"' \
514             '[date]="Sun, 07 Jan 2001 15:43:56 -0800"' \
515             "[in-reply-to]=\<$parent\>"
516 add_message '[subject]="thread-naming: Final thread subject"' \
517             '[date]="Mon, 08 Jan 2001 15:43:56 -0800"' \
518             "[in-reply-to]=\<$parent\>"
519 final=${gen_msg_id}
520
521 printf " Initial thread name (oldest-first search)...\t"
522 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
523 pass_if_equal "$output" "thread:XXX   2001-01-05 [4/4] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
524
525 printf " Initial thread name (newest-first search)...\t"
526 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
527 pass_if_equal "$output" "thread:XXX   2001-01-08 [4/4] Notmuch Test Suite; thread-naming: Final thread subject (inbox unread)"
528
529 # Remove oldest and newest messages from search results
530 $NOTMUCH tag -inbox id:$parent or id:$final
531
532 printf " Changed thread name (oldest-first search)...\t"
533 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
534 pass_if_equal "$output" "thread:XXX   2001-01-06 [2/4] Notmuch Test Suite; thread-naming: Older changed subject (inbox unread)"
535
536 printf " Changed thread name (newest-first search)...\t"
537 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
538 pass_if_equal "$output" "thread:XXX   2001-01-07 [2/4] Notmuch Test Suite; thread-naming: Newer changed subject (inbox unread)"
539
540 printf " Ignore added reply prefix (Re:)...\t\t"
541 add_message '[subject]="Re: thread-naming: Initial thread subject"' \
542             '[date]="Tue, 09 Jan 2001 15:43:45 -0800"' \
543             "[in-reply-to]=\<$parent\>"
544 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
545 pass_if_equal "$output" "thread:XXX   2001-01-09 [3/5] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
546
547 printf " Ignore added reply prefix (Aw:)...\t\t"
548 add_message '[subject]="Aw: thread-naming: Initial thread subject"' \
549             '[date]="Wed, 10 Jan 2001 15:43:45 -0800"' \
550             "[in-reply-to]=\<$parent\>"
551 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
552 pass_if_equal "$output" "thread:XXX   2001-01-10 [4/6] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
553
554 printf " Ignore added reply prefix (Vs:)...\t\t"
555 add_message '[subject]="Vs: thread-naming: Initial thread subject"' \
556             '[date]="Thu, 11 Jan 2001 15:43:45 -0800"' \
557             "[in-reply-to]=\<$parent\>"
558 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
559 pass_if_equal "$output" "thread:XXX   2001-01-11 [5/7] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
560
561 printf " Ignore added reply prefix (Sv:)...\t\t"
562 add_message '[subject]="Sv: thread-naming: Initial thread subject"' \
563             '[date]="Fri, 12 Jan 2001 15:43:45 -0800"' \
564             "[in-reply-to]=\<$parent\>"
565 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
566 pass_if_equal "$output" "thread:XXX   2001-01-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
567
568 printf " Test order of messages in \"notmuch show\"\t"
569 output=$($NOTMUCH show thread-naming | notmuch_show_sanitize)
570 pass_if_equal "$output" "\fmessage{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-$(printf "%03d" $first)
571 \fheader{
572 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
573 Subject: thread-naming: Initial thread subject
574 From: Notmuch Test Suite <test_suite@notmuchmail.org>
575 To: Notmuch Test Suite <test_suite@notmuchmail.org>
576 Date: Fri, 05 Jan 2001 15:43:56 -0800
577 \fheader}
578 \fbody{
579 \fpart{ ID: 1, Content-type: text/plain
580 This is just a test message (#$first)
581 \fpart}
582 \fbody}
583 \fmessage}
584 \fmessage{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1)))
585 \fheader{
586 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
587 Subject: thread-naming: Older changed subject
588 From: Notmuch Test Suite <test_suite@notmuchmail.org>
589 To: Notmuch Test Suite <test_suite@notmuchmail.org>
590 Date: Sat, 06 Jan 2001 15:43:56 -0800
591 \fheader}
592 \fbody{
593 \fpart{ ID: 1, Content-type: text/plain
594 This is just a test message (#$((first + 1)))
595 \fpart}
596 \fbody}
597 \fmessage}
598 \fmessage{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2)))
599 \fheader{
600 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
601 Subject: thread-naming: Newer changed subject
602 From: Notmuch Test Suite <test_suite@notmuchmail.org>
603 To: Notmuch Test Suite <test_suite@notmuchmail.org>
604 Date: Sun, 07 Jan 2001 15:43:56 -0800
605 \fheader}
606 \fbody{
607 \fpart{ ID: 1, Content-type: text/plain
608 This is just a test message (#$((first + 2)))
609 \fpart}
610 \fbody}
611 \fmessage}
612 \fmessage{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3)))
613 \fheader{
614 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
615 Subject: thread-naming: Final thread subject
616 From: Notmuch Test Suite <test_suite@notmuchmail.org>
617 To: Notmuch Test Suite <test_suite@notmuchmail.org>
618 Date: Mon, 08 Jan 2001 15:43:56 -0800
619 \fheader}
620 \fbody{
621 \fpart{ ID: 1, Content-type: text/plain
622 This is just a test message (#$((first + 3)))
623 \fpart}
624 \fbody}
625 \fmessage}
626 \fmessage{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4)))
627 \fheader{
628 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
629 Subject: Re: thread-naming: Initial thread subject
630 From: Notmuch Test Suite <test_suite@notmuchmail.org>
631 To: Notmuch Test Suite <test_suite@notmuchmail.org>
632 Date: Tue, 09 Jan 2001 15:43:45 -0800
633 \fheader}
634 \fbody{
635 \fpart{ ID: 1, Content-type: text/plain
636 This is just a test message (#$((first + 4)))
637 \fpart}
638 \fbody}
639 \fmessage}
640 \fmessage{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5)))
641 \fheader{
642 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
643 Subject: Aw: thread-naming: Initial thread subject
644 From: Notmuch Test Suite <test_suite@notmuchmail.org>
645 To: Notmuch Test Suite <test_suite@notmuchmail.org>
646 Date: Wed, 10 Jan 2001 15:43:45 -0800
647 \fheader}
648 \fbody{
649 \fpart{ ID: 1, Content-type: text/plain
650 This is just a test message (#$((first + 5)))
651 \fpart}
652 \fbody}
653 \fmessage}
654 \fmessage{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6)))
655 \fheader{
656 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
657 Subject: Vs: thread-naming: Initial thread subject
658 From: Notmuch Test Suite <test_suite@notmuchmail.org>
659 To: Notmuch Test Suite <test_suite@notmuchmail.org>
660 Date: Thu, 11 Jan 2001 15:43:45 -0800
661 \fheader}
662 \fbody{
663 \fpart{ ID: 1, Content-type: text/plain
664 This is just a test message (#$((first + 6)))
665 \fpart}
666 \fbody}
667 \fmessage}
668 \fmessage{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7)))
669 \fheader{
670 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
671 Subject: Sv: thread-naming: Initial thread subject
672 From: Notmuch Test Suite <test_suite@notmuchmail.org>
673 To: Notmuch Test Suite <test_suite@notmuchmail.org>
674 Date: Fri, 12 Jan 2001 15:43:45 -0800
675 \fheader}
676 \fbody{
677 \fpart{ ID: 1, Content-type: text/plain
678 This is just a test message (#$((first + 7)))
679 \fpart}
680 \fbody}
681 \fmessage}"
682
683 printf "\nTesting \"notmuch reply\" in several variations:\n"
684
685 printf " Basic reply...\t\t\t\t\t"
686 add_message '[from]="Sender <sender@example.com>"' \
687              [to]=test_suite@notmuchmail.org \
688              [subject]=notmuch-reply-test \
689             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
690             '[body]="basic reply test"'
691
692 output=$($NOTMUCH reply id:${gen_msg_id})
693 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
694 Subject: Re: notmuch-reply-test
695 To: Sender <sender@example.com>
696 Bcc: test_suite@notmuchmail.org
697 In-Reply-To: <${gen_msg_id}>
698 References: <${gen_msg_id}>
699
700 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
701 > basic reply test"
702
703 printf " Multiple recipients...\t\t\t\t"
704 add_message '[from]="Sender <sender@example.com>"' \
705             '[to]="test_suite@notmuchmail.org, Someone Else <someone@example.com>"' \
706              [subject]=notmuch-reply-test \
707             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
708             '[body]="Multiple recipients"'
709
710 output=$($NOTMUCH reply id:${gen_msg_id})
711 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
712 Subject: Re: notmuch-reply-test
713 To: Sender <sender@example.com>, Someone Else <someone@example.com>
714 Bcc: test_suite@notmuchmail.org
715 In-Reply-To: <${gen_msg_id}>
716 References: <${gen_msg_id}>
717
718 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
719 > Multiple recipients"
720
721 printf " Reply with CC...\t\t\t\t"
722 add_message '[from]="Sender <sender@example.com>"' \
723              [to]=test_suite@notmuchmail.org \
724             '[cc]="Other Parties <cc@example.com>"' \
725              [subject]=notmuch-reply-test \
726             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
727             '[body]="reply with CC"'
728
729 output=$($NOTMUCH reply id:${gen_msg_id})
730 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
731 Subject: Re: notmuch-reply-test
732 To: Sender <sender@example.com>
733 Cc: Other Parties <cc@example.com>
734 Bcc: test_suite@notmuchmail.org
735 In-Reply-To: <${gen_msg_id}>
736 References: <${gen_msg_id}>
737
738 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
739 > reply with CC"
740
741 printf " Reply from alternate address...\t\t"
742 add_message '[from]="Sender <sender@example.com>"' \
743              [to]=test_suite_other@notmuchmail.org \
744              [subject]=notmuch-reply-test \
745             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
746             '[body]="reply from alternate address"'
747
748 output=$($NOTMUCH reply id:${gen_msg_id})
749 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
750 Subject: Re: notmuch-reply-test
751 To: Sender <sender@example.com>
752 Bcc: test_suite@notmuchmail.org
753 In-Reply-To: <${gen_msg_id}>
754 References: <${gen_msg_id}>
755
756 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
757 > reply from alternate address"
758
759 printf " Support for Reply-To...\t\t\t"
760 add_message '[from]="Sender <sender@example.com>"' \
761              [to]=test_suite@notmuchmail.org \
762              [subject]=notmuch-reply-test \
763             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
764             '[body]="support for reply-to"' \
765             '[reply-to]="Sender <elsewhere@example.com>"'
766
767 output=$($NOTMUCH reply id:${gen_msg_id})
768 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
769 Subject: Re: notmuch-reply-test
770 To: Sender <elsewhere@example.com>
771 Bcc: test_suite@notmuchmail.org
772 In-Reply-To: <${gen_msg_id}>
773 References: <${gen_msg_id}>
774
775 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
776 > support for reply-to"
777
778 printf " Un-munging Reply-To...\t\t\t\t"
779 add_message '[from]="Sender <sender@example.com>"' \
780             '[to]="Some List <list@example.com>"' \
781              [subject]=notmuch-reply-test \
782             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
783             '[body]="Un-munging Reply-To"' \
784             '[reply-to]="Evil Munging List <list@example.com>"'
785
786 output=$($NOTMUCH reply id:${gen_msg_id})
787 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
788 Subject: Re: notmuch-reply-test
789 To: Sender <sender@example.com>, Some List <list@example.com>
790 Bcc: test_suite@notmuchmail.org
791 In-Reply-To: <${gen_msg_id}>
792 References: <${gen_msg_id}>
793
794 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
795 > Un-munging Reply-To"
796
797 printf "\nTesting handling of uuencoded data:\n"
798
799 add_message [subject]=uuencodetest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
800 '[body]="This message is used to ensure that notmuch correctly handles a
801 message containing a block of uuencoded data. First, we have a marker
802 this content beforeuudata . Then we beging the uunencoded data itself:
803
804 begin 644 bogus-uuencoded-data
805 M0123456789012345678901234567890123456789012345678901234567890
806 MOBVIOUSLY, THIS IS NOT ANY SORT OF USEFUL UUNECODED DATA.    
807 MINSTEAD THIS IS JUST A WAY TO ENSURE THAT THIS BLOCK OF DATA 
808 MIS CORRECTLY IGNORED WHEN NOTMUCH CREATES ITS INDEX. SO WE   
809 MINCLUDE A DURINGUUDATA MARKER THAT SHOULD NOT RESULT IN ANY  
810 MSEARCH RESULT.                                               
811 \`
812 end
813
814 Finally, we have our afteruudata marker as well."'
815
816 printf " Ensure content before uu data is indexed...\t"
817 output=$($NOTMUCH search beforeuudata | notmuch_search_sanitize)
818 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
819 printf " Ensure uu data is not indexed...\t\t"
820 output=$($NOTMUCH search DURINGUUDATA | notmuch_search_sanitize)
821 pass_if_equal "$output" ""
822 printf " Ensure content after uu data is indexed...\t"
823 output=$($NOTMUCH search afteruudata | notmuch_search_sanitize)
824 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
825
826 printf "\nTesting \"notmuch dump\" and \"notmuch restore\":\n"
827
828 printf " Dumping all tags...\t\t\t\t"
829 $NOTMUCH dump dump.expected
830 pass_if_equal "$?" "0"
831
832 printf " Clearing all tags...\t\t\t\t"
833 sed -e 's/(\([^(]*\))$/()/' < dump.expected > clear.expected
834 $NOTMUCH restore clear.expected
835 $NOTMUCH dump clear.actual
836 pass_if_equal "$(< clear.actual)" "$(< clear.expected)"
837
838 printf " Restoring original tags...\t\t\t"
839 $NOTMUCH restore dump.expected
840 $NOTMUCH dump dump.actual
841 pass_if_equal "$(< dump.actual)" "$(< dump.expected)"
842
843 printf " Restore with nothing to do...\t\t\t"
844 $NOTMUCH restore dump.expected
845 pass_if_equal "$?" "0"
846
847 printf "\nTesting threading when messages received out of order:\n"
848 printf " Adding initial child message...\t\t"
849 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
850 output=$(NOTMUCH_NEW)
851 pass_if_equal "$output" "Added 1 new message to the database."
852 printf " Searching returns the message...\t\t"
853 output=$($NOTMUCH search foo | notmuch_search_sanitize)
854 pass_if_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; brokenthreadtest (inbox unread)"
855 printf " Adding second child message...\t\t\t"
856 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
857 output=$(NOTMUCH_NEW)
858 pass_if_equal "$output" "Added 1 new message to the database."
859 printf " Searching returns both messages in one thread..."
860 output=$($NOTMUCH search foo | notmuch_search_sanitize)
861 pass_if_equal "$output" "thread:XXX   2000-01-01 [2/2] Notmuch Test Suite; brokenthreadtest (inbox unread)"
862 printf " Adding parent message...\t\t\t"
863 generate_message [body]=foo [id]=parent-id [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
864 output=$(NOTMUCH_NEW)
865 pass_if_equal "$output" "Added 1 new message to the database."
866 printf " Searching returns all three messages in one thread..."
867 output=$($NOTMUCH search foo | notmuch_search_sanitize)
868 pass_if_equal "$output" "thread:XXX   2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
869
870 printf " Magic from guessing (nothing to go on)...\t"
871 add_message '[from]="Sender <sender@example.com>"' \
872              [to]=mailinglist@notmuchmail.org \
873              [subject]=notmuch-reply-test \
874             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
875             '[body]="from guessing test"'
876
877 output=$($NOTMUCH reply id:${gen_msg_id})
878 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
879 Subject: Re: notmuch-reply-test
880 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
881 Bcc: test_suite@notmuchmail.org
882 In-Reply-To: <${gen_msg_id}>
883 References: <${gen_msg_id}>
884
885 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
886 > from guessing test"
887
888 printf " Magic from guessing (Envelope-to:)...\t\t"
889 add_message '[from]="Sender <sender@example.com>"' \
890              [to]=mailinglist@notmuchmail.org \
891              [subject]=notmuch-reply-test \
892             '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
893             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
894             '[body]="from guessing test"'
895
896 output=$($NOTMUCH reply id:${gen_msg_id})
897 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
898 Subject: Re: notmuch-reply-test
899 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
900 Bcc: test_suite@notmuchmail.org
901 In-Reply-To: <${gen_msg_id}>
902 References: <${gen_msg_id}>
903
904 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
905 > from guessing test"
906
907 printf " Magic from guessing (X-Original-To:)...\t"
908 add_message '[from]="Sender <sender@example.com>"' \
909              [to]=mailinglist@notmuchmail.org \
910              [subject]=notmuch-reply-test \
911             '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
912             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
913             '[body]="from guessing test"'
914
915 output=$($NOTMUCH reply id:${gen_msg_id})
916 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
917 Subject: Re: notmuch-reply-test
918 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
919 Bcc: test_suite@notmuchmail.org
920 In-Reply-To: <${gen_msg_id}>
921 References: <${gen_msg_id}>
922
923 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
924 > from guessing test"
925
926 printf " Magic from guessing (Received: .. for ..)...\t"
927 add_message '[from]="Sender <sender@example.com>"' \
928              [to]=mailinglist@notmuchmail.org \
929              [subject]=notmuch-reply-test \
930             '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
931         by mail.notmuchmail.org (some MTA) with ESMTP id 12345678\
932         for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
933             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
934             '[body]="from guessing test"'
935
936 output=$($NOTMUCH reply id:${gen_msg_id})
937 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
938 Subject: Re: notmuch-reply-test
939 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
940 Bcc: test_suite@notmuchmail.org
941 In-Reply-To: <${gen_msg_id}>
942 References: <${gen_msg_id}>
943
944 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
945 > from guessing test"
946
947 printf " Magic from guessing (Received: domain)...\t"
948 add_message '[from]="Sender <sender@example.com>"' \
949              [to]=mailinglist@notmuchmail.org \
950              [subject]=notmuch-reply-test \
951             '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
952         by mail.otherdomain.org (some MTA) with ESMTP id 12345678\
953         Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
954             '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
955             '[body]="from guessing test"'
956
957 output=$($NOTMUCH reply id:${gen_msg_id})
958 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
959 Subject: Re: notmuch-reply-test
960 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
961 Bcc: test_suite@notmuchmail.org
962 In-Reply-To: <${gen_msg_id}>
963 References: <${gen_msg_id}>
964
965 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
966 > from guessing test"
967
968
969 echo ""
970 echo "Notmuch test suite complete."
971
972 if [ "$test_failures" = "0" ]; then
973     echo "All $tests tests passed."
974     rm -rf ${TEST_DIR}
975 else
976     echo "$test_failures/$tests tests failed. The failures can be investigated in:"
977     echo "${TEST_DIR}"
978 fi
979
980 echo ""
981
982 exit $test_failures