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