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"'
458 add_message '[subject]="thread-naming: Older changed subject"' \
459 '[date]="Sat, 06 Jan 2001 15:43:56 -0800"' \
460 "[in-reply-to]=\<$parent\>"
461 add_message '[subject]="thread-naming: Newer changed subject"' \
462 '[date]="Sun, 07 Jan 2001 15:43:56 -0800"' \
463 "[in-reply-to]=\<$parent\>"
464 add_message '[subject]="thread-naming: Final thread subject"' \
465 '[date]="Mon, 08 Jan 2001 15:43:56 -0800"' \
466 "[in-reply-to]=\<$parent\>"
469 printf " Initial thread name (oldest-first search)...\t"
470 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
471 pass_if_equal "$output" "thread:XXX 2001-01-05 [4/4] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
473 printf " Initial thread name (newest-first search)...\t"
474 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
475 pass_if_equal "$output" "thread:XXX 2001-01-08 [4/4] Notmuch Test Suite; thread-naming: Final thread subject (inbox unread)"
477 # Remove oldest and newest messages from search results
478 $NOTMUCH tag -inbox id:$parent or id:$final
480 printf " Changed thread name (oldest-first search)...\t"
481 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
482 pass_if_equal "$output" "thread:XXX 2001-01-06 [2/4] Notmuch Test Suite; thread-naming: Older changed subject (inbox unread)"
484 printf " Changed thread name (newest-first search)...\t"
485 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
486 pass_if_equal "$output" "thread:XXX 2001-01-07 [2/4] Notmuch Test Suite; thread-naming: Newer changed subject (inbox unread)"
488 printf " Ignore added reply prefix (Re:)...\t\t"
489 add_message '[subject]="Re: thread-naming: Initial thread subject"' \
490 '[date]="Tue, 09 Jan 2001 15:43:45 -0800"' \
491 "[in-reply-to]=\<$parent\>"
492 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
493 pass_if_equal "$output" "thread:XXX 2001-01-09 [3/5] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
495 printf " Ignore added reply prefix (Aw:)...\t\t"
496 add_message '[subject]="Aw: thread-naming: Initial thread subject"' \
497 '[date]="Wed, 10 Jan 2001 15:43:45 -0800"' \
498 "[in-reply-to]=\<$parent\>"
499 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
500 pass_if_equal "$output" "thread:XXX 2001-01-10 [4/6] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
502 printf " Ignore added reply prefix (Vs:)...\t\t"
503 add_message '[subject]="Vs: thread-naming: Initial thread subject"' \
504 '[date]="Thu, 11 Jan 2001 15:43:45 -0800"' \
505 "[in-reply-to]=\<$parent\>"
506 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
507 pass_if_equal "$output" "thread:XXX 2001-01-11 [5/7] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
509 printf " Ignore added reply prefix (Sv:)...\t\t"
510 add_message '[subject]="Sv: thread-naming: Initial thread subject"' \
511 '[date]="Fri, 12 Jan 2001 15:43:45 -0800"' \
512 "[in-reply-to]=\<$parent\>"
513 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
514 pass_if_equal "$output" "thread:XXX 2001-01-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
516 printf " Test order of messages in \"notmuch show\"\t"
517 output=$($NOTMUCH show thread-naming | notmuch_show_sanitize)
518 pass_if_equal "$output" "
\fmessage{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 filename:/XXX/mail/msg-$(printf "%03d" $first)
520 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (unread)
521 Subject: thread-naming: Initial thread subject
522 From: Notmuch Test Suite <test_suite@notmuchmail.org>
523 To: Notmuch Test Suite <test_suite@notmuchmail.org>
524 Date: Fri, 05 Jan 2001 15:43:56 -0800
527 \fpart{ ID: 1, Content-type: text/plain
528 This is just a test message (#$first)
532 \fmessage{ id:msg-$(printf "%03d" $((first + 1)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 1)))
534 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-06) (inbox unread)
535 Subject: thread-naming: Older changed subject
536 From: Notmuch Test Suite <test_suite@notmuchmail.org>
537 To: Notmuch Test Suite <test_suite@notmuchmail.org>
538 Date: Sat, 06 Jan 2001 15:43:56 -0800
541 \fpart{ ID: 1, Content-type: text/plain
542 This is just a test message (#$((first + 1)))
546 \fmessage{ id:msg-$(printf "%03d" $((first + 2)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 2)))
548 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-07) (inbox unread)
549 Subject: thread-naming: Newer changed subject
550 From: Notmuch Test Suite <test_suite@notmuchmail.org>
551 To: Notmuch Test Suite <test_suite@notmuchmail.org>
552 Date: Sun, 07 Jan 2001 15:43:56 -0800
555 \fpart{ ID: 1, Content-type: text/plain
556 This is just a test message (#$((first + 2)))
560 \fmessage{ id:msg-$(printf "%03d" $((first + 3)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 3)))
562 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-08) (unread)
563 Subject: thread-naming: Final thread subject
564 From: Notmuch Test Suite <test_suite@notmuchmail.org>
565 To: Notmuch Test Suite <test_suite@notmuchmail.org>
566 Date: Mon, 08 Jan 2001 15:43:56 -0800
569 \fpart{ ID: 1, Content-type: text/plain
570 This is just a test message (#$((first + 3)))
574 \fmessage{ id:msg-$(printf "%03d" $((first + 4)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 4)))
576 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-09) (inbox unread)
577 Subject: Re: thread-naming: Initial thread subject
578 From: Notmuch Test Suite <test_suite@notmuchmail.org>
579 To: Notmuch Test Suite <test_suite@notmuchmail.org>
580 Date: Tue, 09 Jan 2001 15:43:45 -0800
583 \fpart{ ID: 1, Content-type: text/plain
584 This is just a test message (#$((first + 4)))
588 \fmessage{ id:msg-$(printf "%03d" $((first + 5)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 5)))
590 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-10) (inbox unread)
591 Subject: Aw: thread-naming: Initial thread subject
592 From: Notmuch Test Suite <test_suite@notmuchmail.org>
593 To: Notmuch Test Suite <test_suite@notmuchmail.org>
594 Date: Wed, 10 Jan 2001 15:43:45 -0800
597 \fpart{ ID: 1, Content-type: text/plain
598 This is just a test message (#$((first + 5)))
602 \fmessage{ id:msg-$(printf "%03d" $((first + 6)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 6)))
604 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-11) (inbox unread)
605 Subject: Vs: thread-naming: Initial thread subject
606 From: Notmuch Test Suite <test_suite@notmuchmail.org>
607 To: Notmuch Test Suite <test_suite@notmuchmail.org>
608 Date: Thu, 11 Jan 2001 15:43:45 -0800
611 \fpart{ ID: 1, Content-type: text/plain
612 This is just a test message (#$((first + 6)))
616 \fmessage{ id:msg-$(printf "%03d" $((first + 7)))@notmuch-test-suite depth:1 match:1 filename:/XXX/mail/msg-$(printf "%03d" $((first + 7)))
618 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-12) (inbox unread)
619 Subject: Sv: thread-naming: Initial thread subject
620 From: Notmuch Test Suite <test_suite@notmuchmail.org>
621 To: Notmuch Test Suite <test_suite@notmuchmail.org>
622 Date: Fri, 12 Jan 2001 15:43:45 -0800
625 \fpart{ ID: 1, Content-type: text/plain
626 This is just a test message (#$((first + 7)))
631 printf "\nTesting \"notmuch reply\" in several variations:\n"
633 printf " Basic reply...\t\t\t\t\t"
634 add_message '[from]="Sender <sender@example.com>"' \
635 [to]=test_suite@notmuchmail.org \
636 [subject]=notmuch-reply-test \
637 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
638 '[body]="basic reply test"'
640 output=$($NOTMUCH reply id:${gen_msg_id})
641 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
642 Subject: Re: notmuch-reply-test
643 To: Sender <sender@example.com>
644 Bcc: test_suite@notmuchmail.org
645 In-Reply-To: <${gen_msg_id}>
646 References: <${gen_msg_id}>
648 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
651 printf " Multiple recipients...\t\t\t\t"
652 add_message '[from]="Sender <sender@example.com>"' \
653 '[to]="test_suite@notmuchmail.org, Someone Else <someone@example.com>"' \
654 [subject]=notmuch-reply-test \
655 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
656 '[body]="Multiple recipients"'
658 output=$($NOTMUCH reply id:${gen_msg_id})
659 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
660 Subject: Re: notmuch-reply-test
661 To: Sender <sender@example.com>, Someone Else <someone@example.com>
662 Bcc: test_suite@notmuchmail.org
663 In-Reply-To: <${gen_msg_id}>
664 References: <${gen_msg_id}>
666 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
667 > Multiple recipients"
669 printf " Reply with CC...\t\t\t\t"
670 add_message '[from]="Sender <sender@example.com>"' \
671 [to]=test_suite@notmuchmail.org \
672 '[cc]="Other Parties <cc@example.com>"' \
673 [subject]=notmuch-reply-test \
674 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
675 '[body]="reply with CC"'
677 output=$($NOTMUCH reply id:${gen_msg_id})
678 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
679 Subject: Re: notmuch-reply-test
680 To: Sender <sender@example.com>
681 Cc: Other Parties <cc@example.com>
682 Bcc: test_suite@notmuchmail.org
683 In-Reply-To: <${gen_msg_id}>
684 References: <${gen_msg_id}>
686 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
689 printf " Reply from alternate address...\t\t"
690 add_message '[from]="Sender <sender@example.com>"' \
691 [to]=test_suite_other@notmuchmail.org \
692 [subject]=notmuch-reply-test \
693 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
694 '[body]="reply from alternate address"'
696 output=$($NOTMUCH reply id:${gen_msg_id})
697 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
698 Subject: Re: notmuch-reply-test
699 To: Sender <sender@example.com>
700 Bcc: test_suite@notmuchmail.org
701 In-Reply-To: <${gen_msg_id}>
702 References: <${gen_msg_id}>
704 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
705 > reply from alternate address"
707 printf " Support for Reply-To...\t\t\t"
708 add_message '[from]="Sender <sender@example.com>"' \
709 [to]=test_suite@notmuchmail.org \
710 [subject]=notmuch-reply-test \
711 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
712 '[body]="support for reply-to"' \
713 '[reply-to]="Sender <elsewhere@example.com>"'
715 output=$($NOTMUCH reply id:${gen_msg_id})
716 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
717 Subject: Re: notmuch-reply-test
718 To: Sender <elsewhere@example.com>
719 Bcc: test_suite@notmuchmail.org
720 In-Reply-To: <${gen_msg_id}>
721 References: <${gen_msg_id}>
723 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
724 > support for reply-to"
726 printf " Un-munging Reply-To...\t\t\t\t"
727 add_message '[from]="Sender <sender@example.com>"' \
728 '[to]="Some List <list@example.com>"' \
729 [subject]=notmuch-reply-test \
730 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
731 '[body]="Un-munging Reply-To"' \
732 '[reply-to]="Evil Munging List <list@example.com>"'
734 output=$($NOTMUCH reply id:${gen_msg_id})
735 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
736 Subject: Re: notmuch-reply-test
737 To: Sender <sender@example.com>, Some List <list@example.com>
738 Bcc: test_suite@notmuchmail.org
739 In-Reply-To: <${gen_msg_id}>
740 References: <${gen_msg_id}>
742 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
743 > Un-munging Reply-To"
745 printf "\nTesting handling of uuencoded data:\n"
747 add_message [subject]=uuencodetest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
748 '[body]="This message is used to ensure that notmuch correctly handles a
749 message containing a block of uuencoded data. First, we have a marker
750 this content beforeuudata . Then we beging the uunencoded data itself:
752 begin 644 bogus-uuencoded-data
753 M0123456789012345678901234567890123456789012345678901234567890
754 MOBVIOUSLY, THIS IS NOT ANY SORT OF USEFUL UUNECODED DATA.
755 MINSTEAD THIS IS JUST A WAY TO ENSURE THAT THIS BLOCK OF DATA
756 MIS CORRECTLY IGNORED WHEN NOTMUCH CREATES ITS INDEX. SO WE
757 MINCLUDE A DURINGUUDATA MARKER THAT SHOULD NOT RESULT IN ANY
762 Finally, we have our afteruudata marker as well."'
764 printf " Ensure content before uu data is indexed...\t"
765 output=$($NOTMUCH search beforeuudata | notmuch_search_sanitize)
766 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
767 printf " Ensure uu data is not indexed...\t\t"
768 output=$($NOTMUCH search DURINGUUDATA | notmuch_search_sanitize)
769 pass_if_equal "$output" ""
770 printf " Ensure content after uu data is indexed...\t"
771 output=$($NOTMUCH search afteruudata | notmuch_search_sanitize)
772 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
774 printf "\nTesting \"notmuch dump\" and \"notmuch restore\":\n"
776 printf " Dumping all tags...\t\t\t\t"
777 $NOTMUCH dump dump.expected
778 pass_if_equal "$?" "0"
780 printf " Clearing all tags...\t\t\t\t"
781 sed -e 's/(\([^(]*\))$/()/' < dump.expected > clear.expected
782 $NOTMUCH restore clear.expected
783 $NOTMUCH dump clear.actual
784 pass_if_equal "$(< clear.actual)" "$(< clear.expected)"
786 printf " Restoring original tags...\t\t\t"
787 $NOTMUCH restore dump.expected
788 $NOTMUCH dump dump.actual
789 pass_if_equal "$(< dump.actual)" "$(< dump.expected)"
791 printf " Restore with nothing to do...\t\t\t"
792 $NOTMUCH restore dump.expected
793 pass_if_equal "$?" "0"
795 printf "\nTesting threading when messages received out of order:\n"
796 printf " Adding initial child message...\t\t"
797 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
798 output=$(NOTMUCH_NEW)
799 pass_if_equal "$output" "Added 1 new message to the database."
800 printf " Searching returns the message...\t\t"
801 output=$($NOTMUCH search foo | notmuch_search_sanitize)
802 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; brokenthreadtest (inbox unread)"
803 printf " Adding second child message...\t\t\t"
804 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
805 output=$(NOTMUCH_NEW)
806 pass_if_equal "$output" "Added 1 new message to the database."
807 printf " Searching returns both messages in one thread..."
808 output=$($NOTMUCH search foo | notmuch_search_sanitize)
809 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/2] Notmuch Test Suite; brokenthreadtest (inbox unread)"
810 printf " Adding parent message...\t\t\t"
811 generate_message [body]=foo [id]=parent-id [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
812 output=$(NOTMUCH_NEW)
813 pass_if_equal "$output" "Added 1 new message to the database."
814 printf " Searching returns all three messages in one thread..."
815 output=$($NOTMUCH search foo | notmuch_search_sanitize)
816 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
819 echo "Notmuch test suite complete."
821 if [ "$test_failures" = "0" ]; then
822 echo "All $tests tests passed."
825 echo "$test_failures/$tests tests failed. The failures can be investigated in:"