8 while [ -n "$dir" ]; do
15 if [ "$dir" = "/" ]; then
23 increment_mtime_amount=0
28 increment_mtime_amount=$((increment_mtime_amount + 1))
29 touch -d "+${increment_mtime_amount} seconds" $dir
32 # Generate a new message in the mail directory, with a unique message
33 # ID and subject. The message is not added to the index.
35 # After this function returns, the filename of the generated message
36 # is available as $gen_msg_filename and the message ID is available as
39 # This function supports named parameters with the bash syntax for
40 # assigning a value to an associative array ([name]=value). The
41 # supported parameters are:
43 # [dir]=directory/of/choice
45 # Generate the message in directory 'directory/of/choice' within
46 # the mail store. The directory will be created if necessary.
50 # Text to use as the body of the email message
52 # '[from]="Some User <user@example.com>"'
53 # '[to]="Some User <user@example.com>"'
54 # '[subject]="Subject of email message"'
55 # '[date]="RFC 822 Date"'
57 # Values for email headers. If not provided, default values will
58 # be generated instead.
60 # '[cc]="Some User <user@example.com>"'
61 # [reply-to]=some-address
62 # [in-reply-to]=<message-id>
64 # Additional values for email headers. If these are not provided
65 # then the relevant headers will simply not appear in the
70 # Controls the message-id of the created message.
76 # This is our (bash-specific) magic for doing named parameters
77 local -A template="($@)"
78 local additional_headers
80 if [ -z "${template[id]}" ]; then
81 gen_msg_cnt=$((gen_msg_cnt + 1))
82 gen_msg_name=msg-$(printf "%03d" $gen_msg_cnt)
83 gen_msg_id="${gen_msg_name}@notmuch-test-suite"
85 gen_msg_name="msg-${template[id]}"
86 gen_msg_id="${template[id]}"
89 if [ -z "${template[dir]}" ]; then
90 gen_msg_filename="${MAIL_DIR}/$gen_msg_name"
92 gen_msg_filename="${MAIL_DIR}/${template[dir]}/$gen_msg_name"
93 mkdir -p $(dirname $gen_msg_filename)
96 if [ -z "${template[body]}" ]; then
97 template[body]="This is just a test message (#${gen_msg_cnt})"
100 if [ -z "${template[from]}" ]; then
101 template[from]="Notmuch Test Suite <test_suite@notmuchmail.org>"
104 if [ -z "${template[to]}" ]; then
105 template[to]="Notmuch Test Suite <test_suite@notmuchmail.org>"
108 if [ -z "${template[subject]}" ]; then
109 template[subject]="Test message #${gen_msg_cnt}"
112 if [ -z "${template[date]}" ]; then
113 template[date]="Tue, 05 Jan 2001 15:43:57 -0800"
116 additional_headers=""
117 if [ ! -z "${template[reply-to]}" ]; then
118 additional_headers="Reply-To: ${template[reply-to]}
119 ${additional_headers}"
122 if [ ! -z "${template[in-reply-to]}" ]; then
123 additional_headers="In-Reply-To: ${template[in-reply-to]}
124 ${additional_headers}"
127 if [ ! -z "${template[cc]}" ]; then
128 additional_headers="Cc: ${template[cc]}
129 ${additional_headers}"
132 cat <<EOF >$gen_msg_filename
133 From: ${template[from]}
135 Message-Id: <${gen_msg_id}>
136 Subject: ${template[subject]}
137 Date: ${template[date]}
138 ${additional_headers}
142 # Ensure that the mtime of the containing directory is updated
143 increment_mtime $(dirname ${gen_msg_filename})
146 # Generate a new message and add it to the index.
148 # All of the arguments and return values supported by generate_message
149 # are also supported here, so see that function for details.
152 generate_message "$@"
154 $NOTMUCH new > /dev/null
167 if [ "$output" = "$expected" ]; then
171 testname=test-$(printf "%03d" $tests)
172 echo "$expected" > $testname.expected
173 echo "$output" > $testname.output
174 diff -u $testname.expected $testname.output || true
175 test_failures=$((test_failures + 1))
179 TEST_DIR=$(pwd)/test.$$
180 MAIL_DIR=${TEST_DIR}/mail
181 export NOTMUCH_CONFIG=${TEST_DIR}/notmuch-config
182 NOTMUCH=$(find_notmuch_binary $(pwd))
186 $NOTMUCH new | grep -v -E -e '^Processed [0-9]*( total)? file|Found [0-9]* total file'
189 NOTMUCH_SEARCH_THREAD_ID_SQUELCH='s/thread:................/thread:XXX/'
190 notmuch_search_sanitize ()
192 sed -e "$NOTMUCH_SEARCH_THREAD_ID_SQUELCH"
195 NOTMUCH_SHOW_FILENAME_SQUELCH='s,filename:.*/mail,filename:/XXX/mail,'
196 notmuch_show_sanitize ()
198 sed -e "$NOTMUCH_SHOW_FILENAME_SQUELCH"
207 cat <<EOF > ${NOTMUCH_CONFIG}
212 name=Notmuch Test Suite
213 primary_email=test_suite@notmuchmail.org
214 other_email=test_suite_other@notmuchmail.org
217 printf "Testing \"notmuch new\" in several variations:\n"
218 printf " No new messages...\t\t\t\t"
219 output=$(NOTMUCH_NEW)
220 pass_if_equal "$output" "No new mail."
222 printf " Single new message...\t\t\t\t"
224 output=$(NOTMUCH_NEW)
225 pass_if_equal "$output" "Added 1 new message to the database."
227 printf " Multiple new messages...\t\t\t"
230 output=$(NOTMUCH_NEW)
231 pass_if_equal "$output" "Added 2 new messages to the database."
233 printf " No new messages (non-empty DB)...\t\t"
234 output=$(NOTMUCH_NEW)
235 pass_if_equal "$output" "No new mail."
237 printf " New directories...\t\t\t\t"
238 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
239 mkdir ${MAIL_DIR}/def
240 mkdir ${MAIL_DIR}/ghi
241 generate_message [dir]=def
243 output=$(NOTMUCH_NEW)
244 pass_if_equal "$output" "Added 1 new message to the database."
246 printf " Alternate inode order...\t\t\t"
248 rm -rf ${MAIL_DIR}/.notmuch
249 mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc
251 generate_message [dir]=abc
253 output=$(NOTMUCH_NEW)
254 pass_if_equal "$output" "Added 1 new message to the database."
256 printf " Message moved in...\t\t\t\t"
257 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
259 tmp_msg_filename=tmp/$gen_msg_filename
260 mkdir -p $(dirname $tmp_msg_filename)
261 mv $gen_msg_filename $tmp_msg_filename
262 increment_mtime ${MAIL_DIR}
263 $NOTMUCH new > /dev/null
264 mv $tmp_msg_filename $gen_msg_filename
265 increment_mtime ${MAIL_DIR}
266 output=$(NOTMUCH_NEW)
267 pass_if_equal "$output" "Added 1 new message to the database."
269 printf " Renamed message...\t\t\t\t"
272 $NOTMUCH new > /dev/null
273 mv $gen_msg_filename ${gen_msg_filename}-renamed
274 increment_mtime ${MAIL_DIR}
275 output=$(NOTMUCH_NEW)
276 pass_if_equal "$output" "No new mail. Detected 1 file rename."
278 printf " Deleted message...\t\t\t\t"
280 rm ${gen_msg_filename}-renamed
281 increment_mtime ${MAIL_DIR}
282 output=$(NOTMUCH_NEW)
283 pass_if_equal "$output" "No new mail. Removed 1 message."
285 printf " Renamed directory...\t\t\t\t"
287 generate_message [dir]=dir
288 generate_message [dir]=dir
289 generate_message [dir]=dir
291 $NOTMUCH new > /dev/null
293 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
294 increment_mtime ${MAIL_DIR}
296 output=$(NOTMUCH_NEW)
297 pass_if_equal "$output" "No new mail. Detected 3 file renames."
299 printf " Deleted directory...\t\t\t\t"
301 rm -rf ${MAIL_DIR}/dir-renamed
302 increment_mtime ${MAIL_DIR}
304 output=$(NOTMUCH_NEW)
305 pass_if_equal "$output" "No new mail. Removed 3 messages."
307 printf " New directory (at end of list)...\t\t"
309 generate_message [dir]=zzz
310 generate_message [dir]=zzz
311 generate_message [dir]=zzz
313 output=$(NOTMUCH_NEW)
314 pass_if_equal "$output" "Added 3 new messages to the database."
316 printf " Deleted directory (end of list)...\t\t"
318 rm -rf ${MAIL_DIR}/zzz
319 increment_mtime ${MAIL_DIR}
321 output=$(NOTMUCH_NEW)
322 pass_if_equal "$output" "No new mail. Removed 3 messages."
324 printf " New symlink to directory...\t\t\t"
326 rm -rf ${MAIL_DIR}/.notmuch
327 mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir
330 ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink
332 output=$(NOTMUCH_NEW)
333 pass_if_equal "$output" "Added 1 new message to the database."
335 printf " New symlink to a file...\t\t\t"
337 external_msg_filename=${TEST_DIR}/external/$(basename $gen_msg_filename)
338 mkdir -p $(dirname $external_msg_filename)
339 mv $gen_msg_filename $external_msg_filename
340 ln -s $external_msg_filename $gen_msg_filename
341 increment_mtime ${MAIL_DIR}
342 output=$(NOTMUCH_NEW)
343 pass_if_equal "$output" "Added 1 new message to the database."
345 printf " New two-level directory...\t\t\t"
347 generate_message [dir]=two/levels
348 generate_message [dir]=two/levels
349 generate_message [dir]=two/levels
351 output=$(NOTMUCH_NEW)
352 pass_if_equal "$output" "Added 3 new messages to the database."
354 printf " Deleted two-level directory...\t\t\t"
356 rm -rf ${MAIL_DIR}/two
357 increment_mtime ${MAIL_DIR}
359 output=$(NOTMUCH_NEW)
360 pass_if_equal "$output" "No new mail. Removed 3 messages."
362 printf "\nTesting \"notmuch search\" in several variations:\n"
364 printf " Search body...\t\t\t\t\t"
365 add_message '[subject]="body search"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [body]=bodysearchtest
366 output=$($NOTMUCH search bodysearchtest | notmuch_search_sanitize)
367 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)"
369 printf " Search by from:...\t\t\t\t"
370 add_message '[subject]="search by from"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom
371 output=$($NOTMUCH search from:searchbyfrom | notmuch_search_sanitize)
372 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)"
374 printf " Search by to:...\t\t\t\t"
375 add_message '[subject]="search by to"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto
376 output=$($NOTMUCH search to:searchbyto | notmuch_search_sanitize)
377 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)"
379 printf " Search by subject:...\t\t\t\t"
380 add_message [subject]=subjectsearchtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
381 output=$($NOTMUCH search subject:subjectsearchtest | notmuch_search_sanitize)
382 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)"
384 printf " Search by id:...\t\t\t\t"
385 add_message '[subject]="search by id"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
386 output=$($NOTMUCH search id:${gen_msg_id} | notmuch_search_sanitize)
387 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)"
389 printf " Search by tag:...\t\t\t\t"
390 add_message '[subject]="search by tag"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
391 $NOTMUCH tag +searchbytag id:${gen_msg_id}
392 output=$($NOTMUCH search tag:searchbytag | notmuch_search_sanitize)
393 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)"
395 printf " Search by thread:...\t\t\t\t"
396 add_message '[subject]="search by thread"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
397 thread_id=$($NOTMUCH search id:${gen_msg_id} | sed -e 's/thread:\([a-f0-9]*\).*/\1/')
398 output=$($NOTMUCH search thread:${thread_id} | notmuch_search_sanitize)
399 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)"
401 printf " Search body (phrase)...\t\t\t"
402 add_message '[subject]="body search (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="body search (phrase)"'
403 add_message '[subject]="negative result"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="This phrase should not match the body search"'
404 output=$($NOTMUCH search '\"body search (phrase)\"' | notmuch_search_sanitize)
405 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)"
407 printf " Search by from: (address)...\t\t\t"
408 add_message '[subject]="search by from (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom@example.com
409 output=$($NOTMUCH search from:searchbyfrom@example.com | notmuch_search_sanitize)
410 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)"
412 printf " Search by from: (name)...\t\t\t"
413 add_message '[subject]="search by from (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]="Search By From Name <test@example.com>"'
414 output=$($NOTMUCH search from:'Search By From Name' | notmuch_search_sanitize)
415 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"
417 printf " Search by to: (address)...\t\t\t"
418 add_message '[subject]="search by to (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto@example.com
419 output=$($NOTMUCH search to:searchbyto@example.com | notmuch_search_sanitize)
420 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)"
422 printf " Search by to: (name)...\t\t\t"
423 add_message '[subject]="search by to (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[to]="Search By To Name <test@example.com>"'
424 output=$($NOTMUCH search to:'Search By To Name' | notmuch_search_sanitize)
425 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"
427 printf " Search by subject: (phrase)...\t\t\t"
428 add_message '[subject]="subject search test (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
429 add_message '[subject]="this phrase should not match the subject search test"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
430 output=$($NOTMUCH search 'subject:\"subject search test (phrase)\"' | notmuch_search_sanitize)
431 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)"
433 printf " Search for all messages (\"*\"):...\t\t"
434 output=$($NOTMUCH search '*' | notmuch_search_sanitize)
435 pass_if_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #6 (inbox unread)
436 thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #14 (inbox unread)
437 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)
438 thread:XXX 2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)
439 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)
440 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)
441 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)
442 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)
443 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)
444 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)
445 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; negative result (inbox unread)
446 thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)
447 thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)
448 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)
449 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)
450 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)
451 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match the subject search test (inbox unread)"
453 printf "\nTesting naming of threads with changing subject:\n"
454 add_message '[subject]="thread-naming: Initial thread subject"' \
455 '[date]="Fri, 05 Jan 2001 15:43:56 -0800"'
457 add_message '[subject]="thread-naming: Older changed subject"' \
458 '[date]="Sat, 06 Jan 2001 15:43:56 -0800"' \
459 "[in-reply-to]=\<$parent\>"
460 add_message '[subject]="thread-naming: Newer changed subject"' \
461 '[date]="Sun, 07 Jan 2001 15:43:56 -0800"' \
462 "[in-reply-to]=\<$parent\>"
463 add_message '[subject]="thread-naming: Final thread subject"' \
464 '[date]="Mon, 08 Jan 2001 15:43:56 -0800"' \
465 "[in-reply-to]=\<$parent\>"
468 printf " Initial thread name (oldest-first search)...\t"
469 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
470 pass_if_equal "$output" "thread:XXX 2001-01-05 [4/4] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
472 printf " Initial thread name (newest-first search)...\t"
473 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
474 pass_if_equal "$output" "thread:XXX 2001-01-08 [4/4] Notmuch Test Suite; thread-naming: Final thread subject (inbox unread)"
476 # Remove oldest and newest messages from search results
477 $NOTMUCH tag -inbox id:$parent or id:$final
479 printf " Changed thread name (oldest-first search)...\t"
480 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
481 pass_if_equal "$output" "thread:XXX 2001-01-06 [2/4] Notmuch Test Suite; thread-naming: Older changed subject (inbox unread)"
483 printf " Changed thread name (newest-first search)...\t"
484 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
485 pass_if_equal "$output" "thread:XXX 2001-01-07 [2/4] Notmuch Test Suite; thread-naming: Newer changed subject (inbox unread)"
487 printf " Ignore added reply prefix (Re:)...\t\t"
488 add_message '[subject]="Re: thread-naming: Initial thread subject"' \
489 '[date]="Tue, 09 Jan 2001 15:43:45 -0800"' \
490 "[in-reply-to]=\<$parent\>"
491 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
492 pass_if_equal "$output" "thread:XXX 2001-01-09 [3/5] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
494 printf " Ignore added reply prefix (Aw:)...\t\t"
495 add_message '[subject]="Aw: thread-naming: Initial thread subject"' \
496 '[date]="Wed, 10 Jan 2001 15:43:45 -0800"' \
497 "[in-reply-to]=\<$parent\>"
498 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
499 pass_if_equal "$output" "thread:XXX 2001-01-10 [4/6] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
501 printf " Ignore added reply prefix (Vs:)...\t\t"
502 add_message '[subject]="Vs: thread-naming: Initial thread subject"' \
503 '[date]="Thu, 11 Jan 2001 15:43:45 -0800"' \
504 "[in-reply-to]=\<$parent\>"
505 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
506 pass_if_equal "$output" "thread:XXX 2001-01-11 [5/7] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
508 printf " Ignore added reply prefix (Sv:)...\t\t"
509 add_message '[subject]="Sv: thread-naming: Initial thread subject"' \
510 '[date]="Fri, 12 Jan 2001 15:43:45 -0800"' \
511 "[in-reply-to]=\<$parent\>"
512 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
513 pass_if_equal "$output" "thread:XXX 2001-01-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
515 printf " Test order of messages in \"notmuch show\"\t"
516 output=$($NOTMUCH show thread-naming | notmuch_show_sanitize)
517 pass_if_equal "$output" "
\fmessage{ id:msg-033@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-033
519 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
520 Subject: thread-naming: Initial thread subject
521 From: Notmuch Test Suite <test_suite@notmuchmail.org>
522 To: Notmuch Test Suite <test_suite@notmuchmail.org>
523 Date: Fri, 05 Jan 2001 15:43:56 -0800
526 \fpart{ ID: 1, Content-type: text/plain
527 This is just a test message (#33)
531 \fmessage{ id:msg-034@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-034
533 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
534 Subject: thread-naming: Older changed subject
535 From: Notmuch Test Suite <test_suite@notmuchmail.org>
536 To: Notmuch Test Suite <test_suite@notmuchmail.org>
537 Date: Sat, 06 Jan 2001 15:43:56 -0800
540 \fpart{ ID: 1, Content-type: text/plain
541 This is just a test message (#34)
545 \fmessage{ id:msg-035@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-035
547 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
548 Subject: thread-naming: Newer changed subject
549 From: Notmuch Test Suite <test_suite@notmuchmail.org>
550 To: Notmuch Test Suite <test_suite@notmuchmail.org>
551 Date: Sun, 07 Jan 2001 15:43:56 -0800
554 \fpart{ ID: 1, Content-type: text/plain
555 This is just a test message (#35)
559 \fmessage{ id:msg-036@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-036
561 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
562 Subject: thread-naming: Final thread subject
563 From: Notmuch Test Suite <test_suite@notmuchmail.org>
564 To: Notmuch Test Suite <test_suite@notmuchmail.org>
565 Date: Mon, 08 Jan 2001 15:43:56 -0800
568 \fpart{ ID: 1, Content-type: text/plain
569 This is just a test message (#36)
573 \fmessage{ id:msg-037@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-037
575 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
576 Subject: Re: thread-naming: Initial thread subject
577 From: Notmuch Test Suite <test_suite@notmuchmail.org>
578 To: Notmuch Test Suite <test_suite@notmuchmail.org>
579 Date: Tue, 09 Jan 2001 15:43:45 -0800
582 \fpart{ ID: 1, Content-type: text/plain
583 This is just a test message (#37)
587 \fmessage{ id:msg-038@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-038
589 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
590 Subject: Aw: thread-naming: Initial thread subject
591 From: Notmuch Test Suite <test_suite@notmuchmail.org>
592 To: Notmuch Test Suite <test_suite@notmuchmail.org>
593 Date: Wed, 10 Jan 2001 15:43:45 -0800
596 \fpart{ ID: 1, Content-type: text/plain
597 This is just a test message (#38)
601 \fmessage{ id:msg-039@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-039
603 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
604 Subject: Vs: thread-naming: Initial thread subject
605 From: Notmuch Test Suite <test_suite@notmuchmail.org>
606 To: Notmuch Test Suite <test_suite@notmuchmail.org>
607 Date: Thu, 11 Jan 2001 15:43:45 -0800
610 \fpart{ ID: 1, Content-type: text/plain
611 This is just a test message (#39)
615 \fmessage{ id:msg-040@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-040
617 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
618 Subject: Sv: thread-naming: Initial thread subject
619 From: Notmuch Test Suite <test_suite@notmuchmail.org>
620 To: Notmuch Test Suite <test_suite@notmuchmail.org>
621 Date: Fri, 12 Jan 2001 15:43:45 -0800
624 \fpart{ ID: 1, Content-type: text/plain
625 This is just a test message (#40)
630 printf "\nTesting \"notmuch reply\" in several variations:\n"
632 printf " Basic reply...\t\t\t\t\t"
633 add_message '[from]="Sender <sender@example.com>"' \
634 [to]=test_suite@notmuchmail.org \
635 [subject]=notmuch-reply-test \
636 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
637 '[body]="basic reply test"'
639 output=$($NOTMUCH reply id:${gen_msg_id})
640 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
641 Subject: Re: notmuch-reply-test
642 To: Sender <sender@example.com>
643 Bcc: test_suite@notmuchmail.org
644 In-Reply-To: <${gen_msg_id}>
645 References: <${gen_msg_id}>
647 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
650 printf " Multiple recipients...\t\t\t\t"
651 add_message '[from]="Sender <sender@example.com>"' \
652 '[to]="test_suite@notmuchmail.org, Someone Else <someone@example.com>"' \
653 [subject]=notmuch-reply-test \
654 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
655 '[body]="Multiple recipients"'
657 output=$($NOTMUCH reply id:${gen_msg_id})
658 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
659 Subject: Re: notmuch-reply-test
660 To: Sender <sender@example.com>, Someone Else <someone@example.com>
661 Bcc: test_suite@notmuchmail.org
662 In-Reply-To: <${gen_msg_id}>
663 References: <${gen_msg_id}>
665 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
666 > Multiple recipients"
668 printf " Reply with CC...\t\t\t\t"
669 add_message '[from]="Sender <sender@example.com>"' \
670 [to]=test_suite@notmuchmail.org \
671 '[cc]="Other Parties <cc@example.com>"' \
672 [subject]=notmuch-reply-test \
673 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
674 '[body]="reply with CC"'
676 output=$($NOTMUCH reply id:${gen_msg_id})
677 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
678 Subject: Re: notmuch-reply-test
679 To: Sender <sender@example.com>
680 Cc: Other Parties <cc@example.com>
681 Bcc: test_suite@notmuchmail.org
682 In-Reply-To: <${gen_msg_id}>
683 References: <${gen_msg_id}>
685 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
688 printf " Reply from alternate address...\t\t"
689 add_message '[from]="Sender <sender@example.com>"' \
690 [to]=test_suite_other@notmuchmail.org \
691 [subject]=notmuch-reply-test \
692 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
693 '[body]="reply from alternate address"'
695 output=$($NOTMUCH reply id:${gen_msg_id})
696 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
697 Subject: Re: notmuch-reply-test
698 To: Sender <sender@example.com>
699 Bcc: test_suite@notmuchmail.org
700 In-Reply-To: <${gen_msg_id}>
701 References: <${gen_msg_id}>
703 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
704 > reply from alternate address"
706 printf " Support for Reply-To...\t\t\t"
707 add_message '[from]="Sender <sender@example.com>"' \
708 [to]=test_suite@notmuchmail.org \
709 [subject]=notmuch-reply-test \
710 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
711 '[body]="support for reply-to"' \
712 '[reply-to]="Sender <elsewhere@example.com>"'
714 output=$($NOTMUCH reply id:${gen_msg_id})
715 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
716 Subject: Re: notmuch-reply-test
717 To: Sender <elsewhere@example.com>
718 Bcc: test_suite@notmuchmail.org
719 In-Reply-To: <${gen_msg_id}>
720 References: <${gen_msg_id}>
722 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
723 > support for reply-to"
725 printf " Un-munging Reply-To...\t\t\t\t"
726 add_message '[from]="Sender <sender@example.com>"' \
727 '[to]="Some List <list@example.com>"' \
728 [subject]=notmuch-reply-test \
729 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
730 '[body]="Un-munging Reply-To"' \
731 '[reply-to]="Evil Munging List <list@example.com>"'
733 output=$($NOTMUCH reply id:${gen_msg_id})
734 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
735 Subject: Re: notmuch-reply-test
736 To: Sender <sender@example.com>, Some List <list@example.com>
737 Bcc: test_suite@notmuchmail.org
738 In-Reply-To: <${gen_msg_id}>
739 References: <${gen_msg_id}>
741 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
742 > Un-munging Reply-To"
744 printf "\nTesting handling of uuencoded data:\n"
746 add_message [subject]=uuencodetest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
747 '[body]="This message is used to ensure that notmuch correctly handles a
748 message containing a block of uuencoded data. First, we have a marker
749 this content beforeuudata . Then we beging the uunencoded data itself:
751 begin 644 bogus-uuencoded-data
752 M0123456789012345678901234567890123456789012345678901234567890
753 MOBVIOUSLY, THIS IS NOT ANY SORT OF USEFUL UUNECODED DATA.
754 MINSTEAD THIS IS JUST A WAY TO ENSURE THAT THIS BLOCK OF DATA
755 MIS CORRECTLY IGNORED WHEN NOTMUCH CREATES ITS INDEX. SO WE
756 MINCLUDE A DURINGUUDATA MARKER THAT SHOULD NOT RESULT IN ANY
761 Finally, we have our afteruudata marker as well."'
763 printf " Ensure content before uu data is indexed...\t"
764 output=$($NOTMUCH search beforeuudata | notmuch_search_sanitize)
765 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
766 printf " Ensure uu data is not indexed...\t\t"
767 output=$($NOTMUCH search DURINGUUDATA | notmuch_search_sanitize)
768 pass_if_equal "$output" ""
769 printf " Ensure content after uu data is indexed...\t"
770 output=$($NOTMUCH search afteruudata | notmuch_search_sanitize)
771 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
773 printf "\nTesting \"notmuch dump\" and \"notmuch restore\":\n"
775 printf " Dumping all tags...\t\t\t\t"
776 $NOTMUCH dump dump.expected
777 pass_if_equal "$?" "0"
779 printf " Clearing all tags...\t\t\t\t"
780 sed -e 's/(\([^(]*\))$/()/' < dump.expected > clear.expected
781 $NOTMUCH restore clear.expected
782 $NOTMUCH dump clear.actual
783 pass_if_equal "$(< clear.actual)" "$(< clear.expected)"
785 printf " Restoring original tags...\t\t\t"
786 $NOTMUCH restore dump.expected
787 $NOTMUCH dump dump.actual
788 pass_if_equal "$(< dump.actual)" "$(< dump.expected)"
790 printf " Restore with nothing to do...\t\t\t"
791 $NOTMUCH restore dump.expected
792 pass_if_equal "$?" "0"
794 printf "\nTesting threading when messages received out of order:\n"
795 printf " Adding initial child message...\t\t"
796 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
797 output=$(NOTMUCH_NEW)
798 pass_if_equal "$output" "Added 1 new message to the database."
799 printf " Searching returns the message...\t\t"
800 output=$($NOTMUCH search foo | notmuch_search_sanitize)
801 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; brokenthreadtest (inbox unread)"
802 printf " Adding second child message...\t\t\t"
803 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
804 output=$(NOTMUCH_NEW)
805 pass_if_equal "$output" "Added 1 new message to the database."
806 printf " Searching returns both messages in one thread..."
807 output=$($NOTMUCH search foo | notmuch_search_sanitize)
808 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/2] Notmuch Test Suite; brokenthreadtest (inbox unread)"
809 printf " Adding parent message...\t\t\t"
810 generate_message [body]=foo [id]=parent-id [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
811 output=$(NOTMUCH_NEW)
812 pass_if_equal "$output" "Added 1 new message to the database."
813 printf " Searching returns all three messages in one thread..."
814 output=$($NOTMUCH search foo | notmuch_search_sanitize)
815 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
818 echo "Notmuch test suite complete."
820 if [ "$test_failures" = "0" ]; then
821 echo "All $tests tests passed."
824 echo "$test_failures/$tests tests failed. The failures can be investigated in:"