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