3 test_description="emacs interface"
4 . $(dirname "$0")/test-lib.sh || exit 1
6 EXPECTED=$NOTMUCH_SRCDIR/test/emacs.expected-output
11 # syntax errors in test-lib.el cause mysterious failures
12 test_begin_subtest "Syntax of emacs test library"
13 test_expect_success "${TEST_EMACS} -Q --batch --load $NOTMUCH_SRCDIR/test/test-lib.el"
15 test_begin_subtest "Basic notmuch-hello view in emacs"
16 test_emacs '(notmuch-hello)
18 test_expect_equal_file $EXPECTED/notmuch-hello OUTPUT
20 test_begin_subtest "Saved search with 0 results"
21 test_emacs '(let ((notmuch-show-empty-saved-searches t)
22 (notmuch-saved-searches
23 '\''(("inbox" . "tag:inbox")
24 ("unread" . "tag:unread")
25 ("empty" . "tag:doesnotexist"))))
28 test_expect_equal_file $EXPECTED/notmuch-hello-with-empty OUTPUT
30 test_begin_subtest "No saved searches displayed (all with 0 results)"
31 test_emacs '(let ((notmuch-saved-searches
32 '\''(("empty" . "tag:doesnotexist"))))
35 test_expect_equal_file $EXPECTED/notmuch-hello-no-saved-searches OUTPUT
37 test_begin_subtest "Basic notmuch-search view in emacs"
38 test_emacs '(notmuch-search "tag:inbox")
41 test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
43 test_begin_subtest "Incremental parsing of search results"
44 test_emacs "(cl-letf* (((symbol-function 'orig)
45 (symbol-function 'notmuch-search-process-filter))
46 ((symbol-function 'notmuch-search-process-filter)
48 (cl-loop for char across string
49 do (orig proc (char-to-string char))))))
50 (notmuch-search \"tag:inbox\")
53 test_expect_equal_file $EXPECTED/notmuch-search-tag-inbox OUTPUT
55 test_begin_subtest "Navigation of notmuch-hello to search results"
56 test_emacs '(notmuch-hello)
57 (goto-char (point-min))
58 (re-search-forward "inbox")
59 (widget-button-press (1- (point)))
62 test_expect_equal_file $EXPECTED/notmuch-hello-view-inbox OUTPUT
64 test_begin_subtest "Basic notmuch-show view in emacs"
65 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
66 test_emacs "(notmuch-show \"$maildir_storage_thread\")
68 test_expect_equal_file $EXPECTED/notmuch-show-thread-maildir-storage OUTPUT
70 test_begin_subtest "Basic notmuch-show view in emacs default indentation"
71 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
72 test_emacs "(let ((notmuch-show-indent-messages-width 1))
73 (notmuch-show \"$maildir_storage_thread\")
75 test_expect_equal_file $EXPECTED/notmuch-show-thread-maildir-storage OUTPUT
77 test_begin_subtest "Basic notmuch-show view in emacs without indentation"
78 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
79 test_emacs "(let ((notmuch-show-indent-messages-width 0))
80 (notmuch-show \"$maildir_storage_thread\")
82 test_expect_equal_file $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation OUTPUT
84 test_begin_subtest "Basic notmuch-show view in emacs with fourfold indentation"
85 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
86 test_emacs "(let ((notmuch-show-indent-messages-width 4))
87 (notmuch-show \"$maildir_storage_thread\")
89 test_expect_equal_file $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation OUTPUT
91 test_begin_subtest "notmuch-show for message with invalid From"
92 add_message "[subject]=\"message-with-invalid-from\"" \
93 "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
94 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
95 test_emacs "(notmuch-show \"$thread\")
96 (test-output \"OUTPUT.raw\")"
98 Invalid " From <test_suite@notmuchmail.org> (2001-01-05) (inbox)
99 Subject: message-with-invalid-from
100 To: Notmuch Test Suite <test_suite@notmuchmail.org>
103 This is just a test message (#1)
105 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
106 test_expect_equal_file EXPECTED OUTPUT
108 test_begin_subtest "Navigation of notmuch-search to thread view"
109 test_emacs '(notmuch-search "tag:inbox")
111 (goto-char (point-min))
112 (re-search-forward "Working with Maildir")
113 (notmuch-search-show-thread)
116 test_expect_equal_file $EXPECTED/notmuch-show-thread-maildir-storage OUTPUT
118 test_begin_subtest "Add tag from search view"
119 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
120 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
122 (execute-kbd-macro \"+tag-from-search-view\")"
123 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
124 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-search-view unread)"
126 test_begin_subtest "Remove tag from search view"
127 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
129 (execute-kbd-macro \"-tag-from-search-view\")"
130 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
131 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
133 test_begin_subtest "Add tag (large query)"
134 # We use a long query to force us into batch mode and use a funny tag
135 # that requires escaping for batch tagging.
136 test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (mapconcat #'identity (make-list notmuch-tag-argument-limit \"x\") \"-\")) (list \"+tag-from-%-large-query\"))"
137 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
138 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-%-large-query unread)"
139 notmuch tag -tag-from-%-large-query $os_x_darwin_thread
141 test_begin_subtest "notmuch-show: add single tag to single message"
142 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
143 (execute-kbd-macro \"+tag-from-show-view\")"
144 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
145 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag-from-show-view unread)"
147 test_begin_subtest "notmuch-show: remove single tag from single message"
148 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
149 (execute-kbd-macro \"-tag-from-show-view\")"
150 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
151 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
153 test_begin_subtest "notmuch-show: add multiple tags to single message"
154 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
155 (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
156 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
157 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag1-from-show-view tag2-from-show-view unread)"
159 test_begin_subtest "notmuch-show: remove multiple tags from single message"
160 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
161 (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
162 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
163 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)"
165 test_begin_subtest "notmuch-show: before-tag-hook is run, variables are defined"
166 output=$(test_emacs '(let ((notmuch-test-tag-hook-output nil)
167 (notmuch-before-tag-hook (function notmuch-test-tag-hook)))
168 (notmuch-show "id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com")
169 (execute-kbd-macro "+activate-hook\n")
170 (execute-kbd-macro "-activate-hook\n")
171 notmuch-test-tag-hook-output)')
172 test_expect_equal "$output" \
173 '(("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "-activate-hook")
174 ("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "+activate-hook"))'
176 test_begin_subtest "notmuch-show: after-tag-hook is run, variables are defined"
177 output=$(test_emacs '(let ((notmuch-test-tag-hook-output nil)
178 (notmuch-after-tag-hook (function notmuch-test-tag-hook)))
179 (notmuch-show "id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com")
180 (execute-kbd-macro "+activate-hook\n")
181 (execute-kbd-macro "-activate-hook\n")
182 notmuch-test-tag-hook-output)')
183 test_expect_equal "$output" \
184 '(("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "-activate-hook")
185 ("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "+activate-hook"))'
187 test_begin_subtest "Message with .. in Message-Id:"
188 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
189 test_emacs '(notmuch-search "id:\"123..456@example\"")
191 (execute-kbd-macro "+search-add")
192 (execute-kbd-macro "+search-remove")
193 (execute-kbd-macro "-search-remove")
194 (notmuch-show "id:\"123..456@example\"")
196 (execute-kbd-macro "+show-add")
197 (execute-kbd-macro "+show-remove")
198 (execute-kbd-macro "-show-remove")'
199 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
200 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
202 test_begin_subtest "Message with quote in Message-Id:"
203 add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
204 test_emacs '(notmuch-search "subject:\"Message with quote\"")
206 (execute-kbd-macro "+search-add")
207 (notmuch-search-show-thread)
209 (execute-kbd-macro "+show-add")'
210 output=$(notmuch search 'id:"""quote""@example"' | notmuch_search_sanitize)
211 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with quote in Message-Id (inbox search-add show-add)"
213 test_begin_subtest "Sending a message via (fake) SMTP"
214 emacs_deliver_message \
215 'Testing message sent via SMTP' \
216 'This is a test that messages are sent via SMTP' \
219 (insert "To: user@example.com\n")'
221 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
222 -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
224 From: Notmuch Test Suite <test_suite@notmuchmail.org>
226 Subject: Testing message sent via SMTP
227 Date: 01 Jan 2000 12:00:00 -0000
230 Content-Type: text/plain
232 This is a test that messages are sent via SMTP
234 test_expect_equal_file EXPECTED OUTPUT
236 test_begin_subtest "Folding a long header when sending via (fake) SMTP"
237 long_subject="This is a long subject `echo {1..1000}`"
238 emacs_deliver_message \
240 'This is a test that long headers are folded when messages are sent via SMTP' \
243 (insert "To: user@example.com\n")'
245 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
246 -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
248 From: Notmuch Test Suite <test_suite@notmuchmail.org>
250 Subject: This is a long subject 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
251 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
252 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
253 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
254 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
255 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
256 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
257 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
258 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
259 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
260 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
261 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
262 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
263 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
264 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
265 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
266 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
267 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347
268 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365
269 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383
270 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
271 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
272 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
273 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
274 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
275 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491
276 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
277 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527
278 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
279 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563
280 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
281 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
282 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617
283 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635
284 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
285 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671
286 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689
287 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
288 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725
289 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743
290 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761
291 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779
292 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
293 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815
294 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833
295 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
296 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
297 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887
298 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
299 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923
300 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
301 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
302 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977
303 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995
305 Date: 01 Jan 2000 12:00:00 -0000
308 Content-Type: text/plain
310 This is a test that long headers are folded when messages are sent via SMTP
312 test_expect_equal_file EXPECTED OUTPUT
314 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
315 notmuch new > /dev/null
316 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
317 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
319 test_begin_subtest "notmuch-fcc-dirs set to nil"
320 test_emacs "(let ((notmuch-fcc-dirs nil))
324 From: Notmuch Test Suite <test_suite@notmuchmail.org>
327 --text follows this line--
329 test_expect_equal_file EXPECTED OUTPUT
331 # Make another FCC maildir specific for the next test
332 mkdir -p mail/sent-string/cur
333 mkdir -p mail/sent-string/new
334 mkdir -p mail/sent-string/tmp
336 test_begin_subtest "notmuch-fcc-dirs set to a string"
337 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
341 From: Notmuch Test Suite <test_suite@notmuchmail.org>
344 Fcc: ${MAIL_DIR}/sent-string
345 --text follows this line--
347 test_expect_equal_file EXPECTED OUTPUT
349 # Make more FCC maildirs specific for the next test
350 mkdir -p mail/sent-list-match/cur
351 mkdir -p mail/sent-list-match/new
352 mkdir -p mail/sent-list-match/tmp
353 mkdir -p mail/failure/cur
354 mkdir -p mail/failure/new
355 mkdir -p mail/failure/tmp
357 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
358 test_emacs "(let ((notmuch-fcc-dirs
359 '((\"notmuchmail.org\" . \"sent-list-match\")
360 (\".*\" . \"failure\"))))
364 From: Notmuch Test Suite <test_suite@notmuchmail.org>
367 Fcc: ${MAIL_DIR}/sent-list-match
368 --text follows this line--
370 test_expect_equal_file EXPECTED OUTPUT
372 # Make another FCC maildir specific for the next test
373 mkdir -p mail/sent-list-catch-all/cur
374 mkdir -p mail/sent-list-catch-all/new
375 mkdir -p mail/sent-list-catch-all/tmp
377 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
378 test_emacs "(let ((notmuch-fcc-dirs
379 '((\"example.com\" . \"failure\")
380 (\".*\" . \"sent-list-catch-all\"))))
384 From: Notmuch Test Suite <test_suite@notmuchmail.org>
387 Fcc: ${MAIL_DIR}/sent-list-catch-all
388 --text follows this line--
390 test_expect_equal_file EXPECTED OUTPUT
392 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
393 test_emacs "(let ((notmuch-fcc-dirs
394 '((\"example.com\" . \"failure\")
395 (\"nomatchhere.net\" . \"failure\"))))
399 From: Notmuch Test Suite <test_suite@notmuchmail.org>
402 --text follows this line--
404 test_expect_equal_file EXPECTED OUTPUT
406 test_begin_subtest "Reply within emacs"
407 test_emacs '(let ((message-hidden-headers ''()))
408 (notmuch-search "subject:\"testing message sent via SMTP\"")
410 (notmuch-search-reply-to-thread)
412 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
413 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
415 From: Notmuch Test Suite <test_suite@notmuchmail.org>
417 Subject: Re: Testing message sent via SMTP
419 Fcc: ${MAIL_DIR}/sent
421 --text follows this line--
422 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
424 > This is a test that messages are sent via SMTP
426 test_expect_equal_file EXPECTED OUTPUT
428 test_begin_subtest "Reply within emacs to a message with TAB in subject"
429 test_emacs '(let ((message-hidden-headers ''()))
430 (notmuch-search "id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net")
432 (notmuch-search-show-thread)
434 (notmuch-show-reply-sender)
436 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
437 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
438 sed -i -e '/^--text follows this line--$/q' OUTPUT
440 From: Notmuch Test Suite <test_suite@notmuchmail.org>
441 To: Mikhail Gusarov <dottedmag@dottedmag.net>
442 Subject: Re: [notmuch] [PATCH 1/2] Close message file after parsing message headers
444 Fcc: ${MAIL_DIR}/sent
446 --text follows this line--
448 test_expect_equal_file EXPECTED OUTPUT
450 test_begin_subtest "Reply from alternate address within emacs"
451 add_message '[from]="Sender <sender@example.com>"' \
452 [to]=test_suite_other@notmuchmail.org
454 test_emacs "(let ((message-hidden-headers '()))
455 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
457 (notmuch-search-reply-to-thread)
460 From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
461 To: Sender <sender@example.com>
462 Subject: Re: ${test_subtest_name}
463 In-Reply-To: <${gen_msg_id}>
464 Fcc: ${MAIL_DIR}/sent
465 References: <${gen_msg_id}>
466 --text follows this line--
467 Sender <sender@example.com> writes:
469 > This is just a test message (#${gen_msg_cnt})
471 test_expect_equal_file EXPECTED OUTPUT
473 test_begin_subtest "Reply from address in named group list within emacs"
474 add_message '[from]="Sender <sender@example.com>"' \
475 '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
476 [cc]=test_suite_other@notmuchmail.org
478 test_emacs "(let ((message-hidden-headers '()))
479 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
481 (notmuch-search-reply-to-thread)
484 From: Notmuch Test Suite <test_suite@notmuchmail.org>
485 To: Sender <sender@example.com>, someone@example.com
486 Subject: Re: ${test_subtest_name}
487 In-Reply-To: <${gen_msg_id}>
488 Fcc: ${MAIL_DIR}/sent
489 References: <${gen_msg_id}>
490 --text follows this line--
491 Sender <sender@example.com> writes:
493 > This is just a test message (#${gen_msg_cnt})
495 test_expect_equal_file EXPECTED OUTPUT
497 test_begin_subtest "Reply within emacs to a multipart/mixed message"
498 test_emacs '(let ((message-hidden-headers ''()))
499 (notmuch-show "id:20091118002059.067214ed@hikari")
503 From: Notmuch Test Suite <test_suite@notmuchmail.org>
504 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
505 Subject: Re: [notmuch] Introducing myself
506 In-Reply-To: <20091118002059.067214ed@hikari>
507 Fcc: ${MAIL_DIR}/sent
508 References: <20091118002059.067214ed@hikari>
509 --text follows this line--
510 Adrian Perez de Castro <aperez@igalia.com> writes:
514 > I have just heard about Not Much today in some random Linux-related news
515 > site (LWN?), my name is Adrian Perez and I work as systems administrator
516 > (although I can do some code as well :P). I have always thought that the
517 > ideas behind Sup were great, but after some time using it, I got tired of
518 > the oddities that it has. I also do not like doing things like having to
519 > install Ruby just for reading and sorting mails. Some time ago I thought
520 > about doing something like Not Much and in fact I played a bit with the
521 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
522 > to code things in Python when I am not working and also it is installed
523 > by default on most distribution. I got to have some mailboxes indexed and
524 > basic searching working a couple of months ago. Lately I have been very
525 > busy and had no time for coding, and them... boom! Not Much appears -- and
526 > it is almost exactly what I was trying to do, but faster. I have been
527 > playing a bit with Not Much today, and I think it has potential.
529 > Also, I would like to share one idea I had in mind, that you might find
530 > interesting: One thing I have found very annoying is having to re-tag my
531 > mail when the indexes get b0rked (it happened a couple of times to me while
532 > using Sup), so I was planning to mails as read/unread and adding the tags
533 > not just to the index, but to the mail text itself, e.g. by adding a
534 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
535 > could be totally recreated by re-reading the mail directories, and this
536 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
537 > local maildir, tagging and indexing the mails with the e-mail reader and
538 > then syncing back the messages with the "X-Tags" header to the IMAP server.
539 > This would allow to use the mail reader from a different computer and still
540 > have everything tagged finely.
546 > [1] http://software.complete.org/software/projects/show/offlineimap
549 > Adrian Perez de Castro <aperez@igalia.com>
550 > Igalia - Free Software Engineering
551 > _______________________________________________
552 > notmuch mailing list
553 > notmuch@notmuchmail.org
554 > http://notmuchmail.org/mailman/listinfo/notmuch
556 test_expect_equal_file EXPECTED OUTPUT
558 test_begin_subtest "Reply within emacs to a multipart/alternative message"
559 test_emacs '(let ((message-hidden-headers ''()))
560 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
564 From: Notmuch Test Suite <test_suite@notmuchmail.org>
565 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
566 Subject: Re: [notmuch] preliminary FreeBSD support
567 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
568 Fcc: ${MAIL_DIR}/sent
569 References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
570 --text follows this line--
571 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
573 > I saw the announcement this morning, and was very excited, as I had been
574 > hoping sup would be turned into a library,
575 > since I like the concept more than the UI (I'd rather an emacs interface).
577 > I did a preliminary compile which worked out fine, but
578 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
579 > FreeBSD, so notmuch_config_open segfaulted.
581 > Attached is a patch that supplies a default buffer size of 64 in cases where
584 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
585 > is acceptable behavior,
586 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
589 > From e3bc4bbd7b9d0d086816ab5f8f2d6ffea1dd3ea4 Mon Sep 17 00:00:00 2001
590 > From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>
591 > Date: Tue, 17 Nov 2009 11:30:39 -0800
592 > Subject: [PATCH] Deal with situation where sysconf(_SC_GETPW_R_SIZE_MAX) returns -1
595 > notmuch-config.c | 2 ++
596 > 1 files changed, 2 insertions(+), 0 deletions(-)
598 > diff --git a/notmuch-config.c b/notmuch-config.c
599 > index 248149c..e7220d8 100644
600 > --- a/notmuch-config.c
601 > +++ b/notmuch-config.c
602 > @@ -77,6 +77,7 @@ static char *
603 > get_name_from_passwd_file (void *ctx)
605 > long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
606 > + if (pw_buf_size == -1) pw_buf_size = 64;
607 > char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
608 > struct passwd passwd, *ignored;
610 > @@ -101,6 +102,7 @@ static char *
611 > get_username_from_passwd_file (void *ctx)
613 > long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
614 > + if (pw_buf_size == -1) pw_buf_size = 64;
615 > char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
616 > struct passwd passwd, *ignored;
621 > _______________________________________________
622 > notmuch mailing list
623 > notmuch@notmuchmail.org
624 > http://notmuchmail.org/mailman/listinfo/notmuch
626 test_expect_equal_file EXPECTED OUTPUT
628 test_begin_subtest "Reply within emacs to an html-only message"
629 add_message '[content-type]="text/html"' \
630 '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
631 test_emacs "(let ((message-hidden-headers '()))
632 (notmuch-show \"id:${gen_msg_id}\")
636 From: Notmuch Test Suite <test_suite@notmuchmail.org>
637 To: test_suite@notmuchmail.org
638 Subject: Re: Reply within emacs to an html-only message
639 In-Reply-To: <${gen_msg_id}>
640 Fcc: ${MAIL_DIR}/sent
641 References: <${gen_msg_id}>
642 --text follows this line--
643 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
645 > Hi,This is an HTML test message.OK?
647 test_expect_equal_file EXPECTED OUTPUT
649 test_begin_subtest "Reply within emacs to message from self"
650 add_message '[from]="test_suite@notmuchmail.org"' \
651 '[to]="test_suite@notmuchmail.org"'
652 test_emacs "(let ((message-hidden-headers '()))
653 (notmuch-show \"id:${gen_msg_id}\")
656 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
657 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
659 From: Notmuch Test Suite <test_suite@notmuchmail.org>
660 To: test_suite@notmuchmail.org
661 Subject: Re: Reply within emacs to message from self
663 Fcc: ${MAIL_DIR}/sent
665 --text follows this line--
666 test_suite@notmuchmail.org writes:
668 > This is just a test message (#7)
670 test_expect_equal_file EXPECTED OUTPUT
672 test_begin_subtest "Quote MML tags in reply"
673 message_id='test-emacs-mml-quoting@message.id'
674 add_message [id]="$message_id" \
675 "[subject]='$test_subtest_name'" \
676 '[body]="<#part disposition=inline>"'
677 test_emacs "(let ((message-hidden-headers '()))
678 (notmuch-show \"id:$message_id\")
682 From: Notmuch Test Suite <test_suite@notmuchmail.org>
683 To: test_suite@notmuchmail.org
684 Subject: Re: Quote MML tags in reply
685 In-Reply-To: <test-emacs-mml-quoting@message.id>
686 Fcc: ${MAIL_DIR}/sent
687 References: <test-emacs-mml-quoting@message.id>
688 --text follows this line--
689 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
691 > <#!part disposition=inline>
693 test_expect_equal_file EXPECTED OUTPUT
695 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
696 # save as archive to test that Emacs does not re-compress .gz
697 test_emacs '(let ((standard-input "\"attachment1.gz\""))
698 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
699 (notmuch-show-save-attachments))'
700 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
702 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
703 # save as archive to test that Emacs does not re-compress .gz
704 test_emacs '(let ((standard-input "\"attachment2.gz\""))
705 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
706 (search-forward "0001-Deal-with")
707 (notmuch-show-save-part))'
708 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
710 test_begin_subtest "Save 8bit attachment from within emacs using notmuch-show-save-attachments"
712 add_message '[subject]="Attachment with 8bit chars"' \
713 '[header]="MIME-Version: 1.0"' \
714 '[content-type]="multipart/mixed; boundary=\"abcd\""' \
716 Content-Type: text/plain
721 Content-Type: application/octet-stream; name=\"sample\"
722 Content-Transfer-Encoding: 8bit
723 Content-Disposition: attachment; filename=\"sample\"
725 “¡ Hey ! It compiles ¡ Ship it !”
729 test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
730 (delete-file "OUTPUT")
731 (let ((standard-input "\"OUTPUT\""))
732 (notmuch-show-save-attachments))'
734 test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
736 test_begin_subtest "View raw message within emacs"
737 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
738 (notmuch-show-view-raw-message)
740 test_expect_equal_file $EXPECTED/raw-message-cf0c4d-52ad0a OUTPUT
742 test_begin_subtest "Hiding/showing signature in notmuch-show view"
743 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
744 test_emacs "(notmuch-show \"$maildir_storage_thread\")
745 (search-forward \"Click/Enter to show.\")
746 (button-activate (button-at (point)))
747 (search-backward \"Click/Enter to hide.\")
748 (button-activate (button-at (point)))
750 test_expect_equal_file $EXPECTED/notmuch-show-thread-maildir-storage OUTPUT
752 test_begin_subtest "Detection and hiding of top-post quoting of message"
753 add_message '[subject]="The problem with top-posting"' \
754 [id]=top-post-target \
755 '[body]="A: Because it messes up the order in which people normally read text.
756 Q: Why is top-posting such a bad thing?
758 Q: What is the most annoying thing in e-mail?"'
759 add_message '[from]="Top Poster <top@poster.com>"' \
760 [in-reply-to]=top-post-target \
761 [references]=top-post-target \
762 '[subject]="Re: The problem with top-posting"' \
763 '[body]="Thanks for the advice! I will be sure to put it to good use.
767 ----- Original Message -----
768 From: Notmuch Test Suite <test_suite@notmuchmail.org>
769 To: Notmuch Test Suite <test_suite@notmuchmai.org>
770 Sent: Fri, 05 Jan 2001 15:43:57 +0000
771 Subject: The problem with top-posting
773 Q: Why is top-posting such a bad thing?
775 Q: What is the most annoying thing in e-mail?"'
776 test_emacs "(notmuch-show \"top-posting\")
777 (test-visible-output \"OUTPUT.raw\")"
778 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
779 Subject: The problem with top-posting
780 To: Notmuch Test Suite <test_suite@notmuchmail.org>
783 A: Because it messes up the order in which people normally read text.
784 Q: Why is top-posting such a bad thing?
786 Q: What is the most annoying thing in e-mail?
787 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
788 Subject: Re: The problem with top-posting
789 To: Notmuch Test Suite <test_suite@notmuchmail.org>
792 Thanks for the advice! I will be sure to put it to good use.
796 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
797 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
798 test_expect_equal_file EXPECTED OUTPUT
800 test_begin_subtest "Hiding message in notmuch-show view"
801 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
802 (notmuch-show-toggle-message)
803 (test-visible-output)'
804 test_expect_equal_file $EXPECTED/notmuch-show-thread-with-hidden-messages OUTPUT
806 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
807 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
808 (search-forward "Click/Enter to show.")
809 (button-activate (button-at (point)))
810 (notmuch-show-toggle-message)
811 (test-visible-output)'
812 test_expect_equal_file $EXPECTED/notmuch-show-thread-with-hidden-messages OUTPUT
814 test_begin_subtest "notmuch-show: show message headers"
816 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
817 (notmuch-message-headers-visible t))
818 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
819 (test-visible-output))'
820 test_expect_equal_file $EXPECTED/notmuch-show-message-with-headers-visible OUTPUT
822 test_begin_subtest "notmuch-show: hide message headers"
824 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
825 (notmuch-message-headers-visible nil))
826 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
827 (test-visible-output))'
828 test_expect_equal_file $EXPECTED/notmuch-show-message-with-headers-hidden OUTPUT
830 test_begin_subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-visibility-headers)"
832 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
833 (notmuch-message-headers-visible t))
834 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
835 (notmuch-show-toggle-visibility-headers)
836 (test-visible-output))'
837 test_expect_equal_file $EXPECTED/notmuch-show-message-with-headers-hidden OUTPUT
839 test_begin_subtest "notmuch-show: collapse all messages in thread"
840 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
841 (let ((current-prefix-arg t))
842 (notmuch-show-open-or-close-all)
843 (test-visible-output))'
844 test_expect_equal_file $EXPECTED/notmuch-show-thread-with-all-messages-collapsed OUTPUT
846 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
847 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
848 (notmuch-show-open-or-close-all)
849 (test-visible-output)'
850 test_expect_equal_file $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed OUTPUT
852 test_begin_subtest "Stashing in notmuch-show"
853 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
854 '[from]="Some One <someone@somewhere.org>"' \
855 '[to]="Some One Else <notsomeone@somewhere.org>"' \
856 '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
857 '[subject]="Stash my stashables"' \
859 '[body]="Unable to stash body. Where did you get it in the first place?!?"'
860 notmuch tag +stashtest id:${gen_msg_id}
861 test_emacs '(notmuch-show "id:\"bought\"")
862 (notmuch-show-stash-date)
863 (notmuch-show-stash-from)
864 (notmuch-show-stash-to)
865 (notmuch-show-stash-cc)
866 (notmuch-show-stash-subject)
867 (notmuch-show-stash-message-id)
868 (notmuch-show-stash-message-id-stripped)
869 (notmuch-show-stash-tags)
870 (notmuch-show-stash-filename)
871 (notmuch-show-stash-mlarchive-link "Gmane")
872 (notmuch-show-stash-mlarchive-link "MARC")
873 (notmuch-show-stash-mlarchive-link "Mail Archive, The")
875 (generate-new-buffer "*test-stashing*"))
879 (rotate-yank-pointer 1))
880 (reverse-region (point-min) (point-max))
883 Sat, 01 Jan 2000 12:00:00 +0000
884 Some One <someone@somewhere.org>
885 Some One Else <notsomeone@somewhere.org>
886 Notmuch <notmuch@notmuchmail.org>
892 https://mid.gmane.org/bought
893 https://marc.info/?i=bought
894 https://mid.mail-archive.com/bought
896 test_expect_equal_file EXPECTED OUTPUT
898 test_begin_subtest "Stashing in notmuch-search"
899 test_emacs '(notmuch-search "id:\"bought\"")
901 (notmuch-search-stash-thread-id)
903 (generate-new-buffer "*test-stashing*"))
906 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
907 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
909 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
910 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
911 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
912 test_emacs "(notmuch-show \"$message2\")
913 (test-output \"EXPECTED\")"
914 test_emacs "(notmuch-search \"$message1 or $message2\")
916 (notmuch-search-show-thread)
917 (goto-char (point-max))
919 (notmuch-show-advance-and-archive)
921 test_expect_equal_file EXPECTED OUTPUT
923 test_begin_subtest "Refresh show buffer"
924 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
925 (test-visible-output "EXPECTED")
926 (notmuch-show-refresh-view)
927 (test-visible-output)'
928 test_expect_equal_file EXPECTED OUTPUT
930 test_begin_subtest "Refresh modified show buffer"
931 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
932 (notmuch-show-toggle-message)
933 (notmuch-show-next-message)
934 (notmuch-show-toggle-message)
935 (test-visible-output "EXPECTED")
936 (notmuch-show-refresh-view)
937 (test-visible-output)'
938 test_expect_equal_file EXPECTED OUTPUT
940 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
941 id='message-with-application/mpeg-attachment@notmuchmail.org'
943 'Message with application/mpeg attachment' \
946 (insert \"Message-ID: <$id>\n\")
948 (mml-insert-part \"application/mpeg\")
949 (insert \"a fake mp3 file\")"
950 notmuch_counter_reset
951 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
952 (notmuch-show \"id:$id\"))"
953 test_expect_equal $(notmuch_counter_value) 1
955 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
956 id='message-with-audio/mpeg-attachment@notmuchmail.org'
958 'Message with audio/mpeg attachment' \
961 (insert \"Message-ID: <$id>\n\")
963 (mml-insert-part \"audio/mpeg\")
964 (insert \"a fake mp3 file\")"
965 notmuch_counter_reset
966 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
967 (notmuch-show \"id:$id\"))"
968 test_expect_equal $(notmuch_counter_value) 1
970 test_begin_subtest "notmuch-hello-mode hook is called"
971 counter=$(test_emacs \
972 '(let ((notmuch-hello-mode-hook-counter 0))
973 (kill-buffer "*notmuch-hello*")
975 notmuch-hello-mode-hook-counter)'
977 test_expect_equal "$counter" 1
979 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
980 counter=$(test_emacs \
981 '(let ((notmuch-hello-mode-hook-counter 0))
982 (kill-buffer "*notmuch-hello*")
984 (notmuch-hello-update)
985 notmuch-hello-mode-hook-counter)'
987 test_expect_equal "$counter" 1
989 test_begin_subtest "notmuch-hello-refresh hook is called"
990 counter=$(test_emacs \
991 '(let ((notmuch-hello-refresh-hook-counter 0))
992 (kill-buffer "*notmuch-hello*")
994 notmuch-hello-refresh-hook-counter)'
996 test_expect_equal "$counter" 1
998 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
999 counter=$(test_emacs \
1000 '(let ((notmuch-hello-refresh-hook-counter 0))
1001 (kill-buffer "*notmuch-hello*")
1003 (notmuch-hello-update)
1004 notmuch-hello-refresh-hook-counter)'
1006 test_expect_equal "$counter" 2
1009 add_message '[subject]="HTML mail with images"' \
1010 '[content-type]="multipart/related; boundary=abcd"' \
1012 Content-Type: text/html
1014 <img src="cid:330@goomoji.gmail"> smiley
1017 Content-Type: image/gif
1018 Content-Transfer-Encoding: base64
1019 Content-ID: <330@goomoji.gmail>
1021 R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMl
1022 WLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7
1024 test_emacs "(let ((mm-text-html-renderer
1025 (if (assq 'shr mm-text-html-renderer-alist)
1027 (notmuch-show \"id:${gen_msg_id}\"))
1028 (test-output)" > /dev/null
1029 # Different Emacs versions and renderers give very different results,
1030 # so just check that something reasonable showed up. We first cat the
1031 # output so the test framework will print it if the test fails.
1032 test_begin_subtest "Rendering HTML mail with images"
1033 test_expect_success 'cat OUTPUT && grep -q smiley OUTPUT'
1035 test_begin_subtest "Search handles subprocess error exit codes"
1036 cat > notmuch_fail <<EOF
1041 chmod a+x notmuch_fail
1042 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
1043 (with-current-buffer \"*Messages*\"
1044 (let ((inhibit-read-only t)) (erase-buffer)))
1045 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
1047 (notmuch-search \"tag:inbox\")
1049 (with-current-buffer \"*Messages*\"
1050 (test-output \"MESSAGES\"))
1051 (with-current-buffer \"*Notmuch errors*\"
1052 (test-output \"ERROR\"))
1055 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
1057 End of search results.
1059 YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
1062 YYY/notmuch_fail exited with status 1
1063 command: YYY/notmuch_fail search --format\=sexp --format-version\=4 --sort\=newest-first tag\:inbox
1066 test_begin_subtest "Search handles subprocess warnings"
1067 cat > notmuch_fail <<EOF
1070 echo This is a warning >&2
1071 echo This is another warning >&2
1074 chmod a+x notmuch_fail
1075 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
1076 (with-current-buffer \"*Messages*\"
1077 (let ((inhibit-read-only t)) (erase-buffer)))
1078 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
1080 (notmuch-search \"tag:inbox\")
1082 (with-current-buffer \"*Messages*\"
1083 (test-output \"MESSAGES\"))
1084 (with-current-buffer \"*Notmuch errors*\"
1085 (test-output \"ERROR\"))
1087 sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
1088 test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
1089 End of search results.
1091 This is a warning (see *Notmuch errors* for more details)
1095 This is another warning"
1097 test_begin_subtest "Search thread tag operations are race-free"
1098 add_message '[subject]="Search race test"'
1099 gen_msg_id_1=$gen_msg_id
1100 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
1101 '[references]="<'$gen_msg_id_1'>"' \
1102 '[subject]="Search race test two"'
1103 test_emacs '(notmuch-search "subject:\"search race test\"")
1106 (execute-kbd-macro "+search-thread-race-tag")'
1107 output=$(notmuch search --output=messages 'tag:search-thread-race-tag')
1108 test_expect_equal "$output" "id:$gen_msg_id_1"
1110 test_begin_subtest "Search global tag operations are race-free"
1111 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
1112 '[references]="<'$gen_msg_id_1'>"' \
1113 '[subject]="Re: Search race test"'
1114 test_emacs '(notmuch-search "subject:\"search race test\" -subject:two")
1117 (execute-kbd-macro "*+search-global-race-tag")'
1118 output=$(notmuch search --output=messages 'tag:search-global-race-tag')
1119 test_expect_equal "$output" "id:$gen_msg_id_1"
1121 test_begin_subtest "Term escaping"
1122 output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
1124 \"abc\`~\!@#\$%^&*-=_+123\"
1129 \"\\x201cxyz\\x201d\"))")
1130 test_expect_equal "$output" '("\"\"" "abc`~!@#$%^&*-=_+123" "\"(abc\"" "\")abc\"" "\"\"\"abc\"" "\"'$'\x01''xyz\"" "\"“xyz”\"")'
1132 test_begin_subtest "Sending a message calls the send message hooks"
1133 emacs_deliver_message \
1134 'Testing message sending hooks' \
1135 'This is a test of the message sending hooks.' \
1138 (insert \"To: user@example.com\n\")
1139 (add-hook 'notmuch-mua-send-hook (lambda () (goto-char (point-max)) (insert \"\nThis text added by the hook.\")))"
1141 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
1142 -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
1144 From: Notmuch Test Suite <test_suite@notmuchmail.org>
1145 To: user@example.com
1146 Subject: Testing message sending hooks
1147 Date: 01 Jan 2000 12:00:00 -0000
1150 Content-Type: text/plain
1152 This is a test of the message sending hooks.
1153 This text added by the hook.
1155 test_expect_equal_file EXPECTED OUTPUT