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"
201 cat <<EOF > ${NOTMUCH_CONFIG}
206 name=Notmuch Test Suite
207 primary_email=test_suite@notmuchmail.org
208 other_email=test_suite_other@notmuchmail.org
211 printf "Testing \"notmuch new\" in several variations:\n"
212 printf " No new messages...\t\t\t\t"
213 output=$(NOTMUCH_NEW)
214 pass_if_equal "$output" "No new mail."
216 printf " Single new message...\t\t\t\t"
218 output=$(NOTMUCH_NEW)
219 pass_if_equal "$output" "Added 1 new message to the database."
221 printf " Multiple new messages...\t\t\t"
224 output=$(NOTMUCH_NEW)
225 pass_if_equal "$output" "Added 2 new messages to the database."
227 printf " No new messages (non-empty DB)...\t\t"
228 output=$(NOTMUCH_NEW)
229 pass_if_equal "$output" "No new mail."
231 printf " New directories...\t\t\t\t"
232 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
233 mkdir ${MAIL_DIR}/def
234 mkdir ${MAIL_DIR}/ghi
235 generate_message [dir]=def
237 output=$(NOTMUCH_NEW)
238 pass_if_equal "$output" "Added 1 new message to the database."
240 printf " Alternate inode order...\t\t\t"
242 rm -rf ${MAIL_DIR}/.notmuch
243 mv ${MAIL_DIR}/ghi ${MAIL_DIR}/abc
245 generate_message [dir]=abc
247 output=$(NOTMUCH_NEW)
248 pass_if_equal "$output" "Added 1 new message to the database."
250 printf " Message moved in...\t\t\t\t"
251 rm -rf ${MAIL_DIR}/* ${MAIL_DIR}/.notmuch
253 tmp_msg_filename=tmp/$gen_msg_filename
254 mkdir -p $(dirname $tmp_msg_filename)
255 mv $gen_msg_filename $tmp_msg_filename
256 increment_mtime ${MAIL_DIR}
257 $NOTMUCH new > /dev/null
258 mv $tmp_msg_filename $gen_msg_filename
259 increment_mtime ${MAIL_DIR}
260 output=$(NOTMUCH_NEW)
261 pass_if_equal "$output" "Added 1 new message to the database."
263 printf " Renamed message...\t\t\t\t"
266 $NOTMUCH new > /dev/null
267 mv $gen_msg_filename ${gen_msg_filename}-renamed
268 increment_mtime ${MAIL_DIR}
269 output=$(NOTMUCH_NEW)
270 pass_if_equal "$output" "No new mail. Detected 1 file rename."
272 printf " Deleted message...\t\t\t\t"
274 rm ${gen_msg_filename}-renamed
275 increment_mtime ${MAIL_DIR}
276 output=$(NOTMUCH_NEW)
277 pass_if_equal "$output" "No new mail. Removed 1 message."
279 printf " Renamed directory...\t\t\t\t"
281 generate_message [dir]=dir
282 generate_message [dir]=dir
283 generate_message [dir]=dir
285 $NOTMUCH new > /dev/null
287 mv ${MAIL_DIR}/dir ${MAIL_DIR}/dir-renamed
288 increment_mtime ${MAIL_DIR}
290 output=$(NOTMUCH_NEW)
291 pass_if_equal "$output" "No new mail. Detected 3 file renames."
293 printf " Deleted directory...\t\t\t\t"
295 rm -rf ${MAIL_DIR}/dir-renamed
296 increment_mtime ${MAIL_DIR}
298 output=$(NOTMUCH_NEW)
299 pass_if_equal "$output" "No new mail. Removed 3 messages."
301 printf " New directory (at end of list)...\t\t"
303 generate_message [dir]=zzz
304 generate_message [dir]=zzz
305 generate_message [dir]=zzz
307 output=$(NOTMUCH_NEW)
308 pass_if_equal "$output" "Added 3 new messages to the database."
310 printf " Deleted directory (end of list)...\t\t"
312 rm -rf ${MAIL_DIR}/zzz
313 increment_mtime ${MAIL_DIR}
315 output=$(NOTMUCH_NEW)
316 pass_if_equal "$output" "No new mail. Removed 3 messages."
318 printf " New symlink to directory...\t\t\t"
320 rm -rf ${MAIL_DIR}/.notmuch
321 mv ${MAIL_DIR} ${TEST_DIR}/actual_maildir
324 ln -s ${TEST_DIR}/actual_maildir ${MAIL_DIR}/symlink
326 output=$(NOTMUCH_NEW)
327 pass_if_equal "$output" "Added 1 new message to the database."
329 printf " New symlink to a file...\t\t\t"
331 external_msg_filename=${TEST_DIR}/external/$(basename $gen_msg_filename)
332 mkdir -p $(dirname $external_msg_filename)
333 mv $gen_msg_filename $external_msg_filename
334 ln -s $external_msg_filename $gen_msg_filename
335 increment_mtime ${MAIL_DIR}
336 output=$(NOTMUCH_NEW)
337 pass_if_equal "$output" "Added 1 new message to the database."
339 printf " New two-level directory...\t\t\t"
341 generate_message [dir]=two/levels
342 generate_message [dir]=two/levels
343 generate_message [dir]=two/levels
345 output=$(NOTMUCH_NEW)
346 pass_if_equal "$output" "Added 3 new messages to the database."
348 printf " Deleted two-level directory...\t\t\t"
350 rm -rf ${MAIL_DIR}/two
351 increment_mtime ${MAIL_DIR}
353 output=$(NOTMUCH_NEW)
354 pass_if_equal "$output" "No new mail. Removed 3 messages."
356 printf "\nTesting \"notmuch search\" in several variations:\n"
358 printf " Search body...\t\t\t\t\t"
359 add_message '[subject]="body search"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [body]=bodysearchtest
360 output=$($NOTMUCH search bodysearchtest | notmuch_search_sanitize)
361 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)"
363 printf " Search by from:...\t\t\t\t"
364 add_message '[subject]="search by from"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom
365 output=$($NOTMUCH search from:searchbyfrom | notmuch_search_sanitize)
366 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)"
368 printf " Search by to:...\t\t\t\t"
369 add_message '[subject]="search by to"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto
370 output=$($NOTMUCH search to:searchbyto | notmuch_search_sanitize)
371 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)"
373 printf " Search by subject:...\t\t\t\t"
374 add_message [subject]=subjectsearchtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
375 output=$($NOTMUCH search subject:subjectsearchtest | notmuch_search_sanitize)
376 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)"
378 printf " Search by id:...\t\t\t\t"
379 add_message '[subject]="search by id"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
380 output=$($NOTMUCH search id:${gen_msg_id} | notmuch_search_sanitize)
381 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)"
383 printf " Search by tag:...\t\t\t\t"
384 add_message '[subject]="search by tag"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
385 $NOTMUCH tag +searchbytag id:${gen_msg_id}
386 output=$($NOTMUCH search tag:searchbytag | notmuch_search_sanitize)
387 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)"
389 printf " Search by thread:...\t\t\t\t"
390 add_message '[subject]="search by thread"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
391 thread_id=$($NOTMUCH search id:${gen_msg_id} | sed -e 's/thread:\([a-f0-9]*\).*/\1/')
392 output=$($NOTMUCH search thread:${thread_id} | notmuch_search_sanitize)
393 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)"
395 printf " Search body (phrase)...\t\t\t"
396 add_message '[subject]="body search (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="body search (phrase)"'
397 add_message '[subject]="negative result"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[body]="This phrase should not match the body search"'
398 output=$($NOTMUCH search '\"body search (phrase)\"' | notmuch_search_sanitize)
399 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)"
401 printf " Search by from: (address)...\t\t\t"
402 add_message '[subject]="search by from (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [from]=searchbyfrom@example.com
403 output=$($NOTMUCH search from:searchbyfrom@example.com | notmuch_search_sanitize)
404 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)"
406 printf " Search by from: (name)...\t\t\t"
407 add_message '[subject]="search by from (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[from]="Search By From Name <test@example.com>"'
408 output=$($NOTMUCH search from:'Search By From Name' | notmuch_search_sanitize)
409 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)"
411 printf " Search by to: (address)...\t\t\t"
412 add_message '[subject]="search by to (address)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' [to]=searchbyto@example.com
413 output=$($NOTMUCH search to:searchbyto@example.com | notmuch_search_sanitize)
414 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)"
416 printf " Search by to: (name)...\t\t\t"
417 add_message '[subject]="search by to (name)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' '[to]="Search By To Name <test@example.com>"'
418 output=$($NOTMUCH search to:'Search By To Name' | notmuch_search_sanitize)
419 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)"
421 printf " Search by subject: (phrase)...\t\t\t"
422 add_message '[subject]="subject search test (phrase)"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
423 add_message '[subject]="this phrase should not match the subject search test"' '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
424 output=$($NOTMUCH search 'subject:\"subject search test (phrase)\"' | notmuch_search_sanitize)
425 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)"
427 printf " Search for all messages (\"*\"):...\t\t"
428 output=$($NOTMUCH search '*' | notmuch_search_sanitize)
429 pass_if_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #6 (inbox unread)
430 thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Test message #14 (inbox unread)
431 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (inbox unread)
432 thread:XXX 2000-01-01 [1/1] searchbyfrom; search by from (inbox unread)
433 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (inbox unread)
434 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subjectsearchtest (inbox unread)
435 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by id (inbox unread)
436 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by tag (inbox searchbytag unread)
437 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by thread (inbox unread)
438 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; body search (phrase) (inbox unread)
439 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; negative result (inbox unread)
440 thread:XXX 2000-01-01 [1/1] searchbyfrom@example.com; search by from (address) (inbox unread)
441 thread:XXX 2000-01-01 [1/1] Search By From Name; search by from (name) (inbox unread)
442 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (address) (inbox unread)
443 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; search by to (name) (inbox unread)
444 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; subject search test (phrase) (inbox unread)
445 thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; this phrase should not match the subject search test (inbox unread)"
447 printf "\nTesting naming of threads with changing subject:\n"
448 add_message '[subject]="thread-naming: Initial thread subject"' \
449 '[date]="Fri, 05 Jan 2001 15:43:56 -0800"'
451 add_message '[subject]="thread-naming: Older changed subject"' \
452 '[date]="Sat, 06 Jan 2001 15:43:56 -0800"' \
453 "[in-reply-to]=\<$parent\>"
454 add_message '[subject]="thread-naming: Newer changed subject"' \
455 '[date]="Sun, 07 Jan 2001 15:43:56 -0800"' \
456 "[in-reply-to]=\<$parent\>"
457 add_message '[subject]="thread-naming: Final thread subject"' \
458 '[date]="Mon, 08 Jan 2001 15:43:56 -0800"' \
459 "[in-reply-to]=\<$parent\>"
462 printf " Initial thread name (oldest-first search)...\t"
463 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
464 pass_if_equal "$output" "thread:XXX 2001-01-05 [4/4] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
466 printf " Initial thread name (newest-first search)...\t"
467 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
468 pass_if_equal "$output" "thread:XXX 2001-01-08 [4/4] Notmuch Test Suite; thread-naming: Final thread subject (inbox unread)"
470 # Remove oldest and newest messages from search results
471 $NOTMUCH tag -inbox id:$parent or id:$final
473 printf " Changed thread name (oldest-first search)...\t"
474 output=$($NOTMUCH search --sort=oldest-first thread-naming and tag:inbox | notmuch_search_sanitize)
475 pass_if_equal "$output" "thread:XXX 2001-01-06 [2/4] Notmuch Test Suite; thread-naming: Older changed subject (inbox unread)"
477 printf " Changed thread name (newest-first search)...\t"
478 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
479 pass_if_equal "$output" "thread:XXX 2001-01-07 [2/4] Notmuch Test Suite; thread-naming: Newer changed subject (inbox unread)"
481 printf " Ignore added reply prefix (Re:)...\t\t"
482 add_message '[subject]="Re: thread-naming: Initial thread subject"' \
483 '[date]="Tue, 09 Jan 2001 15:43:45 -0800"' \
484 "[in-reply-to]=\<$parent\>"
485 output=$($NOTMUCH search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)
486 pass_if_equal "$output" "thread:XXX 2001-01-09 [3/5] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
488 printf " Ignore added reply prefix (Aw:)...\t\t"
489 add_message '[subject]="Aw: thread-naming: Initial thread subject"' \
490 '[date]="Wed, 10 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-10 [4/6] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
495 printf " Ignore added reply prefix (Vs:)...\t\t"
496 add_message '[subject]="Vs: thread-naming: Initial thread subject"' \
497 '[date]="Thu, 11 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-11 [5/7] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
502 printf " Ignore added reply prefix (Sv:)...\t\t"
503 add_message '[subject]="Sv: thread-naming: Initial thread subject"' \
504 '[date]="Fri, 12 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-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"
509 printf "\nTesting \"notmuch reply\" in several variations:\n"
511 printf " Basic reply...\t\t\t\t\t"
512 add_message '[from]="Sender <sender@example.com>"' \
513 [to]=test_suite@notmuchmail.org \
514 [subject]=notmuch-reply-test \
515 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
516 '[body]="basic reply test"'
518 output=$($NOTMUCH reply id:${gen_msg_id})
519 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
520 Subject: Re: notmuch-reply-test
521 To: Sender <sender@example.com>
522 Bcc: test_suite@notmuchmail.org
523 In-Reply-To: <${gen_msg_id}>
524 References: <${gen_msg_id}>
526 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
529 printf " Multiple recipients...\t\t\t\t"
530 add_message '[from]="Sender <sender@example.com>"' \
531 '[to]="test_suite@notmuchmail.org, Someone Else <someone@example.com>"' \
532 [subject]=notmuch-reply-test \
533 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
534 '[body]="Multiple recipients"'
536 output=$($NOTMUCH reply id:${gen_msg_id})
537 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
538 Subject: Re: notmuch-reply-test
539 To: Sender <sender@example.com>, Someone Else <someone@example.com>
540 Bcc: test_suite@notmuchmail.org
541 In-Reply-To: <${gen_msg_id}>
542 References: <${gen_msg_id}>
544 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
545 > Multiple recipients"
547 printf " Reply with CC...\t\t\t\t"
548 add_message '[from]="Sender <sender@example.com>"' \
549 [to]=test_suite@notmuchmail.org \
550 '[cc]="Other Parties <cc@example.com>"' \
551 [subject]=notmuch-reply-test \
552 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
553 '[body]="reply with CC"'
555 output=$($NOTMUCH reply id:${gen_msg_id})
556 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
557 Subject: Re: notmuch-reply-test
558 To: Sender <sender@example.com>
559 Cc: Other Parties <cc@example.com>
560 Bcc: test_suite@notmuchmail.org
561 In-Reply-To: <${gen_msg_id}>
562 References: <${gen_msg_id}>
564 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
567 printf " Reply from alternate address...\t\t"
568 add_message '[from]="Sender <sender@example.com>"' \
569 [to]=test_suite_other@notmuchmail.org \
570 [subject]=notmuch-reply-test \
571 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
572 '[body]="reply from alternate address"'
574 output=$($NOTMUCH reply id:${gen_msg_id})
575 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
576 Subject: Re: notmuch-reply-test
577 To: Sender <sender@example.com>
578 Bcc: test_suite@notmuchmail.org
579 In-Reply-To: <${gen_msg_id}>
580 References: <${gen_msg_id}>
582 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
583 > reply from alternate address"
585 printf " Support for Reply-To...\t\t\t"
586 add_message '[from]="Sender <sender@example.com>"' \
587 [to]=test_suite@notmuchmail.org \
588 [subject]=notmuch-reply-test \
589 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
590 '[body]="support for reply-to"' \
591 '[reply-to]="Sender <elsewhere@example.com>"'
593 output=$($NOTMUCH reply id:${gen_msg_id})
594 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
595 Subject: Re: notmuch-reply-test
596 To: Sender <elsewhere@example.com>
597 Bcc: test_suite@notmuchmail.org
598 In-Reply-To: <${gen_msg_id}>
599 References: <${gen_msg_id}>
601 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
602 > support for reply-to"
604 printf " Un-munging Reply-To...\t\t\t\t"
605 add_message '[from]="Sender <sender@example.com>"' \
606 '[to]="Some List <list@example.com>"' \
607 [subject]=notmuch-reply-test \
608 '[date]="Tue, 05 Jan 2010 15:43:56 -0800"' \
609 '[body]="Un-munging Reply-To"' \
610 '[reply-to]="Evil Munging List <list@example.com>"'
612 output=$($NOTMUCH reply id:${gen_msg_id})
613 pass_if_equal "$output" "From: Notmuch Test Suite <test_suite@notmuchmail.org>
614 Subject: Re: notmuch-reply-test
615 To: Sender <sender@example.com>, Some List <list@example.com>
616 Bcc: test_suite@notmuchmail.org
617 In-Reply-To: <${gen_msg_id}>
618 References: <${gen_msg_id}>
620 On Tue, 05 Jan 2010 15:43:56 -0800, Sender <sender@example.com> wrote:
621 > Un-munging Reply-To"
623 printf "\nTesting handling of uuencoded data:\n"
625 add_message [subject]=uuencodetest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
626 '[body]="This message is used to ensure that notmuch correctly handles a
627 message containing a block of uuencoded data. First, we have a marker
628 this content beforeuudata . Then we beging the uunencoded data itself:
630 begin 644 bogus-uuencoded-data
631 M0123456789012345678901234567890123456789012345678901234567890
632 MOBVIOUSLY, THIS IS NOT ANY SORT OF USEFUL UUNECODED DATA.
633 MINSTEAD THIS IS JUST A WAY TO ENSURE THAT THIS BLOCK OF DATA
634 MIS CORRECTLY IGNORED WHEN NOTMUCH CREATES ITS INDEX. SO WE
635 MINCLUDE A DURINGUUDATA MARKER THAT SHOULD NOT RESULT IN ANY
640 Finally, we have our afteruudata marker as well."'
642 printf " Ensure content before uu data is indexed...\t"
643 output=$($NOTMUCH search beforeuudata | notmuch_search_sanitize)
644 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
645 printf " Ensure uu data is not indexed...\t\t"
646 output=$($NOTMUCH search DURINGUUDATA | notmuch_search_sanitize)
647 pass_if_equal "$output" ""
648 printf " Ensure content after uu data is indexed...\t"
649 output=$($NOTMUCH search afteruudata | notmuch_search_sanitize)
650 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; uuencodetest (inbox unread)"
652 printf "\nTesting \"notmuch dump\" and \"notmuch restore\":\n"
654 printf " Dumping all tags...\t\t\t\t"
655 $NOTMUCH dump dump.expected
656 pass_if_equal "$?" "0"
658 printf " Clearing all tags...\t\t\t\t"
659 sed -e 's/(\([^(]*\))$/()/' < dump.expected > clear.expected
660 $NOTMUCH restore clear.expected
661 $NOTMUCH dump clear.actual
662 pass_if_equal "$(< clear.actual)" "$(< clear.expected)"
664 printf " Restoring original tags...\t\t\t"
665 $NOTMUCH restore dump.expected
666 $NOTMUCH dump dump.actual
667 pass_if_equal "$(< dump.actual)" "$(< dump.expected)"
669 printf " Restore with nothing to do...\t\t\t"
670 $NOTMUCH restore dump.expected
671 pass_if_equal "$?" "0"
673 printf "\nTesting threading when messages received out of order:\n"
674 printf " Adding initial child message...\t\t"
675 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
676 output=$(NOTMUCH_NEW)
677 pass_if_equal "$output" "Added 1 new message to the database."
678 printf " Searching returns the message...\t\t"
679 output=$($NOTMUCH search foo | notmuch_search_sanitize)
680 pass_if_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; brokenthreadtest (inbox unread)"
681 printf " Adding second child message...\t\t\t"
682 generate_message [body]=foo '[in-reply-to]=\<parent-id\>' [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
683 output=$(NOTMUCH_NEW)
684 pass_if_equal "$output" "Added 1 new message to the database."
685 printf " Searching returns both messages in one thread..."
686 output=$($NOTMUCH search foo | notmuch_search_sanitize)
687 pass_if_equal "$output" "thread:XXX 2000-01-01 [2/2] Notmuch Test Suite; brokenthreadtest (inbox unread)"
688 printf " Adding parent message...\t\t\t"
689 generate_message [body]=foo [id]=parent-id [subject]=brokenthreadtest '[date]="Sat, 01 Jan 2000 12:00:00 -0000"'
690 output=$(NOTMUCH_NEW)
691 pass_if_equal "$output" "Added 1 new message to the database."
692 printf " Searching returns all three messages in one thread..."
693 output=$($NOTMUCH search foo | notmuch_search_sanitize)
694 pass_if_equal "$output" "thread:XXX 2000-01-01 [3/3] Notmuch Test Suite; brokenthreadtest (inbox unread)"
697 echo "Notmuch test suite complete."
699 if [ "$test_failures" = "0" ]; then
700 echo "All $tests tests passed."
703 echo "$test_failures/$tests tests failed. The failures can be investigated in:"