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.
10 find_notmuch_binary ()
14 while [ -n "$dir" ]; do
21 if [ "$dir" = "/" ]; then
29 increment_mtime_amount=0
34 increment_mtime_amount=$((increment_mtime_amount + 1))
35 touch -d "+${increment_mtime_amount} seconds" $dir
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.
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
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:
49 # [dir]=directory/of/choice
51 # Generate the message in directory 'directory/of/choice' within
52 # the mail store. The directory will be created if necessary.
56 # Text to use as the body of the email message
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"'
63 # Values for email headers. If not provided, default values will
64 # be generated instead.
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'
71 # Additional values for email headers. If these are not provided
72 # then the relevant headers will simply not appear in the
77 # Controls the message-id of the created message.
83 # This is our (bash-specific) magic for doing named parameters
84 local -A template="($@)"
85 local additional_headers
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"
92 gen_msg_name="msg-${template[id]}"
93 gen_msg_id="${template[id]}"
96 if [ -z "${template[dir]}" ]; then
97 gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
99 gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
100 mkdir -p $(dirname $gen_msg_filename)
103 if [ -z "${template[body]}" ]; then
104 template[body]="This is just a test message (#${gen_msg_cnt})"
107 if [ -z "${template[from]}" ]; then
108 template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"
111 if [ -z "${template[to]}" ]; then
112 template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"
115 if [ -z "${template[subject]}" ]; then
116 template[subject]="Test message #${gen_msg_cnt}"
119 if [ -z "${template[date]}" ]; then
120 template[date]="Tue, 05 Jan 2001 15:43:57 -0800"
123 additional_headers=""
124 if [ ! -z "${template[header]}" ]; then
125 additional_headers="${template[header]}
126 ${additional_headers}"
129 if [ ! -z "${template[reply-to]}" ]; then
130 additional_headers="Reply-To: ${template[reply-to]}
131 ${additional_headers}"
134 if [ ! -z "${template[in-reply-to]}" ]; then
135 additional_headers="In-Reply-To: ${template[in-reply-to]}
136 ${additional_headers}"
139 if [ ! -z "${template[cc]}" ]; then
140 additional_headers="Cc: ${template[cc]}
141 ${additional_headers}"
145 cat <<EOF >$gen_msg_filename
146 From: ${template[from]}
148 Message-Id: <${gen_msg_id}>
149 Subject: ${template[subject]}
150 Date: ${template[date]}
151 ${additional_headers}
155 # Ensure that the mtime of the containing directory is updated
156 increment_mtime $(dirname ${gen_msg_filename})
159 # Generate a new message and add it to the index.
161 # All of the arguments and return values supported by generate_message
162 # are also supported here, so see that function for details.
165 generate_message "$@"
167 $NOTMUCH new > /dev/null
180 if [ "$output" = "$expected" ]; then
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))
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))
199 $NOTMUCH new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
202 notmuch_search_sanitize ()
204 sed -r -e 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
207 NOTMUCH_SHOW_FILENAME_SQUELCH='s,filename:.*/mail,filename:/XXX/mail,'
208 notmuch_show_sanitize ()
210 sed -e "$NOTMUCH_SHOW_FILENAME_SQUELCH"
219 cat <<EOF > ${NOTMUCH_CONFIG}
224 name=Notmuch Test Suite
225 primary_email=test_suite@notmuchmail.org
226 other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
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."
234 printf " Single new message...\t\t\t\t"
236 output=$(NOTMUCH_NEW)
237 pass_if_equal "$output" "Added 1 new message to the database."
239 printf " Multiple new messages...\t\t\t"
242 output=$(NOTMUCH_NEW)
243 pass_if_equal "$output" "Added 2 new messages to the database."
245 printf " No new messages (non-empty DB)...\t\t"
246 output=$(NOTMUCH_NEW)
247 pass_if_equal "$output" "No new mail."
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
255 output=$(NOTMUCH_NEW)
256 pass_if_equal "$output" "Added 1 new message to the database."
258 printf " Alternate inode order...\t\t\t"
260 rm -rf ${MAIL_DIR}/.notmuch
261 mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc
263 generate_message [dir]=abc
265 output=$(NOTMUCH_NEW)
266 pass_if_equal "$output" "Added 1 new message to the database."
268 printf " Message moved in...\t\t\t\t"
269 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
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."
281 printf " Renamed message...\t\t\t\t"
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."
290 printf " Deleted message...\t\t\t\t"
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."
297 printf " Renamed directory...\t\t\t\t"
299 generate_message [dir]=dir
300 generate_message [dir]=dir
301 generate_message [dir]=dir
303 $NOTMUCH new > /dev/null
305 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
306 increment_mtime ${MAIL_DIR}
308 output=$(NOTMUCH_NEW)
309 pass_if_equal "$output" "No new mail. Detected 3 file renames."
311 printf " Deleted directory...\t\t\t\t"
313 rm -rf ${MAIL_DIR}/dir-renamed
314 increment_mtime ${MAIL_DIR}
316 output=$(NOTMUCH_NEW)
317 pass_if_equal "$output" "No new mail. Removed 3 messages."
319 printf " New directory (at end of list)...\t\t"
321 generate_message [dir]=zzz
322 generate_message [dir]=zzz
323 generate_message [dir]=zzz
325 output=$(NOTMUCH_NEW)
326 pass_if_equal "$output" "Added 3 new messages to the database."
328 printf " Deleted directory (end of list)...\t\t"
330 rm -rf ${MAIL_DIR}/zzz
331 increment_mtime ${MAIL_DIR}
333 output=$(NOTMUCH_NEW)
334 pass_if_equal "$output" "No new mail. Removed 3 messages."
336 printf " New symlink to directory...\t\t\t"
338 rm -rf ${MAIL_DIR}/.notmuch
339 mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir
342 ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink
344 output=$(NOTMUCH_NEW)
345 pass_if_equal "$output" "Added 1 new message to the database."
347 printf " New symlink to a file...\t\t\t"
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."
357 printf " New two-level directory...\t\t\t"
359 generate_message [dir]=two/levels
360 generate_message [dir]=two/levels
361 generate_message [dir]=two/levels
363 output=$(NOTMUCH_NEW)
364 pass_if_equal "$output" "Added 3 new messages to the database."
366 printf " Deleted two-level directory...\t\t\t"
368 rm -rf ${MAIL_DIR}/two
369 increment_mtime ${MAIL_DIR}
371 output=$(NOTMUCH_NEW)
372 pass_if_equal "$output" "No new mail. Removed 3 messages."
374 printf "\nTesting \"notmuch search\" in several variations:\n"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
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)"
470 printf "\nTesting --format=json output:\n"
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"}]}, []]]]'
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,
484 "authors": "Notmuch Test Suite",
485 "subject": "json-search-subject",
486 "tags": ["inbox", "unread"]}]'
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)"
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"}]}, []]]]'
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,
505 "authors": "Notmuch Test Suite",
506 "subject": "json-search-utf8-body-sübjéct",
507 "tags": ["inbox", "unread"]}]'
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"'
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\>"
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)"
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)"
533 # Remove oldest and newest messages from search results
534 $NOTMUCH tag -inbox id:$parent or id:$final
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)"
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)"
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)"
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)"
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)"
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)"
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)
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
583 \fpart{ ID: 1, Content-type: text/plain
584 This is just a test message (#$first)
588 \fmessage{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1)))
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
597 \fpart{ ID: 1, Content-type: text/plain
598 This is just a test message (#$((first + 1)))
602 \fmessage{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2)))
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
611 \fpart{ ID: 1, Content-type: text/plain
612 This is just a test message (#$((first + 2)))
616 \fmessage{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3)))
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
625 \fpart{ ID: 1, Content-type: text/plain
626 This is just a test message (#$((first + 3)))
630 \fmessage{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4)))
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
639 \fpart{ ID: 1, Content-type: text/plain
640 This is just a test message (#$((first + 4)))
644 \fmessage{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5)))
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
653 \fpart{ ID: 1, Content-type: text/plain
654 This is just a test message (#$((first + 5)))
658 \fmessage{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6)))
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
667 \fpart{ ID: 1, Content-type: text/plain
668 This is just a test message (#$((first + 6)))
672 \fmessage{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7)))
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
681 \fpart{ ID: 1, Content-type: text/plain
682 This is just a test message (#$((first + 7)))
687 printf "\nTesting \"notmuch reply\" in several variations:\n"
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"'
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}>
704 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
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"'
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}>
722 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
723 > Multiple recipients"
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"'
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}>
742 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
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"'
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}>
760 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
761 > reply from alternate address"
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>"'
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}>
779 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
780 > support for reply-to"
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>"'
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}>
798 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
799 > Un-munging Reply-To"
801 printf " Message with header of exactly 200 bytes...\t"
803 add_message '[subject]="This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces"' \
804 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
805 '[body]="200-byte header"'
807 output=$($NOTMUCH reply id:${gen_msg_id})
808 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
809 Subject: Re: This subject is exactly 200 bytes in length. Other than its length there is not much of note here. Note that the length of 200 bytes includes the Subject: and Re: prefixes with two spaces
810 Bcc: test_suite@notmuchmail.org
811 In-Reply-To: <${gen_msg_id}>
812 References: <${gen_msg_id}>
814 On Tue, 05 Jan 2010 15:43:56 -0800, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
817 printf "\nTesting handling of uuencoded data:\n"
819 add_message [subject]=uuencodetest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
820 '[body]="This message is used to ensure that notmuch correctly handles a
821 message containing a block of uuencoded data. First, we have a marker
822 this content beforeuudata . Then we beging the uunencoded data itself:
824 begin 644 bogus-uuencoded-data
825 M0123456789012345678901234567890123456789012345678901234567890
826 MOBVIOUSLY, THIS IS NOT ANY SORT OF USEFUL UUNECODED DATA.
827 MINSTEAD THIS IS JUST A WAY TO ENSURE THAT THIS BLOCK OF DATA
828 MIS CORRECTLY IGNORED WHEN NOTMUCH CREATES ITS INDEX. SO WE
829 MINCLUDE A DURINGUUDATA MARKER THAT SHOULD NOT RESULT IN ANY
834 Finally, we have our afteruudata marker as well."'
836 printf " Ensure content before uu data is indexed...\t"
837 output=$($NOTMUCH search beforeuudata | notmuch_search_sanitize)
838 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
839 printf " Ensure uu data is not indexed...\t\t"
840 output=$($NOTMUCH search DURINGUUDATA | notmuch_search_sanitize)
841 pass_if_equal "$output" ""
842 printf " Ensure content after uu data is indexed...\t"
843 output=$($NOTMUCH search afteruudata | notmuch_search_sanitize)
844 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
846 printf "\nTesting \"notmuch dump\" and \"notmuch restore\":\n"
848 printf " Dumping all tags...\t\t\t\t"
849 $NOTMUCH dump dump.expected
850 pass_if_equal "$?" "0"
852 printf " Clearing all tags...\t\t\t\t"
853 sed -e 's/(\([^(]*\))$/()/' < dump.expected > clear.expected
854 $NOTMUCH restore clear.expected
855 $NOTMUCH dump clear.actual
856 pass_if_equal "$(< clear.actual)" "$(< clear.expected)"
858 printf " Restoring original tags...\t\t\t"
859 $NOTMUCH restore dump.expected
860 $NOTMUCH dump dump.actual
861 pass_if_equal "$(< dump.actual)" "$(< dump.expected)"
863 printf " Restore with nothing to do...\t\t\t"
864 $NOTMUCH restore dump.expected
865 pass_if_equal "$?" "0"
867 printf "\nTesting threading when messages received out of order:\n"
868 printf " Adding initial child message...\t\t"
869 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
870 output=$(NOTMUCH_NEW)
871 pass_if_equal "$output" "Added 1 new message to the database."
872 printf " Searching returns the message...\t\t"
873 output=$($NOTMUCH search foo | notmuch_search_sanitize)
874 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; brokenthreadtest (inbox unread)"
875 printf " Adding second child message...\t\t\t"
876 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
877 output=$(NOTMUCH_NEW)
878 pass_if_equal "$output" "Added 1 new message to the database."
879 printf " Searching returns both messages in one thread..."
880 output=$($NOTMUCH search foo | notmuch_search_sanitize)
881 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/2] Notmuch Test Suite; brokenthreadtest (inbox unread)"
882 printf " Adding parent message...\t\t\t"
883 generate_message [body]=foo [id]=parent-id [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
884 output=$(NOTMUCH_NEW)
885 pass_if_equal "$output" "Added 1 new message to the database."
886 printf " Searching returns all three messages in one thread..."
887 output=$($NOTMUCH search foo | notmuch_search_sanitize)
888 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
890 printf "\nTesting author reordering;\n"
891 printf " Adding parent message...\t\t\t"
892 generate_message [body]=findme [id]=new-parent-id [subject]=author-reorder-threadtest '[from]="User <user@example.com>"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
893 output=$(NOTMUCH_NEW)
894 pass_if_equal "$output" "Added 1 new message to the database."
895 printf " Adding initial child message...\t\t"
896 generate_message [body]=findme '[in-reply-to]=\<new-parent-id\>' [subject]=author-reorder-threadtest '[from]="User1 <user1@example.com>"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
897 output=$(NOTMUCH_NEW)
898 pass_if_equal "$output" "Added 1 new message to the database."
899 printf " Adding second child message...\t\t\t"
900 generate_message [body]=findme '[in-reply-to]=\<new-parent-id\>' [subject]=author-reorder-threadtest '[from]="User2 <user2@example.com>"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
901 output=$(NOTMUCH_NEW)
902 pass_if_equal "$output" "Added 1 new message to the database."
903 printf " Searching when all three messages match...\t"
904 output=$($NOTMUCH search findme | notmuch_search_sanitize)
905 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] User, User1, User2; author-reorder-threadtest (inbox unread)"
906 printf " Searching when two messages match...\t\t"
907 output=$($NOTMUCH search User1 or User2 | notmuch_search_sanitize)
908 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/3] User1, User2| User; author-reorder-threadtest (inbox unread)"
909 printf " Searching when only one message matches...\t"
910 output=$($NOTMUCH search User2 | notmuch_search_sanitize)
911 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/3] User2| User, User1; author-reorder-threadtest (inbox unread)"
912 printf " Searching when only first message matches...\t"
913 output=$($NOTMUCH search User | notmuch_search_sanitize)
914 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/3] User| User1, User2; author-reorder-threadtest (inbox unread)"
916 printf "\nTesting From line heuristics (with multiple configured addresses):\n"
917 printf " Magic from guessing (nothing to go on)...\t"
918 add_message '[from]="Sender <sender@example.com>"' \
919 [to]=mailinglist@notmuchmail.org \
920 [subject]=notmuch-reply-test \
921 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
922 '[body]="from guessing test"'
924 output=$($NOTMUCH reply id:${gen_msg_id})
925 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
926 Subject: Re: notmuch-reply-test
927 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
928 Bcc: test_suite@notmuchmail.org
929 In-Reply-To: <${gen_msg_id}>
930 References: <${gen_msg_id}>
932 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
933 > from guessing test"
935 printf " Magic from guessing (Envelope-to:)...\t\t"
936 add_message '[from]="Sender <sender@example.com>"' \
937 [to]=mailinglist@notmuchmail.org \
938 [subject]=notmuch-reply-test \
939 '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
940 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
941 '[body]="from guessing test"'
943 output=$($NOTMUCH reply id:${gen_msg_id})
944 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
945 Subject: Re: notmuch-reply-test
946 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
947 Bcc: test_suite@notmuchmail.org
948 In-Reply-To: <${gen_msg_id}>
949 References: <${gen_msg_id}>
951 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
952 > from guessing test"
954 printf " Magic from guessing (X-Original-To:)...\t"
955 add_message '[from]="Sender <sender@example.com>"' \
956 [to]=mailinglist@notmuchmail.org \
957 [subject]=notmuch-reply-test \
958 '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
959 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
960 '[body]="from guessing test"'
962 output=$($NOTMUCH reply id:${gen_msg_id})
963 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
964 Subject: Re: notmuch-reply-test
965 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
966 Bcc: test_suite@notmuchmail.org
967 In-Reply-To: <${gen_msg_id}>
968 References: <${gen_msg_id}>
970 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
971 > from guessing test"
973 printf " Magic from guessing (Received: .. for ..)...\t"
974 add_message '[from]="Sender <sender@example.com>"' \
975 [to]=mailinglist@notmuchmail.org \
976 [subject]=notmuch-reply-test \
977 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
978 by mail.notmuchmail.org (some MTA) with ESMTP id 12345678\
979 for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
980 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
981 '[body]="from guessing test"'
983 output=$($NOTMUCH reply id:${gen_msg_id})
984 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
985 Subject: Re: notmuch-reply-test
986 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
987 Bcc: test_suite@notmuchmail.org
988 In-Reply-To: <${gen_msg_id}>
989 References: <${gen_msg_id}>
991 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
992 > from guessing test"
994 printf " Magic from guessing (Received: domain)...\t"
995 add_message '[from]="Sender <sender@example.com>"' \
996 [to]=mailinglist@notmuchmail.org \
997 [subject]=notmuch-reply-test \
998 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
999 by mail.otherdomain.org (some MTA) with ESMTP id 12345678\
1000 Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1001 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1002 '[body]="from guessing test"'
1004 output=$($NOTMUCH reply id:${gen_msg_id})
1005 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
1006 Subject: Re: notmuch-reply-test
1007 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1008 Bcc: test_suite@notmuchmail.org
1009 In-Reply-To: <${gen_msg_id}>
1010 References: <${gen_msg_id}>
1012 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1013 > from guessing test"
1016 printf "\nTesting From line heuristics (with single configured address):\n"
1017 sed -i -e 's/^other_email.*//' ${NOTMUCH_CONFIG}
1019 printf " Magic from guessing (nothing to go on)...\t"
1020 add_message '[from]="Sender <sender@example.com>"' \
1021 [to]=mailinglist@notmuchmail.org \
1022 [subject]=notmuch-reply-test \
1023 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1024 '[body]="from guessing test"'
1026 output=$($NOTMUCH reply id:${gen_msg_id})
1027 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1028 Subject: Re: notmuch-reply-test
1029 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1030 Bcc: test_suite@notmuchmail.org
1031 In-Reply-To: <${gen_msg_id}>
1032 References: <${gen_msg_id}>
1034 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1035 > from guessing test"
1037 printf " Magic from guessing (Envelope-to:)...\t\t"
1038 add_message '[from]="Sender <sender@example.com>"' \
1039 [to]=mailinglist@notmuchmail.org \
1040 [subject]=notmuch-reply-test \
1041 '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
1042 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1043 '[body]="from guessing test"'
1045 output=$($NOTMUCH reply id:${gen_msg_id})
1046 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1047 Subject: Re: notmuch-reply-test
1048 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1049 Bcc: test_suite@notmuchmail.org
1050 In-Reply-To: <${gen_msg_id}>
1051 References: <${gen_msg_id}>
1053 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1054 > from guessing test"
1056 printf " Magic from guessing (X-Original-To:)...\t"
1057 add_message '[from]="Sender <sender@example.com>"' \
1058 [to]=mailinglist@notmuchmail.org \
1059 [subject]=notmuch-reply-test \
1060 '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
1061 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1062 '[body]="from guessing test"'
1064 output=$($NOTMUCH reply id:${gen_msg_id})
1065 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1066 Subject: Re: notmuch-reply-test
1067 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1068 Bcc: test_suite@notmuchmail.org
1069 In-Reply-To: <${gen_msg_id}>
1070 References: <${gen_msg_id}>
1072 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1073 > from guessing test"
1075 printf " Magic from guessing (Received: .. for ..)...\t"
1076 add_message '[from]="Sender <sender@example.com>"' \
1077 [to]=mailinglist@notmuchmail.org \
1078 [subject]=notmuch-reply-test \
1079 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
1080 by mail.notmuchmail.org (some MTA) with ESMTP id 12345678\
1081 for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1082 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1083 '[body]="from guessing test"'
1085 output=$($NOTMUCH reply id:${gen_msg_id})
1086 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1087 Subject: Re: notmuch-reply-test
1088 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1089 Bcc: test_suite@notmuchmail.org
1090 In-Reply-To: <${gen_msg_id}>
1091 References: <${gen_msg_id}>
1093 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1094 > from guessing test"
1096 printf " Magic from guessing (Received: domain)...\t"
1097 add_message '[from]="Sender <sender@example.com>"' \
1098 [to]=mailinglist@notmuchmail.org \
1099 [subject]=notmuch-reply-test \
1100 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
1101 by mail.otherdomain.org (some MTA) with ESMTP id 12345678\
1102 Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1103 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1104 '[body]="from guessing test"'
1106 output=$($NOTMUCH reply id:${gen_msg_id})
1107 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1108 Subject: Re: notmuch-reply-test
1109 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1110 Bcc: test_suite@notmuchmail.org
1111 In-Reply-To: <${gen_msg_id}>
1112 References: <${gen_msg_id}>
1114 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1115 > from guessing test"
1118 echo "Notmuch test suite complete."
1120 if [ "$test_failures" = "0" ]; then
1121 echo "All $tests tests passed."
1124 echo "$test_failures/$tests tests failed. The failures can be investigated in:"