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 # [references]=<message-id>
70 # '[header]=full header line, including keyword'
72 # Additional values for email headers. If these are not provided
73 # then the relevant headers will simply not appear in the
78 # Controls the message-id of the created message.
84 # This is our (bash-specific) magic for doing named parameters
85 local -A template="($@)"
86 local additional_headers
88 gen_msg_cnt=$((gen_msg_cnt + 1))
89 gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
91 if [ -z "${template[id]}" ]; then
92 gen_msg_id="${gen_msg_name}@notmuch-test-suite"
94 gen_msg_id="${template[id]}"
97 if [ -z "${template[dir]}" ]; then
98 gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
100 gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
101 mkdir -p $(dirname $gen_msg_filename)
104 if [ -z "${template[body]}" ]; then
105 template[body]="This is just a test message (#${gen_msg_cnt})"
108 if [ -z "${template[from]}" ]; then
109 template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"
112 if [ -z "${template[to]}" ]; then
113 template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"
116 if [ -z "${template[subject]}" ]; then
117 template[subject]="Test message #${gen_msg_cnt}"
120 if [ -z "${template[date]}" ]; then
121 template[date]="Tue, 05 Jan 2001 15:43:57 -0800"
124 additional_headers=""
125 if [ ! -z "${template[header]}" ]; then
126 additional_headers="${template[header]}
127 ${additional_headers}"
130 if [ ! -z "${template[reply-to]}" ]; then
131 additional_headers="Reply-To: ${template[reply-to]}
132 ${additional_headers}"
135 if [ ! -z "${template[in-reply-to]}" ]; then
136 additional_headers="In-Reply-To: ${template[in-reply-to]}
137 ${additional_headers}"
140 if [ ! -z "${template[cc]}" ]; then
141 additional_headers="Cc: ${template[cc]}
142 ${additional_headers}"
145 if [ ! -z "${template[references]}" ]; then
146 additional_headers="References: ${template[references]}
147 ${additional_headers}"
151 cat <<EOF >$gen_msg_filename
152 From: ${template[from]}
154 Message-Id: <${gen_msg_id}>
155 Subject: ${template[subject]}
156 Date: ${template[date]}
157 ${additional_headers}
161 # Ensure that the mtime of the containing directory is updated
162 increment_mtime $(dirname ${gen_msg_filename})
165 # Generate a new message and add it to the index.
167 # All of the arguments and return values supported by generate_message
168 # are also supported here, so see that function for details.
171 generate_message "$@"
173 $NOTMUCH new > /dev/null
186 if [ "$output" = "$expected" ]; then
190 testname=test-$(printf "%03d" $tests)
191 echo "$expected" > $testname.expected
192 echo "$output" > $testname.output
193 diff -u $testname.expected $testname.output || true
194 test_failures=$((test_failures + 1))
198 TEST_DIR=$(pwd)/test.$$
199 MAIL_DIR=${TEST_DIR}/mail
200 export NOTMUCH_CONFIG=${TEST_DIR}/notmuch-config
201 NOTMUCH=$(find_notmuch_binary $(pwd))
205 $NOTMUCH new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
208 notmuch_search_sanitize ()
210 sed -r -e 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
213 NOTMUCH_SHOW_FILENAME_SQUELCH='s,filename:.*/mail,filename:/XXX/mail,'
214 notmuch_show_sanitize ()
216 sed -e "$NOTMUCH_SHOW_FILENAME_SQUELCH"
225 cat <<EOF > ${NOTMUCH_CONFIG}
230 name=Notmuch Test Suite
231 primary_email=test_suite@notmuchmail.org
232 other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
235 printf "Testing \"notmuch new\" in several variations:\n"
236 printf " No new messages...\t\t\t\t"
237 output=$(NOTMUCH_NEW)
238 pass_if_equal "$output" "No new mail."
240 printf " Single new message...\t\t\t\t"
242 output=$(NOTMUCH_NEW)
243 pass_if_equal "$output" "Added 1 new message to the database."
245 printf " Multiple new messages...\t\t\t"
248 output=$(NOTMUCH_NEW)
249 pass_if_equal "$output" "Added 2 new messages to the database."
251 printf " No new messages (non-empty DB)...\t\t"
252 output=$(NOTMUCH_NEW)
253 pass_if_equal "$output" "No new mail."
255 printf " New directories...\t\t\t\t"
256 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
257 mkdir ${MAIL_DIR}/def
258 mkdir ${MAIL_DIR}/ghi
259 generate_message [dir]=def
261 output=$(NOTMUCH_NEW)
262 pass_if_equal "$output" "Added 1 new message to the database."
264 printf " Alternate inode order...\t\t\t"
266 rm -rf ${MAIL_DIR}/.notmuch
267 mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc
269 generate_message [dir]=abc
271 output=$(NOTMUCH_NEW)
272 pass_if_equal "$output" "Added 1 new message to the database."
274 printf " Message moved in...\t\t\t\t"
275 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
277 tmp_msg_filename=tmp/$gen_msg_filename
278 mkdir -p $(dirname $tmp_msg_filename)
279 mv $gen_msg_filename $tmp_msg_filename
280 increment_mtime ${MAIL_DIR}
281 $NOTMUCH new > /dev/null
282 mv $tmp_msg_filename $gen_msg_filename
283 increment_mtime ${MAIL_DIR}
284 output=$(NOTMUCH_NEW)
285 pass_if_equal "$output" "Added 1 new message to the database."
287 printf " Renamed message...\t\t\t\t"
290 $NOTMUCH new > /dev/null
291 mv $gen_msg_filename ${gen_msg_filename}-renamed
292 increment_mtime ${MAIL_DIR}
293 output=$(NOTMUCH_NEW)
294 pass_if_equal "$output" "No new mail. Detected 1 file rename."
296 printf " Deleted message...\t\t\t\t"
298 rm ${gen_msg_filename}-renamed
299 increment_mtime ${MAIL_DIR}
300 output=$(NOTMUCH_NEW)
301 pass_if_equal "$output" "No new mail. Removed 1 message."
303 printf " Renamed directory...\t\t\t\t"
305 generate_message [dir]=dir
306 generate_message [dir]=dir
307 generate_message [dir]=dir
309 $NOTMUCH new > /dev/null
311 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
312 increment_mtime ${MAIL_DIR}
314 output=$(NOTMUCH_NEW)
315 pass_if_equal "$output" "No new mail. Detected 3 file renames."
317 printf " Deleted directory...\t\t\t\t"
319 rm -rf ${MAIL_DIR}/dir-renamed
320 increment_mtime ${MAIL_DIR}
322 output=$(NOTMUCH_NEW)
323 pass_if_equal "$output" "No new mail. Removed 3 messages."
325 printf " New directory (at end of list)...\t\t"
327 generate_message [dir]=zzz
328 generate_message [dir]=zzz
329 generate_message [dir]=zzz
331 output=$(NOTMUCH_NEW)
332 pass_if_equal "$output" "Added 3 new messages to the database."
334 printf " Deleted directory (end of list)...\t\t"
336 rm -rf ${MAIL_DIR}/zzz
337 increment_mtime ${MAIL_DIR}
339 output=$(NOTMUCH_NEW)
340 pass_if_equal "$output" "No new mail. Removed 3 messages."
342 printf " New symlink to directory...\t\t\t"
344 rm -rf ${MAIL_DIR}/.notmuch
345 mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir
348 ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink
350 output=$(NOTMUCH_NEW)
351 pass_if_equal "$output" "Added 1 new message to the database."
353 printf " New symlink to a file...\t\t\t"
355 external_msg_filename=${TEST_DIR}/external/$(basename $gen_msg_filename)
356 mkdir -p $(dirname $external_msg_filename)
357 mv $gen_msg_filename $external_msg_filename
358 ln -s $external_msg_filename $gen_msg_filename
359 increment_mtime ${MAIL_DIR}
360 output=$(NOTMUCH_NEW)
361 pass_if_equal "$output" "Added 1 new message to the database."
363 printf " New two-level directory...\t\t\t"
365 generate_message [dir]=two/levels
366 generate_message [dir]=two/levels
367 generate_message [dir]=two/levels
369 output=$(NOTMUCH_NEW)
370 pass_if_equal "$output" "Added 3 new messages to the database."
372 printf " Deleted two-level directory...\t\t\t"
374 rm -rf ${MAIL_DIR}/two
375 increment_mtime ${MAIL_DIR}
377 output=$(NOTMUCH_NEW)
378 pass_if_equal "$output" "No new mail. Removed 3 messages."
380 printf "\nTesting \"notmuch search\" in several variations:\n"
382 printf " Search body...\t\t\t\t\t"
383 add_message '[subject]="body search"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [body]=bodysearchtest
384 output=$($NOTMUCH search bodysearchtest | notmuch_search_sanitize)
385 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)"
387 printf " Search by from:...\t\t\t\t"
388 add_message '[subject]="search by from"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom
389 output=$($NOTMUCH search from:searchbyfrom | notmuch_search_sanitize)
390 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)"
392 printf " Search by to:...\t\t\t\t"
393 add_message '[subject]="search by to"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto
394 output=$($NOTMUCH search to:searchbyto | notmuch_search_sanitize)
395 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)"
397 printf " Search by subject:...\t\t\t\t"
398 add_message [subject]=subjectsearchtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
399 output=$($NOTMUCH search subject:subjectsearchtest | notmuch_search_sanitize)
400 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)"
402 printf " Search by id:...\t\t\t\t"
403 add_message '[subject]="search by id"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
404 output=$($NOTMUCH search id:${gen_msg_id} | notmuch_search_sanitize)
405 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)"
407 printf " Search by tag:...\t\t\t\t"
408 add_message '[subject]="search by tag"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
409 $NOTMUCH tag +searchbytag id:${gen_msg_id}
410 output=$($NOTMUCH search tag:searchbytag | notmuch_search_sanitize)
411 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)"
413 printf " Search by thread:...\t\t\t\t"
414 add_message '[subject]="search by thread"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
415 thread_id=$($NOTMUCH search id:${gen_msg_id} | sed -e 's/thread:\([a-f0-9]*\).*/\1/')
416 output=$($NOTMUCH search thread:${thread_id} | notmuch_search_sanitize)
417 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)"
419 printf " Search body (phrase)...\t\t\t"
420 add_message '[subject]="body search (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="body search (phrase)"'
421 add_message '[subject]="negative result"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="This phrase should not match the body search"'
422 output=$($NOTMUCH search '\"body search (phrase)\"' | notmuch_search_sanitize)
423 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)"
425 printf " Search by from: (address)...\t\t\t"
426 add_message '[subject]="search by from (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom@example.com
427 output=$($NOTMUCH search from:searchbyfrom@example.com | notmuch_search_sanitize)
428 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)"
430 printf " Search by from: (name)...\t\t\t"
431 add_message '[subject]="search by from (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]="Search By From Name <test@example.com>"'
432 output=$($NOTMUCH search from:'Search By From Name' | notmuch_search_sanitize)
433 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"
435 printf " Search by to: (address)...\t\t\t"
436 add_message '[subject]="search by to (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto@example.com
437 output=$($NOTMUCH search to:searchbyto@example.com | notmuch_search_sanitize)
438 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)"
440 printf " Search by to: (name)...\t\t\t"
441 add_message '[subject]="search by to (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[to]="Search By To Name <test@example.com>"'
442 output=$($NOTMUCH search to:'Search By To Name' | notmuch_search_sanitize)
443 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"
445 printf " Search by subject: (phrase)...\t\t\t"
446 add_message '[subject]="subject search test (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
447 add_message '[subject]="this phrase should not match the subject search test"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
448 output=$($NOTMUCH search 'subject:\"subject search test (phrase)\"' | notmuch_search_sanitize)
449 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)"
451 printf " Search for all messages (\"*\"):...\t\t"
452 output=$($NOTMUCH search '*' | notmuch_search_sanitize)
453 pass_if_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #6 (inbox unread)
454 thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #14 (inbox unread)
455 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)
456 thread:XXX 2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)
457 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)
458 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)
459 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)
460 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)
461 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)
462 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)
463 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; negative result (inbox unread)
464 thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)
465 thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)
466 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)
467 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)
468 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)
469 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match the subject search test (inbox unread)"
471 printf " Search body (utf-8):...\t\t\t"
472 add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="message body utf8: bödý"'
473 output=$($NOTMUCH search 'bödý' | notmuch_search_sanitize)
474 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)"
476 printf "\nTesting --format=json output:\n"
478 printf " Show message: json...\t\t\t\t"
479 add_message '[subject]="json-show-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="json-show-message"'
480 output=$($NOTMUCH show --format=json 'json-show-message')
481 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"}]}, []]]]'
483 printf " Search message: json...\t\t\t"
484 add_message '[subject]="json-search-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="json-search-message"'
485 output=$($NOTMUCH search --format=json 'json-search-message' | notmuch_search_sanitize)
486 pass_if_equal "$output" '[{"thread": "XXX",
487 "timestamp": 946728000,
490 "authors": "Notmuch Test Suite",
491 "subject": "json-search-subject",
492 "tags": ["inbox", "unread"]}]'
494 printf " Search by subject (utf-8):...\t\t\t"
495 add_message [subject]=utf8-sübjéct '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
496 output=$($NOTMUCH search subject:utf8-sübjéct | notmuch_search_sanitize)
497 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-sübjéct (inbox unread)"
499 printf " Show message: json, utf-8...\t\t\t"
500 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"'
501 output=$($NOTMUCH show --format=json 'jsön-show-méssage')
502 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"}]}, []]]]'
504 printf " Search message: json, utf-8...\t\t\t"
505 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"'
506 output=$($NOTMUCH search --format=json 'jsön-search-méssage' | notmuch_search_sanitize)
507 pass_if_equal "$output" '[{"thread": "XXX",
508 "timestamp": 946728000,
511 "authors": "Notmuch Test Suite",
512 "subject": "json-search-utf8-body-sübjéct",
513 "tags": ["inbox", "unread"]}]'
515 printf "\nTesting naming of threads with changing subject:\n"
516 add_message '[subject]="thread-naming: Initial thread subject"' \
517 '[date]="Fri, 05 Jan 2001 15:43:56 -0800"'
520 add_message '[subject]="thread-naming: Older changed subject"' \
521 '[date]="Sat, 06 Jan 2001 15:43:56 -0800"' \
522 "[in-reply-to]=\<$parent\>"
523 add_message '[subject]="thread-naming: Newer changed subject"' \
524 '[date]="Sun, 07 Jan 2001 15:43:56 -0800"' \
525 "[in-reply-to]=\<$parent\>"
526 add_message '[subject]="thread-naming: Final thread subject"' \
527 '[date]="Mon, 08 Jan 2001 15:43:56 -0800"' \
528 "[in-reply-to]=\<$parent\>"
531 printf " Initial thread name (oldest-first search)...\t"
532 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
533 pass_if_equal "$output" "thread:XXX 2001-01-05 [4/4] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
535 printf " Initial thread name (newest-first search)...\t"
536 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
537 pass_if_equal "$output" "thread:XXX 2001-01-08 [4/4] Notmuch Test Suite; thread-naming: Final thread subject (inbox unread)"
539 # Remove oldest and newest messages from search results
540 $NOTMUCH tag -inbox id:$parent or id:$final
542 printf " Changed thread name (oldest-first search)...\t"
543 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
544 pass_if_equal "$output" "thread:XXX 2001-01-06 [2/4] Notmuch Test Suite; thread-naming: Older changed subject (inbox unread)"
546 printf " Changed thread name (newest-first search)...\t"
547 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
548 pass_if_equal "$output" "thread:XXX 2001-01-07 [2/4] Notmuch Test Suite; thread-naming: Newer changed subject (inbox unread)"
550 printf " Ignore added reply prefix (Re:)...\t\t"
551 add_message '[subject]="Re: thread-naming: Initial thread subject"' \
552 '[date]="Tue, 09 Jan 2001 15:43:45 -0800"' \
553 "[in-reply-to]=\<$parent\>"
554 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
555 pass_if_equal "$output" "thread:XXX 2001-01-09 [3/5] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
557 printf " Ignore added reply prefix (Aw:)...\t\t"
558 add_message '[subject]="Aw: thread-naming: Initial thread subject"' \
559 '[date]="Wed, 10 Jan 2001 15:43:45 -0800"' \
560 "[in-reply-to]=\<$parent\>"
561 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
562 pass_if_equal "$output" "thread:XXX 2001-01-10 [4/6] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
564 printf " Ignore added reply prefix (Vs:)...\t\t"
565 add_message '[subject]="Vs: thread-naming: Initial thread subject"' \
566 '[date]="Thu, 11 Jan 2001 15:43:45 -0800"' \
567 "[in-reply-to]=\<$parent\>"
568 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
569 pass_if_equal "$output" "thread:XXX 2001-01-11 [5/7] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
571 printf " Ignore added reply prefix (Sv:)...\t\t"
572 add_message '[subject]="Sv: thread-naming: Initial thread subject"' \
573 '[date]="Fri, 12 Jan 2001 15:43:45 -0800"' \
574 "[in-reply-to]=\<$parent\>"
575 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
576 pass_if_equal "$output" "thread:XXX 2001-01-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
578 printf " Test order of messages in \"notmuch show\"\t"
579 output=$($NOTMUCH show thread-naming | notmuch_show_sanitize)
580 pass_if_equal "$output" "
\fmessage{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-$(printf "%03d" $first)
582 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
583 Subject: thread-naming: Initial thread subject
584 From: Notmuch Test Suite <test_suite@notmuchmail.org>
585 To: Notmuch Test Suite <test_suite@notmuchmail.org>
586 Date: Fri, 05 Jan 2001 15:43:56 -0800
589 \fpart{ ID: 1, Content-type: text/plain
590 This is just a test message (#$first)
594 \fmessage{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1)))
596 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
597 Subject: thread-naming: Older changed subject
598 From: Notmuch Test Suite <test_suite@notmuchmail.org>
599 To: Notmuch Test Suite <test_suite@notmuchmail.org>
600 Date: Sat, 06 Jan 2001 15:43:56 -0800
603 \fpart{ ID: 1, Content-type: text/plain
604 This is just a test message (#$((first + 1)))
608 \fmessage{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2)))
610 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
611 Subject: thread-naming: Newer changed subject
612 From: Notmuch Test Suite <test_suite@notmuchmail.org>
613 To: Notmuch Test Suite <test_suite@notmuchmail.org>
614 Date: Sun, 07 Jan 2001 15:43:56 -0800
617 \fpart{ ID: 1, Content-type: text/plain
618 This is just a test message (#$((first + 2)))
622 \fmessage{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3)))
624 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
625 Subject: thread-naming: Final thread subject
626 From: Notmuch Test Suite <test_suite@notmuchmail.org>
627 To: Notmuch Test Suite <test_suite@notmuchmail.org>
628 Date: Mon, 08 Jan 2001 15:43:56 -0800
631 \fpart{ ID: 1, Content-type: text/plain
632 This is just a test message (#$((first + 3)))
636 \fmessage{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4)))
638 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
639 Subject: Re: thread-naming: Initial thread subject
640 From: Notmuch Test Suite <test_suite@notmuchmail.org>
641 To: Notmuch Test Suite <test_suite@notmuchmail.org>
642 Date: Tue, 09 Jan 2001 15:43:45 -0800
645 \fpart{ ID: 1, Content-type: text/plain
646 This is just a test message (#$((first + 4)))
650 \fmessage{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5)))
652 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
653 Subject: Aw: thread-naming: Initial thread subject
654 From: Notmuch Test Suite <test_suite@notmuchmail.org>
655 To: Notmuch Test Suite <test_suite@notmuchmail.org>
656 Date: Wed, 10 Jan 2001 15:43:45 -0800
659 \fpart{ ID: 1, Content-type: text/plain
660 This is just a test message (#$((first + 5)))
664 \fmessage{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6)))
666 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
667 Subject: Vs: thread-naming: Initial thread subject
668 From: Notmuch Test Suite <test_suite@notmuchmail.org>
669 To: Notmuch Test Suite <test_suite@notmuchmail.org>
670 Date: Thu, 11 Jan 2001 15:43:45 -0800
673 \fpart{ ID: 1, Content-type: text/plain
674 This is just a test message (#$((first + 6)))
678 \fmessage{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7)))
680 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
681 Subject: Sv: thread-naming: Initial thread subject
682 From: Notmuch Test Suite <test_suite@notmuchmail.org>
683 To: Notmuch Test Suite <test_suite@notmuchmail.org>
684 Date: Fri, 12 Jan 2001 15:43:45 -0800
687 \fpart{ ID: 1, Content-type: text/plain
688 This is just a test message (#$((first + 7)))
693 printf "\nTesting \"notmuch reply\" in several variations:\n"
695 printf " Basic reply...\t\t\t\t\t"
696 add_message '[from]="Sender <sender@example.com>"' \
697 [to]=test_suite@notmuchmail.org \
698 [subject]=notmuch-reply-test \
699 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
700 '[body]="basic reply test"'
702 output=$($NOTMUCH reply id:${gen_msg_id})
703 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
704 Subject: Re: notmuch-reply-test
705 To: Sender <sender@example.com>
706 Bcc: test_suite@notmuchmail.org
707 In-Reply-To: <${gen_msg_id}>
708 References: <${gen_msg_id}>
710 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
713 printf " Multiple recipients...\t\t\t\t"
714 add_message '[from]="Sender <sender@example.com>"' \
715 '[to]="test_suite@notmuchmail.org, Someone Else <someone@example.com>"' \
716 [subject]=notmuch-reply-test \
717 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
718 '[body]="Multiple recipients"'
720 output=$($NOTMUCH reply id:${gen_msg_id})
721 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
722 Subject: Re: notmuch-reply-test
723 To: Sender <sender@example.com>, Someone Else <someone@example.com>
724 Bcc: test_suite@notmuchmail.org
725 In-Reply-To: <${gen_msg_id}>
726 References: <${gen_msg_id}>
728 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
729 > Multiple recipients"
731 printf " Reply with CC...\t\t\t\t"
732 add_message '[from]="Sender <sender@example.com>"' \
733 [to]=test_suite@notmuchmail.org \
734 '[cc]="Other Parties <cc@example.com>"' \
735 [subject]=notmuch-reply-test \
736 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
737 '[body]="reply with CC"'
739 output=$($NOTMUCH reply id:${gen_msg_id})
740 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
741 Subject: Re: notmuch-reply-test
742 To: Sender <sender@example.com>
743 Cc: Other Parties <cc@example.com>
744 Bcc: test_suite@notmuchmail.org
745 In-Reply-To: <${gen_msg_id}>
746 References: <${gen_msg_id}>
748 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
751 printf " Reply from alternate address...\t\t"
752 add_message '[from]="Sender <sender@example.com>"' \
753 [to]=test_suite_other@notmuchmail.org \
754 [subject]=notmuch-reply-test \
755 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
756 '[body]="reply from alternate address"'
758 output=$($NOTMUCH reply id:${gen_msg_id})
759 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
760 Subject: Re: notmuch-reply-test
761 To: Sender <sender@example.com>
762 Bcc: test_suite@notmuchmail.org
763 In-Reply-To: <${gen_msg_id}>
764 References: <${gen_msg_id}>
766 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
767 > reply from alternate address"
769 printf " Support for Reply-To...\t\t\t"
770 add_message '[from]="Sender <sender@example.com>"' \
771 [to]=test_suite@notmuchmail.org \
772 [subject]=notmuch-reply-test \
773 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
774 '[body]="support for reply-to"' \
775 '[reply-to]="Sender <elsewhere@example.com>"'
777 output=$($NOTMUCH reply id:${gen_msg_id})
778 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
779 Subject: Re: notmuch-reply-test
780 To: Sender <elsewhere@example.com>
781 Bcc: test_suite@notmuchmail.org
782 In-Reply-To: <${gen_msg_id}>
783 References: <${gen_msg_id}>
785 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
786 > support for reply-to"
788 printf " Un-munging Reply-To...\t\t\t\t"
789 add_message '[from]="Sender <sender@example.com>"' \
790 '[to]="Some List <list@example.com>"' \
791 [subject]=notmuch-reply-test \
792 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
793 '[body]="Un-munging Reply-To"' \
794 '[reply-to]="Evil Munging List <list@example.com>"'
796 output=$($NOTMUCH reply id:${gen_msg_id})
797 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
798 Subject: Re: notmuch-reply-test
799 To: Sender <sender@example.com>, Some List <list@example.com>
800 Bcc: test_suite@notmuchmail.org
801 In-Reply-To: <${gen_msg_id}>
802 References: <${gen_msg_id}>
804 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
805 > Un-munging Reply-To"
807 printf " Message with header of exactly 200 bytes...\t"
809 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"' \
810 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
811 '[body]="200-byte header"'
813 output=$($NOTMUCH reply id:${gen_msg_id})
814 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
815 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
816 Bcc: test_suite@notmuchmail.org
817 In-Reply-To: <${gen_msg_id}>
818 References: <${gen_msg_id}>
820 On Tue, 05 Jan 2010 15:43:56 -0800, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
823 printf "\nTesting handling of uuencoded data:\n"
825 add_message [subject]=uuencodetest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
826 '[body]="This message is used to ensure that notmuch correctly handles a
827 message containing a block of uuencoded data. First, we have a marker
828 this content beforeuudata . Then we beging the uunencoded data itself:
830 begin 644 bogus-uuencoded-data
831 M0123456789012345678901234567890123456789012345678901234567890
832 MOBVIOUSLY, THIS IS NOT ANY SORT OF USEFUL UUNECODED DATA.
833 MINSTEAD THIS IS JUST A WAY TO ENSURE THAT THIS BLOCK OF DATA
834 MIS CORRECTLY IGNORED WHEN NOTMUCH CREATES ITS INDEX. SO WE
835 MINCLUDE A DURINGUUDATA MARKER THAT SHOULD NOT RESULT IN ANY
840 Finally, we have our afteruudata marker as well."'
842 printf " Ensure content before uu data is indexed...\t"
843 output=$($NOTMUCH search beforeuudata | notmuch_search_sanitize)
844 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
845 printf " Ensure uu data is not indexed...\t\t"
846 output=$($NOTMUCH search DURINGUUDATA | notmuch_search_sanitize)
847 pass_if_equal "$output" ""
848 printf " Ensure content after uu data is indexed...\t"
849 output=$($NOTMUCH search afteruudata | notmuch_search_sanitize)
850 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
852 printf "\nTesting \"notmuch dump\" and \"notmuch restore\":\n"
854 printf " Dumping all tags...\t\t\t\t"
855 $NOTMUCH dump dump.expected
856 pass_if_equal "$?" "0"
858 printf " Clearing all tags...\t\t\t\t"
859 sed -e 's/(\([^(]*\))$/()/' < dump.expected > clear.expected
860 $NOTMUCH restore clear.expected
861 $NOTMUCH dump clear.actual
862 pass_if_equal "$(< clear.actual)" "$(< clear.expected)"
864 printf " Restoring original tags...\t\t\t"
865 $NOTMUCH restore dump.expected
866 $NOTMUCH dump dump.actual
867 pass_if_equal "$(< dump.actual)" "$(< dump.expected)"
869 printf " Restore with nothing to do...\t\t\t"
870 $NOTMUCH restore dump.expected
871 pass_if_equal "$?" "0"
873 printf "\nTesting threading when messages received out of order:\n"
874 printf " Adding initial child message...\t\t"
875 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
876 output=$(NOTMUCH_NEW)
877 pass_if_equal "$output" "Added 1 new message to the database."
878 printf " Searching returns the message...\t\t"
879 output=$($NOTMUCH search foo | notmuch_search_sanitize)
880 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; brokenthreadtest (inbox unread)"
881 printf " Adding second child message...\t\t\t"
882 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
883 output=$(NOTMUCH_NEW)
884 pass_if_equal "$output" "Added 1 new message to the database."
885 printf " Searching returns both messages in one thread..."
886 output=$($NOTMUCH search foo | notmuch_search_sanitize)
887 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/2] Notmuch Test Suite; brokenthreadtest (inbox unread)"
888 printf " Adding parent message...\t\t\t"
889 generate_message [body]=foo [id]=parent-id [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
890 output=$(NOTMUCH_NEW)
891 pass_if_equal "$output" "Added 1 new message to the database."
892 printf " Searching returns all three messages in one thread..."
893 output=$($NOTMUCH search foo | notmuch_search_sanitize)
894 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
896 printf "\nTesting author reordering;\n"
897 printf " Adding parent message...\t\t\t"
898 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"'
899 output=$(NOTMUCH_NEW)
900 pass_if_equal "$output" "Added 1 new message to the database."
901 printf " Adding initial child message...\t\t"
902 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"'
903 output=$(NOTMUCH_NEW)
904 pass_if_equal "$output" "Added 1 new message to the database."
905 printf " Adding second child message...\t\t\t"
906 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"'
907 output=$(NOTMUCH_NEW)
908 pass_if_equal "$output" "Added 1 new message to the database."
909 printf " Searching when all three messages match...\t"
910 output=$($NOTMUCH search findme | notmuch_search_sanitize)
911 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] User, User1, User2; author-reorder-threadtest (inbox unread)"
912 printf " Searching when two messages match...\t\t"
913 output=$($NOTMUCH search User1 or User2 | notmuch_search_sanitize)
914 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/3] User1, User2| User; author-reorder-threadtest (inbox unread)"
915 printf " Searching when only one message matches...\t"
916 output=$($NOTMUCH search User2 | notmuch_search_sanitize)
917 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/3] User2| User, User1; author-reorder-threadtest (inbox unread)"
918 printf " Searching when only first message matches...\t"
919 output=$($NOTMUCH search User | notmuch_search_sanitize)
920 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/3] User| User1, User2; author-reorder-threadtest (inbox unread)"
922 printf "\nTesting From line heuristics (with multiple configured addresses):\n"
923 printf " Magic from guessing (nothing to go on)...\t"
924 add_message '[from]="Sender <sender@example.com>"' \
925 [to]=mailinglist@notmuchmail.org \
926 [subject]=notmuch-reply-test \
927 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
928 '[body]="from guessing test"'
930 output=$($NOTMUCH reply id:${gen_msg_id})
931 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
932 Subject: Re: notmuch-reply-test
933 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
934 Bcc: test_suite@notmuchmail.org
935 In-Reply-To: <${gen_msg_id}>
936 References: <${gen_msg_id}>
938 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
939 > from guessing test"
941 printf " Magic from guessing (Envelope-to:)...\t\t"
942 add_message '[from]="Sender <sender@example.com>"' \
943 [to]=mailinglist@notmuchmail.org \
944 [subject]=notmuch-reply-test \
945 '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
946 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
947 '[body]="from guessing test"'
949 output=$($NOTMUCH reply id:${gen_msg_id})
950 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
951 Subject: Re: notmuch-reply-test
952 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
953 Bcc: test_suite@notmuchmail.org
954 In-Reply-To: <${gen_msg_id}>
955 References: <${gen_msg_id}>
957 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
958 > from guessing test"
960 printf " Magic from guessing (X-Original-To:)...\t"
961 add_message '[from]="Sender <sender@example.com>"' \
962 [to]=mailinglist@notmuchmail.org \
963 [subject]=notmuch-reply-test \
964 '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
965 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
966 '[body]="from guessing test"'
968 output=$($NOTMUCH reply id:${gen_msg_id})
969 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
970 Subject: Re: notmuch-reply-test
971 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
972 Bcc: test_suite@notmuchmail.org
973 In-Reply-To: <${gen_msg_id}>
974 References: <${gen_msg_id}>
976 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
977 > from guessing test"
979 printf " Magic from guessing (Received: .. for ..)...\t"
980 add_message '[from]="Sender <sender@example.com>"' \
981 [to]=mailinglist@notmuchmail.org \
982 [subject]=notmuch-reply-test \
983 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
984 by mail.notmuchmail.org (some MTA) with ESMTP id 12345678\
985 for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
986 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
987 '[body]="from guessing test"'
989 output=$($NOTMUCH reply id:${gen_msg_id})
990 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
991 Subject: Re: notmuch-reply-test
992 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
993 Bcc: test_suite@notmuchmail.org
994 In-Reply-To: <${gen_msg_id}>
995 References: <${gen_msg_id}>
997 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
998 > from guessing test"
1000 printf " Magic from guessing (Received: domain)...\t"
1001 add_message '[from]="Sender <sender@example.com>"' \
1002 [to]=mailinglist@notmuchmail.org \
1003 [subject]=notmuch-reply-test \
1004 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
1005 by mail.otherdomain.org (some MTA) with ESMTP id 12345678\
1006 Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1007 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1008 '[body]="from guessing test"'
1010 output=$($NOTMUCH reply id:${gen_msg_id})
1011 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
1012 Subject: Re: notmuch-reply-test
1013 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1014 Bcc: test_suite@notmuchmail.org
1015 In-Reply-To: <${gen_msg_id}>
1016 References: <${gen_msg_id}>
1018 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1019 > from guessing test"
1022 printf "\nTesting From line heuristics (with single configured address):\n"
1023 sed -i -e 's/^other_email.*//' ${NOTMUCH_CONFIG}
1025 printf " Magic from guessing (nothing to go on)...\t"
1026 add_message '[from]="Sender <sender@example.com>"' \
1027 [to]=mailinglist@notmuchmail.org \
1028 [subject]=notmuch-reply-test \
1029 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1030 '[body]="from guessing test"'
1032 output=$($NOTMUCH reply id:${gen_msg_id})
1033 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1034 Subject: Re: notmuch-reply-test
1035 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1036 Bcc: test_suite@notmuchmail.org
1037 In-Reply-To: <${gen_msg_id}>
1038 References: <${gen_msg_id}>
1040 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1041 > from guessing test"
1043 printf " Magic from guessing (Envelope-to:)...\t\t"
1044 add_message '[from]="Sender <sender@example.com>"' \
1045 [to]=mailinglist@notmuchmail.org \
1046 [subject]=notmuch-reply-test \
1047 '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
1048 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1049 '[body]="from guessing test"'
1051 output=$($NOTMUCH reply id:${gen_msg_id})
1052 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1053 Subject: Re: notmuch-reply-test
1054 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1055 Bcc: test_suite@notmuchmail.org
1056 In-Reply-To: <${gen_msg_id}>
1057 References: <${gen_msg_id}>
1059 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1060 > from guessing test"
1062 printf " Magic from guessing (X-Original-To:)...\t"
1063 add_message '[from]="Sender <sender@example.com>"' \
1064 [to]=mailinglist@notmuchmail.org \
1065 [subject]=notmuch-reply-test \
1066 '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
1067 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1068 '[body]="from guessing test"'
1070 output=$($NOTMUCH reply id:${gen_msg_id})
1071 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1072 Subject: Re: notmuch-reply-test
1073 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1074 Bcc: test_suite@notmuchmail.org
1075 In-Reply-To: <${gen_msg_id}>
1076 References: <${gen_msg_id}>
1078 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1079 > from guessing test"
1081 printf " Magic from guessing (Received: .. for ..)...\t"
1082 add_message '[from]="Sender <sender@example.com>"' \
1083 [to]=mailinglist@notmuchmail.org \
1084 [subject]=notmuch-reply-test \
1085 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
1086 by mail.notmuchmail.org (some MTA) with ESMTP id 12345678\
1087 for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1088 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1089 '[body]="from guessing test"'
1091 output=$($NOTMUCH reply id:${gen_msg_id})
1092 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1093 Subject: Re: notmuch-reply-test
1094 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1095 Bcc: test_suite@notmuchmail.org
1096 In-Reply-To: <${gen_msg_id}>
1097 References: <${gen_msg_id}>
1099 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1100 > from guessing test"
1102 printf " Magic from guessing (Received: domain)...\t"
1103 add_message '[from]="Sender <sender@example.com>"' \
1104 [to]=mailinglist@notmuchmail.org \
1105 [subject]=notmuch-reply-test \
1106 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
1107 by mail.otherdomain.org (some MTA) with ESMTP id 12345678\
1108 Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1109 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1110 '[body]="from guessing test"'
1112 output=$($NOTMUCH reply id:${gen_msg_id})
1113 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1114 Subject: Re: notmuch-reply-test
1115 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1116 Bcc: test_suite@notmuchmail.org
1117 In-Reply-To: <${gen_msg_id}>
1118 References: <${gen_msg_id}>
1120 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1121 > from guessing test"
1124 echo "Notmuch test suite complete."
1126 if [ "$test_failures" = "0" ]; then
1127 echo "All $tests tests passed."
1130 echo "$test_failures/$tests tests failed. The failures can be investigated in:"