3 test_description="emacs interface"
4 . ./test-lib.sh || exit 1
6 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
10 # syntax errors in test-lib.el cause mysterious failures
11 test_expect_success 'Syntax of emacs test library' \
12 "${TEST_EMACS} -Q --batch --load $TEST_DIRECTORY/test-lib.el"
14 test_begin_subtest "Basic notmuch-hello view in emacs"
15 test_emacs '(notmuch-hello)
17 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
19 test_begin_subtest "Saved search with 0 results"
20 test_emacs '(let ((notmuch-show-empty-saved-searches t)
21 (notmuch-saved-searches
22 '\''(("inbox" . "tag:inbox")
23 ("unread" . "tag:unread")
24 ("empty" . "tag:doesnotexist"))))
27 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
29 test_begin_subtest "No saved searches displayed (all with 0 results)"
30 test_emacs '(let ((notmuch-saved-searches
31 '\''(("empty" . "tag:doesnotexist"))))
34 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
36 test_begin_subtest "Basic notmuch-search view in emacs"
37 test_emacs '(notmuch-search "tag:inbox")
40 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
42 test_begin_subtest "Incremental parsing of search results"
43 test_emacs "(ad-enable-advice 'notmuch-search-process-filter 'around 'pessimal)
44 (ad-activate 'notmuch-search-process-filter)
45 (notmuch-search \"tag:inbox\")
47 (ad-disable-advice 'notmuch-search-process-filter 'around 'pessimal)
48 (ad-activate 'notmuch-search-process-filter)
50 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
52 test_begin_subtest "Navigation of notmuch-hello to search results"
53 test_emacs '(notmuch-hello)
54 (goto-char (point-min))
55 (re-search-forward "inbox")
56 (widget-button-press (1- (point)))
59 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
61 test_begin_subtest "Basic notmuch-show view in emacs"
62 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
63 test_emacs "(notmuch-show \"$maildir_storage_thread\")
65 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
67 test_begin_subtest "Basic notmuch-show view in emacs default indentation"
68 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
69 test_emacs "(let ((notmuch-show-indent-messages-width 1))
70 (notmuch-show \"$maildir_storage_thread\")
72 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
74 test_begin_subtest "Basic notmuch-show view in emacs without indentation"
75 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
76 test_emacs "(let ((notmuch-show-indent-messages-width 0))
77 (notmuch-show \"$maildir_storage_thread\")
79 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation
81 test_begin_subtest "Basic notmuch-show view in emacs with fourfold indentation"
82 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
83 test_emacs "(let ((notmuch-show-indent-messages-width 4))
84 (notmuch-show \"$maildir_storage_thread\")
86 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation
88 test_begin_subtest "notmuch-show for message with invalid From"
89 add_message "[subject]=\"message-with-invalid-from\"" \
90 "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
91 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
92 test_emacs "(notmuch-show \"$thread\")
93 (test-output \"OUTPUT.raw\")"
95 "Invalid " (2001-01-05) (inbox)
96 Subject: message-with-invalid-from
97 To: Notmuch Test Suite <test_suite@notmuchmail.org>
100 This is just a test message (#1)
102 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
103 test_expect_equal_file OUTPUT EXPECTED
105 test_begin_subtest "Navigation of notmuch-search to thread view"
106 test_emacs '(notmuch-search "tag:inbox")
108 (goto-char (point-min))
109 (re-search-forward "Working with Maildir")
110 (notmuch-search-show-thread)
113 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
115 test_begin_subtest "Add tag from search view"
116 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
117 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
119 (execute-kbd-macro \"+tag-from-search-view\")"
120 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
121 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)"
123 test_begin_subtest "Remove tag from search view"
124 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
126 (execute-kbd-macro \"-tag-from-search-view\")"
127 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
128 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)"
130 test_begin_subtest "Add tag (large query)"
131 # We use a long query to force us into batch mode and use a funny tag
132 # that requires escaping for batch tagging.
133 test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (mapconcat #'identity (make-list notmuch-tag-argument-limit \"x\") \"-\")) (list \"+tag-from-%-large-query\"))"
134 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
135 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)"
136 notmuch tag -tag-from-%-large-query $os_x_darwin_thread
138 test_begin_subtest "notmuch-show: add single tag to single message"
139 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
140 (execute-kbd-macro \"+tag-from-show-view\")"
141 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
142 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)"
144 test_begin_subtest "notmuch-show: remove single tag from single message"
145 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
146 (execute-kbd-macro \"-tag-from-show-view\")"
147 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
148 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)"
150 test_begin_subtest "notmuch-show: add multiple tags to single message"
151 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
152 (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
153 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
154 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)"
156 test_begin_subtest "notmuch-show: remove multiple tags from single message"
157 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
158 (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
159 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
160 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)"
162 test_begin_subtest "Message with .. in Message-Id:"
163 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
164 test_emacs '(notmuch-search "id:\"123..456@example\"")
166 (execute-kbd-macro "+search-add")
167 (execute-kbd-macro "+search-remove")
168 (execute-kbd-macro "-search-remove")
169 (notmuch-show "id:\"123..456@example\"")
171 (execute-kbd-macro "+show-add")
172 (execute-kbd-macro "+show-remove")
173 (execute-kbd-macro "-show-remove")'
174 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
175 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
177 test_begin_subtest "Message with quote in Message-Id:"
178 add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
179 test_emacs '(notmuch-search "subject:\"Message with quote\"")
181 (execute-kbd-macro "+search-add")
182 (notmuch-search-show-thread)
184 (execute-kbd-macro "+show-add")'
185 output=$(notmuch search 'id:"""quote""@example"' | notmuch_search_sanitize)
186 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)"
188 test_begin_subtest "Sending a message via (fake) SMTP"
189 emacs_deliver_message \
190 'Testing message sent via SMTP' \
191 'This is a test that messages are sent via SMTP' \
194 (insert "To: user@example.com\n")'
196 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
197 -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
199 From: Notmuch Test Suite <test_suite@notmuchmail.org>
201 Subject: Testing message sent via SMTP
202 Date: 01 Jan 2000 12:00:00 -0000
205 Content-Type: text/plain
207 This is a test that messages are sent via SMTP
209 test_expect_equal_file OUTPUT EXPECTED
211 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
212 notmuch new > /dev/null
213 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
214 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
216 test_begin_subtest "notmuch-fcc-dirs set to nil"
217 test_emacs "(let ((notmuch-fcc-dirs nil))
221 From: Notmuch Test Suite <test_suite@notmuchmail.org>
224 --text follows this line--
226 test_expect_equal_file OUTPUT EXPECTED
228 # Make another FCC maildir specific for the next test
229 mkdir -p mail/sent-string/cur
230 mkdir -p mail/sent-string/new
231 mkdir -p mail/sent-string/tmp
233 test_begin_subtest "notmuch-fcc-dirs set to a string"
234 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
238 From: Notmuch Test Suite <test_suite@notmuchmail.org>
241 Fcc: ${MAIL_DIR}/sent-string
242 --text follows this line--
244 test_expect_equal_file OUTPUT EXPECTED
246 # Make more FCC maildirs specific for the next test
247 mkdir -p mail/sent-list-match/cur
248 mkdir -p mail/sent-list-match/new
249 mkdir -p mail/sent-list-match/tmp
250 mkdir -p mail/failure/cur
251 mkdir -p mail/failure/new
252 mkdir -p mail/failure/tmp
254 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
255 test_emacs "(let ((notmuch-fcc-dirs
256 '((\"notmuchmail.org\" . \"sent-list-match\")
257 (\".*\" . \"failure\"))))
261 From: Notmuch Test Suite <test_suite@notmuchmail.org>
264 Fcc: ${MAIL_DIR}/sent-list-match
265 --text follows this line--
267 test_expect_equal_file OUTPUT EXPECTED
269 # Make another FCC maildir specific for the next test
270 mkdir -p mail/sent-list-catch-all/cur
271 mkdir -p mail/sent-list-catch-all/new
272 mkdir -p mail/sent-list-catch-all/tmp
274 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
275 test_emacs "(let ((notmuch-fcc-dirs
276 '((\"example.com\" . \"failure\")
277 (\".*\" . \"sent-list-catch-all\"))))
281 From: Notmuch Test Suite <test_suite@notmuchmail.org>
284 Fcc: ${MAIL_DIR}/sent-list-catch-all
285 --text follows this line--
287 test_expect_equal_file OUTPUT EXPECTED
289 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
290 test_emacs "(let ((notmuch-fcc-dirs
291 '((\"example.com\" . \"failure\")
292 (\"nomatchhere.net\" . \"failure\"))))
296 From: Notmuch Test Suite <test_suite@notmuchmail.org>
299 --text follows this line--
301 test_expect_equal_file OUTPUT EXPECTED
303 test_begin_subtest "Reply within emacs"
304 test_emacs '(let ((message-hidden-headers ''()))
305 (notmuch-search "subject:\"testing message sent via SMTP\"")
307 (notmuch-search-reply-to-thread)
309 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
310 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
312 From: Notmuch Test Suite <test_suite@notmuchmail.org>
314 Subject: Re: Testing message sent via SMTP
316 Fcc: ${MAIL_DIR}/sent
318 --text follows this line--
319 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
321 > This is a test that messages are sent via SMTP
323 test_expect_equal_file OUTPUT EXPECTED
325 test_begin_subtest "Reply from alternate address within emacs"
326 add_message '[from]="Sender <sender@example.com>"' \
327 [to]=test_suite_other@notmuchmail.org
329 test_emacs "(let ((message-hidden-headers '()))
330 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
332 (notmuch-search-reply-to-thread)
335 From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
336 To: Sender <sender@example.com>
337 Subject: Re: ${test_subtest_name}
338 In-Reply-To: <${gen_msg_id}>
339 Fcc: ${MAIL_DIR}/sent
340 References: <${gen_msg_id}>
341 --text follows this line--
342 Sender <sender@example.com> writes:
344 > This is just a test message (#${gen_msg_cnt})
346 test_expect_equal_file OUTPUT EXPECTED
348 test_begin_subtest "Reply from address in named group list within emacs"
349 add_message '[from]="Sender <sender@example.com>"' \
350 '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
351 [cc]=test_suite_other@notmuchmail.org
353 test_emacs "(let ((message-hidden-headers '()))
354 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
356 (notmuch-search-reply-to-thread)
359 From: Notmuch Test Suite <test_suite@notmuchmail.org>
360 To: Sender <sender@example.com>, someone@example.com
361 Subject: Re: ${test_subtest_name}
362 In-Reply-To: <${gen_msg_id}>
363 Fcc: ${MAIL_DIR}/sent
364 References: <${gen_msg_id}>
365 --text follows this line--
366 Sender <sender@example.com> writes:
368 > This is just a test message (#${gen_msg_cnt})
370 test_expect_equal_file OUTPUT EXPECTED
372 test_begin_subtest "Reply within emacs to a multipart/mixed message"
373 test_emacs '(let ((message-hidden-headers ''()))
374 (notmuch-show "id:20091118002059.067214ed@hikari")
378 From: Notmuch Test Suite <test_suite@notmuchmail.org>
379 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
380 Subject: Re: [notmuch] Introducing myself
381 In-Reply-To: <20091118002059.067214ed@hikari>
382 Fcc: ${MAIL_DIR}/sent
383 References: <20091118002059.067214ed@hikari>
384 --text follows this line--
385 Adrian Perez de Castro <aperez@igalia.com> writes:
387 > [ Unknown signature status ]
391 > I have just heard about Not Much today in some random Linux-related news
392 > site (LWN?), my name is Adrian Perez and I work as systems administrator
393 > (although I can do some code as well :P). I have always thought that the
394 > ideas behind Sup were great, but after some time using it, I got tired of
395 > the oddities that it has. I also do not like doing things like having to
396 > install Ruby just for reading and sorting mails. Some time ago I thought
397 > about doing something like Not Much and in fact I played a bit with the
398 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
399 > to code things in Python when I am not working and also it is installed
400 > by default on most distribution. I got to have some mailboxes indexed and
401 > basic searching working a couple of months ago. Lately I have been very
402 > busy and had no time for coding, and them... boom! Not Much appears -- and
403 > it is almost exactly what I was trying to do, but faster. I have been
404 > playing a bit with Not Much today, and I think it has potential.
406 > Also, I would like to share one idea I had in mind, that you might find
407 > interesting: One thing I have found very annoying is having to re-tag my
408 > mail when the indexes get b0rked (it happened a couple of times to me while
409 > using Sup), so I was planning to mails as read/unread and adding the tags
410 > not just to the index, but to the mail text itself, e.g. by adding a
411 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
412 > could be totally recreated by re-reading the mail directories, and this
413 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
414 > local maildir, tagging and indexing the mails with the e-mail reader and
415 > then syncing back the messages with the "X-Tags" header to the IMAP server.
416 > This would allow to use the mail reader from a different computer and still
417 > have everything tagged finely.
423 > [1] http://software.complete.org/software/projects/show/offlineimap
426 > Adrian Perez de Castro <aperez@igalia.com>
427 > Igalia - Free Software Engineering
428 > _______________________________________________
429 > notmuch mailing list
430 > notmuch@notmuchmail.org
431 > http://notmuchmail.org/mailman/listinfo/notmuch
433 test_expect_equal_file OUTPUT EXPECTED
435 test_begin_subtest "Reply within emacs to a multipart/alternative message"
436 test_emacs '(let ((message-hidden-headers ''()))
437 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
441 From: Notmuch Test Suite <test_suite@notmuchmail.org>
442 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
443 Subject: Re: [notmuch] preliminary FreeBSD support
444 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
445 Fcc: ${MAIL_DIR}/sent
446 References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
447 --text follows this line--
448 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
450 > I saw the announcement this morning, and was very excited, as I had been
451 > hoping sup would be turned into a library,
452 > since I like the concept more than the UI (I'd rather an emacs interface).
454 > I did a preliminary compile which worked out fine, but
455 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
456 > FreeBSD, so notmuch_config_open segfaulted.
458 > Attached is a patch that supplies a default buffer size of 64 in cases where
461 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
462 > is acceptable behavior,
463 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
466 > From e3bc4bbd7b9d0d086816ab5f8f2d6ffea1dd3ea4 Mon Sep 17 00:00:00 2001
467 > From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>
468 > Date: Tue, 17 Nov 2009 11:30:39 -0800
469 > Subject: [PATCH] Deal with situation where sysconf(_SC_GETPW_R_SIZE_MAX) returns -1
472 > notmuch-config.c | 2 ++
473 > 1 files changed, 2 insertions(+), 0 deletions(-)
475 > diff --git a/notmuch-config.c b/notmuch-config.c
476 > index 248149c..e7220d8 100644
477 > --- a/notmuch-config.c
478 > +++ b/notmuch-config.c
479 > @@ -77,6 +77,7 @@ static char *
480 > get_name_from_passwd_file (void *ctx)
482 > long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
483 > + if (pw_buf_size == -1) pw_buf_size = 64;
484 > char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
485 > struct passwd passwd, *ignored;
487 > @@ -101,6 +102,7 @@ static char *
488 > get_username_from_passwd_file (void *ctx)
490 > long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
491 > + if (pw_buf_size == -1) pw_buf_size = 64;
492 > char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
493 > struct passwd passwd, *ignored;
498 > _______________________________________________
499 > notmuch mailing list
500 > notmuch@notmuchmail.org
501 > http://notmuchmail.org/mailman/listinfo/notmuch
503 test_expect_equal_file OUTPUT EXPECTED
505 test_begin_subtest "Reply within emacs to an html-only message"
506 add_message '[content-type]="text/html"' \
507 '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
508 test_emacs "(let ((message-hidden-headers '()))
509 (notmuch-show \"id:${gen_msg_id}\")
513 From: Notmuch Test Suite <test_suite@notmuchmail.org>
515 Subject: Re: Reply within emacs to an html-only message
516 In-Reply-To: <${gen_msg_id}>
517 Fcc: ${MAIL_DIR}/sent
518 References: <${gen_msg_id}>
519 --text follows this line--
520 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
522 > Hi,This is an HTML test message.OK?
524 test_expect_equal_file OUTPUT EXPECTED
526 test_begin_subtest "Quote MML tags in reply"
527 message_id='test-emacs-mml-quoting@message.id'
528 add_message [id]="$message_id" \
529 "[subject]='$test_subtest_name'" \
530 '[body]="<#part disposition=inline>"'
531 test_emacs "(let ((message-hidden-headers '()))
532 (notmuch-show \"id:$message_id\")
536 From: Notmuch Test Suite <test_suite@notmuchmail.org>
538 Subject: Re: Quote MML tags in reply
539 In-Reply-To: <test-emacs-mml-quoting@message.id>
540 Fcc: ${MAIL_DIR}/sent
541 References: <test-emacs-mml-quoting@message.id>
542 --text follows this line--
543 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
545 > <#!part disposition=inline>
547 test_expect_equal_file OUTPUT EXPECTED
549 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
550 # save as archive to test that Emacs does not re-compress .gz
551 test_emacs '(let ((standard-input "\"attachment1.gz\""))
552 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
553 (notmuch-show-save-attachments))'
554 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
556 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
557 # save as archive to test that Emacs does not re-compress .gz
558 test_emacs '(let ((standard-input "\"attachment2.gz\""))
559 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
560 (search-forward "0001-Deal-with")
561 (notmuch-show-save-part))'
562 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
564 test_begin_subtest "Save 8bit attachment from within emacs using notmuch-show-save-attachments"
566 add_message '[subject]="Attachment with 8bit chars"' \
567 '[header]="MIME-Version: 1.0"' \
568 '[content-type]="multipart/mixed; boundary=\"abcd\""' \
570 Content-Type: text/plain
575 Content-Type: application/octet-stream; name=\"sample\"
576 Content-Transfer-Encoding: 8bit
577 Content-Disposition: attachment; filename=\"sample\"
579 “¡ Hey ! It compiles ¡ Ship it !”
583 test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
584 (delete-file "OUTPUT")
585 (let ((standard-input "\"OUTPUT\""))
586 (notmuch-show-save-attachments))'
588 test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
590 test_begin_subtest "View raw message within emacs"
591 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
592 (notmuch-show-view-raw-message)
594 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
596 test_begin_subtest "Hiding/showing signature in notmuch-show view"
597 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
598 test_emacs "(notmuch-show \"$maildir_storage_thread\")
599 (search-forward \"Click/Enter to show.\")
600 (button-activate (button-at (point)))
601 (search-backward \"Click/Enter to hide.\")
602 (button-activate (button-at (point)))
604 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
606 test_begin_subtest "Detection and hiding of top-post quoting of message"
607 add_message '[subject]="The problem with top-posting"' \
608 [id]=top-post-target \
609 '[body]="A: Because it messes up the order in which people normally read text.
610 Q: Why is top-posting such a bad thing?
612 Q: What is the most annoying thing in e-mail?"'
613 add_message '[from]="Top Poster <top@poster.com>"' \
614 [in-reply-to]=top-post-target \
615 [references]=top-post-target \
616 '[subject]="Re: The problem with top-posting"' \
617 '[body]="Thanks for the advice! I will be sure to put it to good use.
621 ----- Original Message -----
622 From: Notmuch Test Suite <test_suite@notmuchmail.org>
623 To: Notmuch Test Suite <test_suite@notmuchmai.org>
624 Sent: Fri, 05 Jan 2001 15:43:57 +0000
625 Subject: The problem with top-posting
627 Q: Why is top-posting such a bad thing?
629 Q: What is the most annoying thing in e-mail?"'
630 test_emacs "(notmuch-show \"top-posting\")
631 (test-visible-output \"OUTPUT.raw\")"
632 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
633 Subject: The problem with top-posting
634 To: Notmuch Test Suite <test_suite@notmuchmail.org>
637 A: Because it messes up the order in which people normally read text.
638 Q: Why is top-posting such a bad thing?
640 Q: What is the most annoying thing in e-mail?
641 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
642 Subject: Re: The problem with top-posting
643 To: Notmuch Test Suite <test_suite@notmuchmail.org>
646 Thanks for the advice! I will be sure to put it to good use.
650 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
651 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
652 test_expect_equal_file OUTPUT EXPECTED
654 test_begin_subtest "Hiding message in notmuch-show view"
655 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
656 (notmuch-show-toggle-message)
657 (test-visible-output)'
658 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
660 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
661 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
662 (search-forward "Click/Enter to show.")
663 (button-activate (button-at (point)))
664 (notmuch-show-toggle-message)
665 (test-visible-output)'
666 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
668 test_begin_subtest "notmuch-show: show message headers"
670 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
671 (notmuch-message-headers-visible t))
672 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
673 (test-visible-output))'
674 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-visible
676 test_begin_subtest "notmuch-show: hide message headers"
678 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
679 (notmuch-message-headers-visible nil))
680 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
681 (test-visible-output))'
682 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
684 test_begin_subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-visibility-headers)"
686 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
687 (notmuch-message-headers-visible t))
688 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
689 (notmuch-show-toggle-visibility-headers)
690 (test-visible-output))'
691 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
693 test_begin_subtest "notmuch-show: collapse all messages in thread"
694 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
695 (let ((current-prefix-arg t))
696 (notmuch-show-open-or-close-all)
697 (test-visible-output))'
698 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-collapsed
700 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
701 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
702 (notmuch-show-open-or-close-all)
703 (test-visible-output)'
704 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed
706 test_begin_subtest "Stashing in notmuch-show"
707 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
708 '[from]="Some One <someone@somewhere.org>"' \
709 '[to]="Some One Else <notsomeone@somewhere.org>"' \
710 '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
711 '[subject]="Stash my stashables"' \
713 '[body]="Unable to stash body. Where did you get it in the first place?!?"'
714 notmuch tag +stashtest id:${gen_msg_id}
715 test_emacs '(notmuch-show "id:\"bought\"")
716 (notmuch-show-stash-date)
717 (notmuch-show-stash-from)
718 (notmuch-show-stash-to)
719 (notmuch-show-stash-cc)
720 (notmuch-show-stash-subject)
721 (notmuch-show-stash-message-id)
722 (notmuch-show-stash-message-id-stripped)
723 (notmuch-show-stash-tags)
724 (notmuch-show-stash-filename)
725 (notmuch-show-stash-mlarchive-link "Gmane")
726 (notmuch-show-stash-mlarchive-link "MARC")
727 (notmuch-show-stash-mlarchive-link "Mail Archive, The")
729 (generate-new-buffer "*test-stashing*"))
733 (rotate-yank-pointer 1))
734 (reverse-region (point-min) (point-max))
737 Sat, 01 Jan 2000 12:00:00 +0000
738 Some One <someone@somewhere.org>
739 Some One Else <notsomeone@somewhere.org>
740 Notmuch <notmuch@notmuchmail.org>
746 http://mid.gmane.org/bought
747 https://marc.info/?i=bought
748 https://mid.mail-archive.com/bought
750 test_expect_equal_file OUTPUT EXPECTED
752 test_begin_subtest "Stashing in notmuch-search"
753 test_emacs '(notmuch-search "id:\"bought\"")
755 (notmuch-search-stash-thread-id)
757 (generate-new-buffer "*test-stashing*"))
760 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
761 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
763 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
764 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
765 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
766 test_emacs "(notmuch-show \"$message2\")
767 (test-output \"EXPECTED\")"
768 test_emacs "(notmuch-search \"$message1 or $message2\")
770 (notmuch-search-show-thread)
771 (goto-char (point-max))
773 (notmuch-show-advance-and-archive)
775 test_expect_equal_file OUTPUT EXPECTED
777 test_begin_subtest "Refresh show buffer"
778 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
779 (test-visible-output "EXPECTED")
780 (notmuch-show-refresh-view)
781 (test-visible-output)'
782 test_expect_equal_file OUTPUT EXPECTED
784 test_begin_subtest "Refresh modified show buffer"
785 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
786 (notmuch-show-toggle-message)
787 (notmuch-show-next-message)
788 (notmuch-show-toggle-message)
789 (test-visible-output "EXPECTED")
790 (notmuch-show-refresh-view)
791 (test-visible-output)'
792 test_expect_equal_file OUTPUT EXPECTED
794 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
795 id='message-with-application/mpeg-attachment@notmuchmail.org'
797 'Message with application/mpeg attachment' \
800 (insert \"Message-ID: <$id>\n\")
802 (mml-insert-part \"application/mpeg\")
803 (insert \"a fake mp3 file\")"
804 notmuch_counter_reset
805 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
806 (notmuch-show \"id:$id\"))"
807 test_expect_equal $(notmuch_counter_value) 1
809 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
810 id='message-with-audio/mpeg-attachment@notmuchmail.org'
812 'Message with audio/mpeg attachment' \
815 (insert \"Message-ID: <$id>\n\")
817 (mml-insert-part \"audio/mpeg\")
818 (insert \"a fake mp3 file\")"
819 notmuch_counter_reset
820 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
821 (notmuch-show \"id:$id\"))"
822 test_expect_equal $(notmuch_counter_value) 1
824 test_begin_subtest "notmuch-hello-mode hook is called"
825 counter=$(test_emacs \
826 '(let ((notmuch-hello-mode-hook-counter 0))
827 (kill-buffer "*notmuch-hello*")
829 notmuch-hello-mode-hook-counter)'
831 test_expect_equal "$counter" 1
833 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
834 counter=$(test_emacs \
835 '(let ((notmuch-hello-mode-hook-counter 0))
836 (kill-buffer "*notmuch-hello*")
838 (notmuch-hello-update)
839 notmuch-hello-mode-hook-counter)'
841 test_expect_equal "$counter" 1
843 test_begin_subtest "notmuch-hello-refresh hook is called"
844 counter=$(test_emacs \
845 '(let ((notmuch-hello-refresh-hook-counter 0))
846 (kill-buffer "*notmuch-hello*")
848 notmuch-hello-refresh-hook-counter)'
850 test_expect_equal "$counter" 1
852 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
853 counter=$(test_emacs \
854 '(let ((notmuch-hello-refresh-hook-counter 0))
855 (kill-buffer "*notmuch-hello*")
857 (notmuch-hello-update)
858 notmuch-hello-refresh-hook-counter)'
860 test_expect_equal "$counter" 2
863 add_message '[subject]="HTML mail with images"' \
864 '[content-type]="multipart/related; boundary=abcd"' \
866 Content-Type: text/html
868 <img src="cid:330@goomoji.gmail"> smiley
871 Content-Type: image/gif
872 Content-Transfer-Encoding: base64
873 Content-ID: <330@goomoji.gmail>
875 R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMl
876 WLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7
878 test_emacs "(let ((mm-text-html-renderer
879 (if (assq 'shr mm-text-html-renderer-alist)
881 (notmuch-show \"id:${gen_msg_id}\"))
882 (test-output)" > /dev/null
883 # Different Emacs versions and renderers give very different results,
884 # so just check that something reasonable showed up. We first cat the
885 # output so the test framework will print it if the test fails.
886 test_expect_success "Rendering HTML mail with images" \
887 'cat OUTPUT && grep -q smiley OUTPUT'
890 test_begin_subtest "Search handles subprocess error exit codes"
891 cat > notmuch_fail <<EOF
896 chmod a+x notmuch_fail
897 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
898 (with-current-buffer \"*Messages*\"
899 (let ((inhibit-read-only t)) (erase-buffer)))
900 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
902 (notmuch-search \"tag:inbox\")
904 (with-current-buffer \"*Messages*\"
905 (test-output \"MESSAGES\"))
906 (with-current-buffer \"*Notmuch errors*\"
907 (test-output \"ERROR\"))
910 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
912 End of search results.
914 YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
917 YYY/notmuch_fail exited with status 1
918 command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox
921 test_begin_subtest "Search handles subprocess warnings"
922 cat > notmuch_fail <<EOF
925 echo This is a warning >&2
926 echo This is another warning >&2
929 chmod a+x notmuch_fail
930 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
931 (with-current-buffer \"*Messages*\"
932 (let ((inhibit-read-only t)) (erase-buffer)))
933 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
935 (notmuch-search \"tag:inbox\")
937 (with-current-buffer \"*Messages*\"
938 (test-output \"MESSAGES\"))
939 (with-current-buffer \"*Notmuch errors*\"
940 (test-output \"ERROR\"))
942 sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
943 test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
944 End of search results.
946 This is a warning (see *Notmuch errors* for more details)
950 This is another warning"
952 test_begin_subtest "Search thread tag operations are race-free"
953 add_message '[subject]="Search race test"'
954 gen_msg_id_1=$gen_msg_id
955 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
956 '[references]="<'$gen_msg_id_1'>"' \
957 '[subject]="Search race test two"'
958 test_emacs '(notmuch-search "subject:\"search race test\"")
961 (execute-kbd-macro "+search-thread-race-tag")'
962 output=$(notmuch search --output=messages 'tag:search-thread-race-tag')
963 test_expect_equal "$output" "id:$gen_msg_id_1"
965 test_begin_subtest "Search global tag operations are race-free"
966 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
967 '[references]="<'$gen_msg_id_1'>"' \
968 '[subject]="Re: Search race test"'
969 test_emacs '(notmuch-search "subject:\"search race test\" -subject:two")
972 (execute-kbd-macro "*+search-global-race-tag")'
973 output=$(notmuch search --output=messages 'tag:search-global-race-tag')
974 test_expect_equal "$output" "id:$gen_msg_id_1"
976 test_begin_subtest "Term escaping"
977 output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
979 \"abc\`~\!@#\$%^&*-=_+123\"
984 \"\\x201cxyz\\x201d\"))")
985 test_expect_equal "$output" '("\"\"" "abc`~!@#$%^&*-=_+123" "\"(abc\"" "\")abc\"" "\"\"\"abc\"" "\"'$'\x01''xyz\"" "\"“xyz”\"")'