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 # [content-type]=content-type-specification
71 # '[header]=full header line, including keyword'
73 # Additional values for email headers. If these are not provided
74 # then the relevant headers will simply not appear in the
79 # Controls the message-id of the created message.
85 # This is our (bash-specific) magic for doing named parameters
86 local -A template="($@)"
87 local additional_headers
89 gen_msg_cnt=$((gen_msg_cnt + 1))
90 gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
92 if [ -z "${template[id]}" ]; then
93 gen_msg_id="${gen_msg_name}@notmuch-test-suite"
95 gen_msg_id="${template[id]}"
98 if [ -z "${template[dir]}" ]; then
99 gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
101 gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
102 mkdir -p $(dirname $gen_msg_filename)
105 if [ -z "${template[body]}" ]; then
106 template[body]="This is just a test message (#${gen_msg_cnt})"
109 if [ -z "${template[from]}" ]; then
110 template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"
113 if [ -z "${template[to]}" ]; then
114 template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"
117 if [ -z "${template[subject]}" ]; then
118 template[subject]="Test message #${gen_msg_cnt}"
121 if [ -z "${template[date]}" ]; then
122 template[date]="Tue, 05 Jan 2001 15:43:57 -0800"
125 additional_headers=""
126 if [ ! -z "${template[header]}" ]; then
127 additional_headers="${template[header]}
128 ${additional_headers}"
131 if [ ! -z "${template[reply-to]}" ]; then
132 additional_headers="Reply-To: ${template[reply-to]}
133 ${additional_headers}"
136 if [ ! -z "${template[in-reply-to]}" ]; then
137 additional_headers="In-Reply-To: ${template[in-reply-to]}
138 ${additional_headers}"
141 if [ ! -z "${template[cc]}" ]; then
142 additional_headers="Cc: ${template[cc]}
143 ${additional_headers}"
146 if [ ! -z "${template[references]}" ]; then
147 additional_headers="References: ${template[references]}
148 ${additional_headers}"
151 if [ ! -z "${template[content-type]}" ]; then
152 additional_headers="Content-Type: ${template[content-type]}
153 ${additional_headers}"
157 cat <<EOF >$gen_msg_filename
158 From: ${template[from]}
160 Message-Id: <${gen_msg_id}>
161 Subject: ${template[subject]}
162 Date: ${template[date]}
163 ${additional_headers}
167 # Ensure that the mtime of the containing directory is updated
168 increment_mtime $(dirname ${gen_msg_filename})
171 # Generate a new message and add it to the index.
173 # All of the arguments and return values supported by generate_message
174 # are also supported here, so see that function for details.
177 generate_message "$@"
179 $NOTMUCH new > /dev/null
192 if [ "$output" = "$expected" ]; then
196 testname=test-$(printf "%03d" $tests)
197 echo "$expected" > $testname.expected
198 echo "$output" > $testname.output
199 diff -u $testname.expected $testname.output || true
200 test_failures=$((test_failures + 1))
204 TEST_DIR=$(pwd)/test.$$
205 MAIL_DIR=${TEST_DIR}/mail
206 export NOTMUCH_CONFIG=${TEST_DIR}/notmuch-config
207 NOTMUCH=$(find_notmuch_binary $(pwd))
211 $NOTMUCH new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
214 notmuch_search_sanitize ()
216 sed -r -e 's/("?thread"?: ?)("?)................("?)/\1\2XXX\3/'
219 NOTMUCH_SHOW_FILENAME_SQUELCH='s,filename:.*/mail,filename:/XXX/mail,'
220 notmuch_show_sanitize ()
222 sed -e "$NOTMUCH_SHOW_FILENAME_SQUELCH"
231 cat <<EOF > ${NOTMUCH_CONFIG}
236 name=Notmuch Test Suite
237 primary_email=test_suite@notmuchmail.org
238 other_email=test_suite_other@notmuchmail.org;test_suite@otherdomain.org
241 printf "Testing \"notmuch new\" in several variations:\n"
242 printf " No new messages...\t\t\t\t"
243 output=$(NOTMUCH_NEW)
244 pass_if_equal "$output" "No new mail."
246 printf " Single new message...\t\t\t\t"
248 output=$(NOTMUCH_NEW)
249 pass_if_equal "$output" "Added 1 new message to the database."
251 printf " Multiple new messages...\t\t\t"
254 output=$(NOTMUCH_NEW)
255 pass_if_equal "$output" "Added 2 new messages to the database."
257 printf " No new messages (non-empty DB)...\t\t"
258 output=$(NOTMUCH_NEW)
259 pass_if_equal "$output" "No new mail."
261 printf " New directories...\t\t\t\t"
262 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
263 mkdir ${MAIL_DIR}/def
264 mkdir ${MAIL_DIR}/ghi
265 generate_message [dir]=def
267 output=$(NOTMUCH_NEW)
268 pass_if_equal "$output" "Added 1 new message to the database."
270 printf " Alternate inode order...\t\t\t"
272 rm -rf ${MAIL_DIR}/.notmuch
273 mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc
275 generate_message [dir]=abc
277 output=$(NOTMUCH_NEW)
278 pass_if_equal "$output" "Added 1 new message to the database."
280 printf " Message moved in...\t\t\t\t"
281 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
283 tmp_msg_filename=tmp/$gen_msg_filename
284 mkdir -p $(dirname $tmp_msg_filename)
285 mv $gen_msg_filename $tmp_msg_filename
286 increment_mtime ${MAIL_DIR}
287 $NOTMUCH new > /dev/null
288 mv $tmp_msg_filename $gen_msg_filename
289 increment_mtime ${MAIL_DIR}
290 output=$(NOTMUCH_NEW)
291 pass_if_equal "$output" "Added 1 new message to the database."
293 printf " Renamed message...\t\t\t\t"
296 $NOTMUCH new > /dev/null
297 mv $gen_msg_filename ${gen_msg_filename}-renamed
298 increment_mtime ${MAIL_DIR}
299 output=$(NOTMUCH_NEW)
300 pass_if_equal "$output" "No new mail. Detected 1 file rename."
302 printf " Deleted message...\t\t\t\t"
304 rm ${gen_msg_filename}-renamed
305 increment_mtime ${MAIL_DIR}
306 output=$(NOTMUCH_NEW)
307 pass_if_equal "$output" "No new mail. Removed 1 message."
309 printf " Renamed directory...\t\t\t\t"
311 generate_message [dir]=dir
312 generate_message [dir]=dir
313 generate_message [dir]=dir
315 $NOTMUCH new > /dev/null
317 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
318 increment_mtime ${MAIL_DIR}
320 output=$(NOTMUCH_NEW)
321 pass_if_equal "$output" "No new mail. Detected 3 file renames."
323 printf " Deleted directory...\t\t\t\t"
325 rm -rf ${MAIL_DIR}/dir-renamed
326 increment_mtime ${MAIL_DIR}
328 output=$(NOTMUCH_NEW)
329 pass_if_equal "$output" "No new mail. Removed 3 messages."
331 printf " New directory (at end of list)...\t\t"
333 generate_message [dir]=zzz
334 generate_message [dir]=zzz
335 generate_message [dir]=zzz
337 output=$(NOTMUCH_NEW)
338 pass_if_equal "$output" "Added 3 new messages to the database."
340 printf " Deleted directory (end of list)...\t\t"
342 rm -rf ${MAIL_DIR}/zzz
343 increment_mtime ${MAIL_DIR}
345 output=$(NOTMUCH_NEW)
346 pass_if_equal "$output" "No new mail. Removed 3 messages."
348 printf " New symlink to directory...\t\t\t"
350 rm -rf ${MAIL_DIR}/.notmuch
351 mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir
354 ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink
356 output=$(NOTMUCH_NEW)
357 pass_if_equal "$output" "Added 1 new message to the database."
359 printf " New symlink to a file...\t\t\t"
361 external_msg_filename=${TEST_DIR}/external/$(basename $gen_msg_filename)
362 mkdir -p $(dirname $external_msg_filename)
363 mv $gen_msg_filename $external_msg_filename
364 ln -s $external_msg_filename $gen_msg_filename
365 increment_mtime ${MAIL_DIR}
366 output=$(NOTMUCH_NEW)
367 pass_if_equal "$output" "Added 1 new message to the database."
369 printf " New two-level directory...\t\t\t"
371 generate_message [dir]=two/levels
372 generate_message [dir]=two/levels
373 generate_message [dir]=two/levels
375 output=$(NOTMUCH_NEW)
376 pass_if_equal "$output" "Added 3 new messages to the database."
378 printf " Deleted two-level directory...\t\t\t"
380 rm -rf ${MAIL_DIR}/two
381 increment_mtime ${MAIL_DIR}
383 output=$(NOTMUCH_NEW)
384 pass_if_equal "$output" "No new mail. Removed 3 messages."
386 printf "\nTesting \"notmuch search\" in several variations:\n"
388 printf " Search body...\t\t\t\t\t"
389 add_message '[subject]="body search"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [body]=bodysearchtest
390 output=$($NOTMUCH search bodysearchtest | notmuch_search_sanitize)
391 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)"
393 printf " Search by from:...\t\t\t\t"
394 add_message '[subject]="search by from"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom
395 output=$($NOTMUCH search from:searchbyfrom | notmuch_search_sanitize)
396 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)"
398 printf " Search by to:...\t\t\t\t"
399 add_message '[subject]="search by to"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto
400 output=$($NOTMUCH search to:searchbyto | notmuch_search_sanitize)
401 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)"
403 printf " Search by subject:...\t\t\t\t"
404 add_message [subject]=subjectsearchtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
405 output=$($NOTMUCH search subject:subjectsearchtest | notmuch_search_sanitize)
406 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)"
408 printf " Search by id:...\t\t\t\t"
409 add_message '[subject]="search by id"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
410 output=$($NOTMUCH search id:${gen_msg_id} | notmuch_search_sanitize)
411 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)"
413 printf " Search by tag:...\t\t\t\t"
414 add_message '[subject]="search by tag"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
415 $NOTMUCH tag +searchbytag id:${gen_msg_id}
416 output=$($NOTMUCH search tag:searchbytag | notmuch_search_sanitize)
417 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)"
419 printf " Search by thread:...\t\t\t\t"
420 add_message '[subject]="search by thread"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
421 thread_id=$($NOTMUCH search id:${gen_msg_id} | sed -e 's/thread:\([a-f0-9]*\).*/\1/')
422 output=$($NOTMUCH search thread:${thread_id} | notmuch_search_sanitize)
423 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)"
425 printf " Search body (phrase)...\t\t\t"
426 add_message '[subject]="body search (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="body search (phrase)"'
427 add_message '[subject]="negative result"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="This phrase should not match the body search"'
428 output=$($NOTMUCH search '\"body search (phrase)\"' | notmuch_search_sanitize)
429 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)"
431 printf " Search by from: (address)...\t\t\t"
432 add_message '[subject]="search by from (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom@example.com
433 output=$($NOTMUCH search from:searchbyfrom@example.com | notmuch_search_sanitize)
434 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)"
436 printf " Search by from: (name)...\t\t\t"
437 add_message '[subject]="search by from (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]="Search By From Name <test@example.com>"'
438 output=$($NOTMUCH search from:'Search By From Name' | notmuch_search_sanitize)
439 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"
441 printf " Search by to: (address)...\t\t\t"
442 add_message '[subject]="search by to (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto@example.com
443 output=$($NOTMUCH search to:searchbyto@example.com | notmuch_search_sanitize)
444 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)"
446 printf " Search by to: (name)...\t\t\t"
447 add_message '[subject]="search by to (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[to]="Search By To Name <test@example.com>"'
448 output=$($NOTMUCH search to:'Search By To Name' | notmuch_search_sanitize)
449 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"
451 printf " Search by subject: (phrase)...\t\t\t"
452 add_message '[subject]="subject search test (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
453 add_message '[subject]="this phrase should not match the subject search test"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
454 output=$($NOTMUCH search 'subject:\"subject search test (phrase)\"' | notmuch_search_sanitize)
455 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)"
457 printf " Search for all messages (\"*\"):...\t\t"
458 output=$($NOTMUCH search '*' | notmuch_search_sanitize)
459 pass_if_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #6 (inbox unread)
460 thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #14 (inbox unread)
461 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)
462 thread:XXX 2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)
463 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)
464 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)
465 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)
466 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)
467 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)
468 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)
469 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; negative result (inbox unread)
470 thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)
471 thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)
472 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)
473 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)
474 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)
475 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match the subject search test (inbox unread)"
477 printf " Search body (utf-8):...\t\t\t"
478 add_message '[subject]="utf8-message-body-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="message body utf8: bödý"'
479 output=$($NOTMUCH search 'bödý' | notmuch_search_sanitize)
480 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-message-body-subject (inbox unread)"
482 printf "\nTesting --format=json output:\n"
484 printf " Show message: json...\t\t\t\t"
485 add_message '[subject]="json-show-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="json-show-message"'
486 output=$($NOTMUCH show --format=json 'json-show-message')
487 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"}]}, []]]]'
489 printf " Search message: json...\t\t\t"
490 add_message '[subject]="json-search-subject"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="json-search-message"'
491 output=$($NOTMUCH search --format=json 'json-search-message' | notmuch_search_sanitize)
492 pass_if_equal "$output" '[{"thread": "XXX",
493 "timestamp": 946728000,
496 "authors": "Notmuch Test Suite",
497 "subject": "json-search-subject",
498 "tags": ["inbox", "unread"]}]'
500 printf " Search by subject (utf-8):...\t\t\t"
501 add_message [subject]=utf8-sübjéct '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
502 output=$($NOTMUCH search subject:utf8-sübjéct | notmuch_search_sanitize)
503 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; utf8-sübjéct (inbox unread)"
505 printf " Show message: json, utf-8...\t\t\t"
506 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"'
507 output=$($NOTMUCH show --format=json 'jsön-show-méssage')
508 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"}]}, []]]]'
510 printf " Search message: json, utf-8...\t\t\t"
511 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"'
512 output=$($NOTMUCH search --format=json 'jsön-search-méssage' | notmuch_search_sanitize)
513 pass_if_equal "$output" '[{"thread": "XXX",
514 "timestamp": 946728000,
517 "authors": "Notmuch Test Suite",
518 "subject": "json-search-utf8-body-sübjéct",
519 "tags": ["inbox", "unread"]}]'
521 printf "\nTesting naming of threads with changing subject:\n"
522 add_message '[subject]="thread-naming: Initial thread subject"' \
523 '[date]="Fri, 05 Jan 2001 15:43:56 -0800"'
526 add_message '[subject]="thread-naming: Older changed subject"' \
527 '[date]="Sat, 06 Jan 2001 15:43:56 -0800"' \
528 "[in-reply-to]=\<$parent\>"
529 add_message '[subject]="thread-naming: Newer changed subject"' \
530 '[date]="Sun, 07 Jan 2001 15:43:56 -0800"' \
531 "[in-reply-to]=\<$parent\>"
532 add_message '[subject]="thread-naming: Final thread subject"' \
533 '[date]="Mon, 08 Jan 2001 15:43:56 -0800"' \
534 "[in-reply-to]=\<$parent\>"
537 printf " Initial thread name (oldest-first search)...\t"
538 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
539 pass_if_equal "$output" "thread:XXX 2001-01-05 [4/4] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
541 printf " Initial thread name (newest-first search)...\t"
542 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
543 pass_if_equal "$output" "thread:XXX 2001-01-08 [4/4] Notmuch Test Suite; thread-naming: Final thread subject (inbox unread)"
545 # Remove oldest and newest messages from search results
546 $NOTMUCH tag -inbox id:$parent or id:$final
548 printf " Changed thread name (oldest-first search)...\t"
549 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
550 pass_if_equal "$output" "thread:XXX 2001-01-06 [2/4] Notmuch Test Suite; thread-naming: Older changed subject (inbox unread)"
552 printf " Changed thread name (newest-first search)...\t"
553 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
554 pass_if_equal "$output" "thread:XXX 2001-01-07 [2/4] Notmuch Test Suite; thread-naming: Newer changed subject (inbox unread)"
556 printf " Ignore added reply prefix (Re:)...\t\t"
557 add_message '[subject]="Re: thread-naming: Initial thread subject"' \
558 '[date]="Tue, 09 Jan 2001 15:43:45 -0800"' \
559 "[in-reply-to]=\<$parent\>"
560 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
561 pass_if_equal "$output" "thread:XXX 2001-01-09 [3/5] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
563 printf " Ignore added reply prefix (Aw:)...\t\t"
564 add_message '[subject]="Aw: thread-naming: Initial thread subject"' \
565 '[date]="Wed, 10 Jan 2001 15:43:45 -0800"' \
566 "[in-reply-to]=\<$parent\>"
567 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
568 pass_if_equal "$output" "thread:XXX 2001-01-10 [4/6] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
570 printf " Ignore added reply prefix (Vs:)...\t\t"
571 add_message '[subject]="Vs: thread-naming: Initial thread subject"' \
572 '[date]="Thu, 11 Jan 2001 15:43:45 -0800"' \
573 "[in-reply-to]=\<$parent\>"
574 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
575 pass_if_equal "$output" "thread:XXX 2001-01-11 [5/7] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
577 printf " Ignore added reply prefix (Sv:)...\t\t"
578 add_message '[subject]="Sv: thread-naming: Initial thread subject"' \
579 '[date]="Fri, 12 Jan 2001 15:43:45 -0800"' \
580 "[in-reply-to]=\<$parent\>"
581 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
582 pass_if_equal "$output" "thread:XXX 2001-01-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
584 printf " Test order of messages in \"notmuch show\"\t"
585 output=$($NOTMUCH show thread-naming | notmuch_show_sanitize)
586 pass_if_equal "$output" "
\fmessage{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-$(printf "%03d" $first)
588 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
589 Subject: thread-naming: Initial thread subject
590 From: Notmuch Test Suite <test_suite@notmuchmail.org>
591 To: Notmuch Test Suite <test_suite@notmuchmail.org>
592 Date: Fri, 05 Jan 2001 15:43:56 -0800
595 \fpart{ ID: 1, Content-type: text/plain
596 This is just a test message (#$first)
600 \fmessage{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1)))
602 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
603 Subject: thread-naming: Older changed subject
604 From: Notmuch Test Suite <test_suite@notmuchmail.org>
605 To: Notmuch Test Suite <test_suite@notmuchmail.org>
606 Date: Sat, 06 Jan 2001 15:43:56 -0800
609 \fpart{ ID: 1, Content-type: text/plain
610 This is just a test message (#$((first + 1)))
614 \fmessage{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2)))
616 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
617 Subject: thread-naming: Newer changed subject
618 From: Notmuch Test Suite <test_suite@notmuchmail.org>
619 To: Notmuch Test Suite <test_suite@notmuchmail.org>
620 Date: Sun, 07 Jan 2001 15:43:56 -0800
623 \fpart{ ID: 1, Content-type: text/plain
624 This is just a test message (#$((first + 2)))
628 \fmessage{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3)))
630 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
631 Subject: thread-naming: Final thread subject
632 From: Notmuch Test Suite <test_suite@notmuchmail.org>
633 To: Notmuch Test Suite <test_suite@notmuchmail.org>
634 Date: Mon, 08 Jan 2001 15:43:56 -0800
637 \fpart{ ID: 1, Content-type: text/plain
638 This is just a test message (#$((first + 3)))
642 \fmessage{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4)))
644 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
645 Subject: Re: thread-naming: Initial thread subject
646 From: Notmuch Test Suite <test_suite@notmuchmail.org>
647 To: Notmuch Test Suite <test_suite@notmuchmail.org>
648 Date: Tue, 09 Jan 2001 15:43:45 -0800
651 \fpart{ ID: 1, Content-type: text/plain
652 This is just a test message (#$((first + 4)))
656 \fmessage{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5)))
658 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
659 Subject: Aw: thread-naming: Initial thread subject
660 From: Notmuch Test Suite <test_suite@notmuchmail.org>
661 To: Notmuch Test Suite <test_suite@notmuchmail.org>
662 Date: Wed, 10 Jan 2001 15:43:45 -0800
665 \fpart{ ID: 1, Content-type: text/plain
666 This is just a test message (#$((first + 5)))
670 \fmessage{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6)))
672 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
673 Subject: Vs: thread-naming: Initial thread subject
674 From: Notmuch Test Suite <test_suite@notmuchmail.org>
675 To: Notmuch Test Suite <test_suite@notmuchmail.org>
676 Date: Thu, 11 Jan 2001 15:43:45 -0800
679 \fpart{ ID: 1, Content-type: text/plain
680 This is just a test message (#$((first + 6)))
684 \fmessage{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7)))
686 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
687 Subject: Sv: thread-naming: Initial thread subject
688 From: Notmuch Test Suite <test_suite@notmuchmail.org>
689 To: Notmuch Test Suite <test_suite@notmuchmail.org>
690 Date: Fri, 12 Jan 2001 15:43:45 -0800
693 \fpart{ ID: 1, Content-type: text/plain
694 This is just a test message (#$((first + 7)))
699 printf "\nTesting \"notmuch reply\" in several variations:\n"
701 printf " Basic reply...\t\t\t\t\t"
702 add_message '[from]="Sender <sender@example.com>"' \
703 [to]=test_suite@notmuchmail.org \
704 [subject]=notmuch-reply-test \
705 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
706 '[body]="basic reply test"'
708 output=$($NOTMUCH reply id:${gen_msg_id})
709 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
710 Subject: Re: notmuch-reply-test
711 To: Sender <sender@example.com>
712 Bcc: test_suite@notmuchmail.org
713 In-Reply-To: <${gen_msg_id}>
714 References: <${gen_msg_id}>
716 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
719 printf " Multiple recipients...\t\t\t\t"
720 add_message '[from]="Sender <sender@example.com>"' \
721 '[to]="test_suite@notmuchmail.org, Someone Else <someone@example.com>"' \
722 [subject]=notmuch-reply-test \
723 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
724 '[body]="Multiple recipients"'
726 output=$($NOTMUCH reply id:${gen_msg_id})
727 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
728 Subject: Re: notmuch-reply-test
729 To: Sender <sender@example.com>, Someone Else <someone@example.com>
730 Bcc: test_suite@notmuchmail.org
731 In-Reply-To: <${gen_msg_id}>
732 References: <${gen_msg_id}>
734 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
735 > Multiple recipients"
737 printf " Reply with CC...\t\t\t\t"
738 add_message '[from]="Sender <sender@example.com>"' \
739 [to]=test_suite@notmuchmail.org \
740 '[cc]="Other Parties <cc@example.com>"' \
741 [subject]=notmuch-reply-test \
742 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
743 '[body]="reply with CC"'
745 output=$($NOTMUCH reply id:${gen_msg_id})
746 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
747 Subject: Re: notmuch-reply-test
748 To: Sender <sender@example.com>
749 Cc: Other Parties <cc@example.com>
750 Bcc: test_suite@notmuchmail.org
751 In-Reply-To: <${gen_msg_id}>
752 References: <${gen_msg_id}>
754 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
757 printf " Reply from alternate address...\t\t"
758 add_message '[from]="Sender <sender@example.com>"' \
759 [to]=test_suite_other@notmuchmail.org \
760 [subject]=notmuch-reply-test \
761 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
762 '[body]="reply from alternate address"'
764 output=$($NOTMUCH reply id:${gen_msg_id})
765 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
766 Subject: Re: notmuch-reply-test
767 To: Sender <sender@example.com>
768 Bcc: test_suite@notmuchmail.org
769 In-Reply-To: <${gen_msg_id}>
770 References: <${gen_msg_id}>
772 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
773 > reply from alternate address"
775 printf " Support for Reply-To...\t\t\t"
776 add_message '[from]="Sender <sender@example.com>"' \
777 [to]=test_suite@notmuchmail.org \
778 [subject]=notmuch-reply-test \
779 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
780 '[body]="support for reply-to"' \
781 '[reply-to]="Sender <elsewhere@example.com>"'
783 output=$($NOTMUCH reply id:${gen_msg_id})
784 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
785 Subject: Re: notmuch-reply-test
786 To: Sender <elsewhere@example.com>
787 Bcc: test_suite@notmuchmail.org
788 In-Reply-To: <${gen_msg_id}>
789 References: <${gen_msg_id}>
791 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
792 > support for reply-to"
794 printf " Un-munging Reply-To...\t\t\t\t"
795 add_message '[from]="Sender <sender@example.com>"' \
796 '[to]="Some List <list@example.com>"' \
797 [subject]=notmuch-reply-test \
798 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
799 '[body]="Un-munging Reply-To"' \
800 '[reply-to]="Evil Munging List <list@example.com>"'
802 output=$($NOTMUCH reply id:${gen_msg_id})
803 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
804 Subject: Re: notmuch-reply-test
805 To: Sender <sender@example.com>, Some List <list@example.com>
806 Bcc: test_suite@notmuchmail.org
807 In-Reply-To: <${gen_msg_id}>
808 References: <${gen_msg_id}>
810 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
811 > Un-munging Reply-To"
813 printf " Message with header of exactly 200 bytes...\t"
815 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"' \
816 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
817 '[body]="200-byte header"'
819 output=$($NOTMUCH reply id:${gen_msg_id})
820 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
821 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
822 Bcc: test_suite@notmuchmail.org
823 In-Reply-To: <${gen_msg_id}>
824 References: <${gen_msg_id}>
826 On Tue, 05 Jan 2010 15:43:56 -0800, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
829 printf "\nTesting handling of uuencoded data:\n"
831 add_message [subject]=uuencodetest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
832 '[body]="This message is used to ensure that notmuch correctly handles a
833 message containing a block of uuencoded data. First, we have a marker
834 this content beforeuudata . Then we beging the uunencoded data itself:
836 begin 644 bogus-uuencoded-data
837 M0123456789012345678901234567890123456789012345678901234567890
838 MOBVIOUSLY, THIS IS NOT ANY SORT OF USEFUL UUNECODED DATA.
839 MINSTEAD THIS IS JUST A WAY TO ENSURE THAT THIS BLOCK OF DATA
840 MIS CORRECTLY IGNORED WHEN NOTMUCH CREATES ITS INDEX. SO WE
841 MINCLUDE A DURINGUUDATA MARKER THAT SHOULD NOT RESULT IN ANY
846 Finally, we have our afteruudata marker as well."'
848 printf " Ensure content before uu data is indexed...\t"
849 output=$($NOTMUCH search beforeuudata | notmuch_search_sanitize)
850 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
851 printf " Ensure uu data is not indexed...\t\t"
852 output=$($NOTMUCH search DURINGUUDATA | notmuch_search_sanitize)
853 pass_if_equal "$output" ""
854 printf " Ensure content after uu data is indexed...\t"
855 output=$($NOTMUCH search afteruudata | notmuch_search_sanitize)
856 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
858 printf "\nTesting \"notmuch dump\" and \"notmuch restore\":\n"
860 printf " Dumping all tags...\t\t\t\t"
861 $NOTMUCH dump dump.expected
862 pass_if_equal "$?" "0"
864 printf " Clearing all tags...\t\t\t\t"
865 sed -e 's/(\([^(]*\))$/()/' < dump.expected > clear.expected
866 $NOTMUCH restore clear.expected
867 $NOTMUCH dump clear.actual
868 pass_if_equal "$(< clear.actual)" "$(< clear.expected)"
870 printf " Restoring original tags...\t\t\t"
871 $NOTMUCH restore dump.expected
872 $NOTMUCH dump dump.actual
873 pass_if_equal "$(< dump.actual)" "$(< dump.expected)"
875 printf " Restore with nothing to do...\t\t\t"
876 $NOTMUCH restore dump.expected
877 pass_if_equal "$?" "0"
879 printf "\nTesting threading when messages received out of order:\n"
880 printf " Adding initial child message...\t\t"
881 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
882 output=$(NOTMUCH_NEW)
883 pass_if_equal "$output" "Added 1 new message to the database."
884 printf " Searching returns the message...\t\t"
885 output=$($NOTMUCH search foo | notmuch_search_sanitize)
886 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; brokenthreadtest (inbox unread)"
887 printf " Adding second child message...\t\t\t"
888 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
889 output=$(NOTMUCH_NEW)
890 pass_if_equal "$output" "Added 1 new message to the database."
891 printf " Searching returns both messages in one thread..."
892 output=$($NOTMUCH search foo | notmuch_search_sanitize)
893 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/2] Notmuch Test Suite; brokenthreadtest (inbox unread)"
894 printf " Adding parent message...\t\t\t"
895 generate_message [body]=foo [id]=parent-id [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
896 output=$(NOTMUCH_NEW)
897 pass_if_equal "$output" "Added 1 new message to the database."
898 printf " Searching returns all three messages in one thread..."
899 output=$($NOTMUCH search foo | notmuch_search_sanitize)
900 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
902 printf "\nTesting author reordering;\n"
903 printf " Adding parent message...\t\t\t"
904 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"'
905 output=$(NOTMUCH_NEW)
906 pass_if_equal "$output" "Added 1 new message to the database."
907 printf " Adding initial child message...\t\t"
908 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"'
909 output=$(NOTMUCH_NEW)
910 pass_if_equal "$output" "Added 1 new message to the database."
911 printf " Adding second child message...\t\t\t"
912 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"'
913 output=$(NOTMUCH_NEW)
914 pass_if_equal "$output" "Added 1 new message to the database."
915 printf " Searching when all three messages match...\t"
916 output=$($NOTMUCH search findme | notmuch_search_sanitize)
917 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] User, User1, User2; author-reorder-threadtest (inbox unread)"
918 printf " Searching when two messages match...\t\t"
919 output=$($NOTMUCH search User1 or User2 | notmuch_search_sanitize)
920 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/3] User1, User2| User; author-reorder-threadtest (inbox unread)"
921 printf " Searching when only one message matches...\t"
922 output=$($NOTMUCH search User2 | notmuch_search_sanitize)
923 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/3] User2| User, User1; author-reorder-threadtest (inbox unread)"
924 printf " Searching when only first message matches...\t"
925 output=$($NOTMUCH search User | notmuch_search_sanitize)
926 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/3] User| User1, User2; author-reorder-threadtest (inbox unread)"
928 printf "\nTesting From line heuristics (with multiple configured addresses):\n"
929 printf " Magic from guessing (nothing to go on)...\t"
930 add_message '[from]="Sender <sender@example.com>"' \
931 [to]=mailinglist@notmuchmail.org \
932 [subject]=notmuch-reply-test \
933 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
934 '[body]="from guessing test"'
936 output=$($NOTMUCH reply id:${gen_msg_id})
937 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
938 Subject: Re: notmuch-reply-test
939 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
940 Bcc: test_suite@notmuchmail.org
941 In-Reply-To: <${gen_msg_id}>
942 References: <${gen_msg_id}>
944 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
945 > from guessing test"
947 printf " Magic from guessing (Envelope-to:)...\t\t"
948 add_message '[from]="Sender <sender@example.com>"' \
949 [to]=mailinglist@notmuchmail.org \
950 [subject]=notmuch-reply-test \
951 '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
952 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
953 '[body]="from guessing test"'
955 output=$($NOTMUCH reply id:${gen_msg_id})
956 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
957 Subject: Re: notmuch-reply-test
958 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
959 Bcc: test_suite@notmuchmail.org
960 In-Reply-To: <${gen_msg_id}>
961 References: <${gen_msg_id}>
963 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
964 > from guessing test"
966 printf " Magic from guessing (X-Original-To:)...\t"
967 add_message '[from]="Sender <sender@example.com>"' \
968 [to]=mailinglist@notmuchmail.org \
969 [subject]=notmuch-reply-test \
970 '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
971 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
972 '[body]="from guessing test"'
974 output=$($NOTMUCH reply id:${gen_msg_id})
975 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
976 Subject: Re: notmuch-reply-test
977 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
978 Bcc: test_suite@notmuchmail.org
979 In-Reply-To: <${gen_msg_id}>
980 References: <${gen_msg_id}>
982 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
983 > from guessing test"
985 printf " Magic from guessing (Received: .. for ..)...\t"
986 add_message '[from]="Sender <sender@example.com>"' \
987 [to]=mailinglist@notmuchmail.org \
988 [subject]=notmuch-reply-test \
989 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
990 by mail.notmuchmail.org (some MTA) with ESMTP id 12345678\
991 for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
992 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
993 '[body]="from guessing test"'
995 output=$($NOTMUCH reply id:${gen_msg_id})
996 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
997 Subject: Re: notmuch-reply-test
998 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
999 Bcc: test_suite@notmuchmail.org
1000 In-Reply-To: <${gen_msg_id}>
1001 References: <${gen_msg_id}>
1003 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1004 > from guessing test"
1006 printf " Magic from guessing (Received: domain)...\t"
1007 add_message '[from]="Sender <sender@example.com>"' \
1008 [to]=mailinglist@notmuchmail.org \
1009 [subject]=notmuch-reply-test \
1010 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
1011 by mail.otherdomain.org (some MTA) with ESMTP id 12345678\
1012 Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1013 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1014 '[body]="from guessing test"'
1016 output=$($NOTMUCH reply id:${gen_msg_id})
1017 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@otherdomain.org>
1018 Subject: Re: notmuch-reply-test
1019 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1020 Bcc: test_suite@notmuchmail.org
1021 In-Reply-To: <${gen_msg_id}>
1022 References: <${gen_msg_id}>
1024 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1025 > from guessing test"
1028 printf "\nTesting From line heuristics (with single configured address):\n"
1029 sed -i -e 's/^other_email.*//' ${NOTMUCH_CONFIG}
1031 printf " Magic from guessing (nothing to go on)...\t"
1032 add_message '[from]="Sender <sender@example.com>"' \
1033 [to]=mailinglist@notmuchmail.org \
1034 [subject]=notmuch-reply-test \
1035 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1036 '[body]="from guessing test"'
1038 output=$($NOTMUCH reply id:${gen_msg_id})
1039 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1040 Subject: Re: notmuch-reply-test
1041 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1042 Bcc: test_suite@notmuchmail.org
1043 In-Reply-To: <${gen_msg_id}>
1044 References: <${gen_msg_id}>
1046 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1047 > from guessing test"
1049 printf " Magic from guessing (Envelope-to:)...\t\t"
1050 add_message '[from]="Sender <sender@example.com>"' \
1051 [to]=mailinglist@notmuchmail.org \
1052 [subject]=notmuch-reply-test \
1053 '[header]="Envelope-To: test_suite_other@notmuchmail.org"' \
1054 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1055 '[body]="from guessing test"'
1057 output=$($NOTMUCH reply id:${gen_msg_id})
1058 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1059 Subject: Re: notmuch-reply-test
1060 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1061 Bcc: test_suite@notmuchmail.org
1062 In-Reply-To: <${gen_msg_id}>
1063 References: <${gen_msg_id}>
1065 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1066 > from guessing test"
1068 printf " Magic from guessing (X-Original-To:)...\t"
1069 add_message '[from]="Sender <sender@example.com>"' \
1070 [to]=mailinglist@notmuchmail.org \
1071 [subject]=notmuch-reply-test \
1072 '[header]="X-Original-To: test_suite_other@notmuchmail.org"' \
1073 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1074 '[body]="from guessing test"'
1076 output=$($NOTMUCH reply id:${gen_msg_id})
1077 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1078 Subject: Re: notmuch-reply-test
1079 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1080 Bcc: test_suite@notmuchmail.org
1081 In-Reply-To: <${gen_msg_id}>
1082 References: <${gen_msg_id}>
1084 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1085 > from guessing test"
1087 printf " Magic from guessing (Received: .. for ..)...\t"
1088 add_message '[from]="Sender <sender@example.com>"' \
1089 [to]=mailinglist@notmuchmail.org \
1090 [subject]=notmuch-reply-test \
1091 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
1092 by mail.notmuchmail.org (some MTA) with ESMTP id 12345678\
1093 for <test_suite_other@notmuchmail.org>; Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1094 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1095 '[body]="from guessing test"'
1097 output=$($NOTMUCH reply id:${gen_msg_id})
1098 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1099 Subject: Re: notmuch-reply-test
1100 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1101 Bcc: test_suite@notmuchmail.org
1102 In-Reply-To: <${gen_msg_id}>
1103 References: <${gen_msg_id}>
1105 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1106 > from guessing test"
1108 printf " Magic from guessing (Received: domain)...\t"
1109 add_message '[from]="Sender <sender@example.com>"' \
1110 [to]=mailinglist@notmuchmail.org \
1111 [subject]=notmuch-reply-test \
1112 '[header]="Received: from mail.example.com (mail.example.com [1.1.1.1])\
1113 by mail.otherdomain.org (some MTA) with ESMTP id 12345678\
1114 Sat, 10 Apr 2010 07:54:51 -0400 (EDT)"' \
1115 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
1116 '[body]="from guessing test"'
1118 output=$($NOTMUCH reply id:${gen_msg_id})
1119 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
1120 Subject: Re: notmuch-reply-test
1121 To: Sender <sender@example.com>, mailinglist@notmuchmail.org
1122 Bcc: test_suite@notmuchmail.org
1123 In-Reply-To: <${gen_msg_id}>
1124 References: <${gen_msg_id}>
1126 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
1127 > from guessing test"
1129 printf "\nTesting messages with ridiculously-long message IDs...\n"
1130 printf " Referencing long ID before adding...\t\t"
1131 generate_message '[subject]="Reference of ridiculously-long message ID"' \
1132 '[references]=\<abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\>'
1134 output=$(NOTMUCH_NEW)
1135 pass_if_equal "$output" "Added 1 new message to the database."
1137 printf " Adding message with long ID...\t\t\t"
1138 generate_message '[subject]="A ridiculously-long message ID"' \
1139 '[id]=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-'
1141 output=$(NOTMUCH_NEW)
1142 pass_if_equal "$output" "Added 1 new message to the database."
1144 printf " Referencing long ID after adding...\t\t"
1145 generate_message '[subject]="Reply to ridiculously-long message ID"' \
1146 '[in-reply-to]=\<abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\>'
1148 output=$(NOTMUCH_NEW)
1149 pass_if_equal "$output" "Added 1 new message to the database."
1151 printf " Ensure all messages were threaded together...\t"
1153 output=$($NOTMUCH search 'subject:"a ridiculously-long message ID"' | notmuch_search_sanitize)
1154 pass_if_equal "$output" "thread:XXX 2001-01-05 [1/3] Notmuch Test Suite; A ridiculously-long message ID (inbox unread)"
1156 printf "\nTesting encoding issues...\n"
1157 printf " Message with text of unknown charset...\t"
1158 add_message '[content-type]="text/plain; charset=unknown-8bit"' \
1161 output=$($NOTMUCH show id:${gen_msg_id} 2>&1 | notmuch_show_sanitize)
1162 pass_if_equal "$output" "
\fmessage{ id:msg-074@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-074
1164 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox unread)
1165 Subject: Test message #74
1166 From: Notmuch Test Suite <test_suite@notmuchmail.org>
1167 To: Notmuch Test Suite <test_suite@notmuchmail.org>
1168 Date: Tue, 05 Jan 2001 15:43:57 -0800
1171 \fpart{ ID: 1, Content-type: text/plain
1178 echo "Notmuch test suite complete."
1180 if [ "$test_failures" = "0" ]; then
1181 echo "All $tests tests passed."
1184 echo "$test_failures/$tests tests failed. The failures can be investigated in:"