3 test_description="emacs interface"
6 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
10 test_begin_subtest "Basic notmuch-hello view in emacs"
11 test_emacs '(notmuch-hello)
13 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
15 test_begin_subtest "Saved search with 0 results"
16 test_emacs '(let ((notmuch-show-empty-saved-searches t)
17 (notmuch-saved-searches
18 '\''(("inbox" . "tag:inbox")
19 ("unread" . "tag:unread")
20 ("empty" . "tag:doesnotexist"))))
23 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
25 test_begin_subtest "No saved searches displayed (all with 0 results)"
26 test_emacs '(let ((notmuch-saved-searches
27 '\''(("empty" . "tag:doesnotexist"))))
30 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
32 test_begin_subtest "Basic notmuch-search view in emacs"
33 test_emacs '(notmuch-search "tag:inbox")
36 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
38 test_begin_subtest "Incremental parsing of search results"
39 test_emacs "(ad-enable-advice 'notmuch-search-process-filter 'around 'pessimal)
40 (ad-activate 'notmuch-search-process-filter)
41 (notmuch-search \"tag:inbox\")
43 (ad-disable-advice 'notmuch-search-process-filter 'around 'pessimal)
44 (ad-activate 'notmuch-search-process-filter)
46 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
48 test_begin_subtest "Navigation of notmuch-hello to search results"
49 test_emacs '(notmuch-hello)
50 (goto-char (point-min))
51 (re-search-forward "inbox")
52 (widget-button-press (1- (point)))
55 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
57 test_begin_subtest "Basic notmuch-show view in emacs"
58 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
59 test_emacs "(notmuch-show \"$maildir_storage_thread\")
61 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
63 test_begin_subtest "Basic notmuch-show view in emacs default indentation"
64 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
65 test_emacs "(let ((notmuch-show-indent-messages-width 1))
66 (notmuch-show \"$maildir_storage_thread\")
68 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
70 test_begin_subtest "Basic notmuch-show view in emacs without 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 0))
73 (notmuch-show \"$maildir_storage_thread\")
75 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation
77 test_begin_subtest "Basic notmuch-show view in emacs with fourfold 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 4))
80 (notmuch-show \"$maildir_storage_thread\")
82 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation
84 test_begin_subtest "notmuch-show for message with invalid From"
85 add_message "[subject]=\"message-with-invalid-from\"" \
86 "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
87 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
88 test_emacs "(notmuch-show \"$thread\")
89 (test-output \"OUTPUT.raw\")"
91 "Invalid " (2001-01-05) (inbox)
92 Subject: message-with-invalid-from
93 To: Notmuch Test Suite <test_suite@notmuchmail.org>
96 This is just a test message (#1)
98 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
99 test_expect_equal_file OUTPUT EXPECTED
101 test_begin_subtest "Navigation of notmuch-search to thread view"
102 test_emacs '(notmuch-search "tag:inbox")
104 (goto-char (point-min))
105 (re-search-forward "Working with Maildir")
106 (notmuch-search-show-thread)
109 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
111 test_begin_subtest "Add tag from search view"
112 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
113 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
115 (execute-kbd-macro \"+tag-from-search-view\")"
116 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
117 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)"
119 test_begin_subtest "Remove tag from search view"
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 unread)"
126 test_begin_subtest "Add tag (large query)"
127 # We use a long query to force us into batch mode and use a funny tag
128 # that requires escaping for batch tagging.
129 test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (make-string notmuch-tag-argument-limit ?x)) (list \"+tag-from-%-large-query\"))"
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 tag-from-%-large-query unread)"
132 notmuch tag -tag-from-%-large-query $os_x_darwin_thread
134 test_begin_subtest "notmuch-show: add single tag to single message"
135 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
136 (execute-kbd-macro \"+tag-from-show-view\")"
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-show-view unread)"
140 test_begin_subtest "notmuch-show: remove single tag from single message"
141 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
142 (execute-kbd-macro \"-tag-from-show-view\")"
143 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
144 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)"
146 test_begin_subtest "notmuch-show: add multiple tags to single message"
147 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
148 (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
149 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
150 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)"
152 test_begin_subtest "notmuch-show: remove multiple tags from single message"
153 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
154 (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
155 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
156 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)"
158 test_begin_subtest "Message with .. in Message-Id:"
159 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
160 test_emacs '(notmuch-search "id:\"123..456@example\"")
162 (execute-kbd-macro "+search-add")
163 (execute-kbd-macro "+search-remove")
164 (execute-kbd-macro "-search-remove")
165 (notmuch-show "id:\"123..456@example\"")
167 (execute-kbd-macro "+show-add")
168 (execute-kbd-macro "+show-remove")
169 (execute-kbd-macro "-show-remove")'
170 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
171 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
173 test_begin_subtest "Message with quote in Message-Id:"
174 add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
175 test_emacs '(notmuch-search "subject:\"Message with quote\"")
177 (execute-kbd-macro "+search-add")
178 (notmuch-search-show-thread)
180 (execute-kbd-macro "+show-add")'
181 output=$(notmuch search 'id:"""quote""@example"' | notmuch_search_sanitize)
182 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)"
184 test_begin_subtest "Sending a message via (fake) SMTP"
185 emacs_deliver_message \
186 'Testing message sent via SMTP' \
187 'This is a test that messages are sent via SMTP' \
190 (insert "To: user@example.com\n")'
192 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
193 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
194 -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
196 From: Notmuch Test Suite <test_suite@notmuchmail.org>
198 Subject: Testing message sent via SMTP
199 Date: 01 Jan 2000 12:00:00 -0000
200 User-Agent: Notmuch/XXX Emacs/XXX
203 Content-Type: text/plain
205 This is a test that messages are sent via SMTP
207 test_expect_equal_file OUTPUT EXPECTED
209 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
210 notmuch new > /dev/null
211 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
212 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
214 test_begin_subtest "notmuch-fcc-dirs set to nil"
215 test_emacs "(let ((notmuch-fcc-dirs nil))
219 From: Notmuch Test Suite <test_suite@notmuchmail.org>
222 --text follows this line--
224 test_expect_equal_file OUTPUT EXPECTED
226 # Make another FCC maildir specific for the next test
227 mkdir -p mail/sent-string/cur
228 mkdir -p mail/sent-string/new
229 mkdir -p mail/sent-string/tmp
231 test_begin_subtest "notmuch-fcc-dirs set to a string"
232 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
236 From: Notmuch Test Suite <test_suite@notmuchmail.org>
239 Fcc: ${MAIL_DIR}/sent-string
240 --text follows this line--
242 test_expect_equal_file OUTPUT EXPECTED
244 # Make more FCC maildirs specific for the next test
245 mkdir -p mail/sent-list-match/cur
246 mkdir -p mail/sent-list-match/new
247 mkdir -p mail/sent-list-match/tmp
248 mkdir -p mail/failure/cur
249 mkdir -p mail/failure/new
250 mkdir -p mail/failure/tmp
252 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
253 test_emacs "(let ((notmuch-fcc-dirs
254 '((\"notmuchmail.org\" . \"sent-list-match\")
255 (\".*\" . \"failure\"))))
259 From: Notmuch Test Suite <test_suite@notmuchmail.org>
262 Fcc: ${MAIL_DIR}/sent-list-match
263 --text follows this line--
265 test_expect_equal_file OUTPUT EXPECTED
267 # Make another FCC maildir specific for the next test
268 mkdir -p mail/sent-list-catch-all/cur
269 mkdir -p mail/sent-list-catch-all/new
270 mkdir -p mail/sent-list-catch-all/tmp
272 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
273 test_emacs "(let ((notmuch-fcc-dirs
274 '((\"example.com\" . \"failure\")
275 (\".*\" . \"sent-list-catch-all\"))))
279 From: Notmuch Test Suite <test_suite@notmuchmail.org>
282 Fcc: ${MAIL_DIR}/sent-list-catch-all
283 --text follows this line--
285 test_expect_equal_file OUTPUT EXPECTED
287 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
288 test_emacs "(let ((notmuch-fcc-dirs
289 '((\"example.com\" . \"failure\")
290 (\"nomatchhere.net\" . \"failure\"))))
294 From: Notmuch Test Suite <test_suite@notmuchmail.org>
297 --text follows this line--
299 test_expect_equal_file OUTPUT EXPECTED
301 test_begin_subtest "Reply within emacs"
302 test_emacs '(let ((message-hidden-headers ''()))
303 (notmuch-search "subject:\"testing message sent via SMTP\"")
305 (notmuch-search-reply-to-thread)
307 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
308 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
309 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
311 From: Notmuch Test Suite <test_suite@notmuchmail.org>
313 Subject: Re: Testing message sent via SMTP
315 Fcc: ${MAIL_DIR}/sent
317 User-Agent: Notmuch/XXX Emacs/XXX
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)
334 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
336 From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
337 To: Sender <sender@example.com>
338 Subject: Re: ${test_subtest_name}
339 In-Reply-To: <${gen_msg_id}>
340 Fcc: ${MAIL_DIR}/sent
341 References: <${gen_msg_id}>
342 User-Agent: Notmuch/XXX Emacs/XXX
343 --text follows this line--
344 Sender <sender@example.com> writes:
346 > This is just a test message (#${gen_msg_cnt})
348 test_expect_equal_file OUTPUT EXPECTED
350 test_begin_subtest "Reply from address in named group list within emacs"
351 add_message '[from]="Sender <sender@example.com>"' \
352 '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
353 [cc]=test_suite_other@notmuchmail.org
355 test_emacs "(let ((message-hidden-headers '()))
356 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
358 (notmuch-search-reply-to-thread)
360 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
362 From: Notmuch Test Suite <test_suite@notmuchmail.org>
363 To: Sender <sender@example.com>, someone@example.com
364 Subject: Re: ${test_subtest_name}
365 In-Reply-To: <${gen_msg_id}>
366 Fcc: ${MAIL_DIR}/sent
367 References: <${gen_msg_id}>
368 User-Agent: Notmuch/XXX Emacs/XXX
369 --text follows this line--
370 Sender <sender@example.com> writes:
372 > This is just a test message (#${gen_msg_cnt})
374 test_expect_equal_file OUTPUT EXPECTED
376 test_begin_subtest "Reply within emacs to a multipart/mixed message"
377 test_emacs '(let ((message-hidden-headers ''()))
378 (notmuch-show "id:20091118002059.067214ed@hikari")
381 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
383 From: Notmuch Test Suite <test_suite@notmuchmail.org>
384 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
385 Subject: Re: [notmuch] Introducing myself
386 In-Reply-To: <20091118002059.067214ed@hikari>
387 Fcc: ${MAIL_DIR}/sent
388 References: <20091118002059.067214ed@hikari>
389 User-Agent: Notmuch/XXX Emacs/XXX
390 --text follows this line--
391 Adrian Perez de Castro <aperez@igalia.com> writes:
395 > I have just heard about Not Much today in some random Linux-related news
396 > site (LWN?), my name is Adrian Perez and I work as systems administrator
397 > (although I can do some code as well :P). I have always thought that the
398 > ideas behind Sup were great, but after some time using it, I got tired of
399 > the oddities that it has. I also do not like doing things like having to
400 > install Ruby just for reading and sorting mails. Some time ago I thought
401 > about doing something like Not Much and in fact I played a bit with the
402 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
403 > to code things in Python when I am not working and also it is installed
404 > by default on most distribution. I got to have some mailboxes indexed and
405 > basic searching working a couple of months ago. Lately I have been very
406 > busy and had no time for coding, and them... boom! Not Much appears -- and
407 > it is almost exactly what I was trying to do, but faster. I have been
408 > playing a bit with Not Much today, and I think it has potential.
410 > Also, I would like to share one idea I had in mind, that you might find
411 > interesting: One thing I have found very annoying is having to re-tag my
412 > mail when the indexes get b0rked (it happened a couple of times to me while
413 > using Sup), so I was planning to mails as read/unread and adding the tags
414 > not just to the index, but to the mail text itself, e.g. by adding a
415 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
416 > could be totally recreated by re-reading the mail directories, and this
417 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
418 > local maildir, tagging and indexing the mails with the e-mail reader and
419 > then syncing back the messages with the "X-Tags" header to the IMAP server.
420 > This would allow to use the mail reader from a different computer and still
421 > have everything tagged finely.
427 > [1] http://software.complete.org/software/projects/show/offlineimap
430 > Adrian Perez de Castro <aperez@igalia.com>
431 > Igalia - Free Software Engineering
432 > _______________________________________________
433 > notmuch mailing list
434 > notmuch@notmuchmail.org
435 > http://notmuchmail.org/mailman/listinfo/notmuch
437 test_expect_equal_file OUTPUT EXPECTED
439 test_begin_subtest "Reply within emacs to a multipart/alternative message"
440 test_emacs '(let ((message-hidden-headers ''()))
441 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
444 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
446 From: Notmuch Test Suite <test_suite@notmuchmail.org>
447 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
448 Subject: Re: [notmuch] preliminary FreeBSD support
449 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
450 Fcc: ${MAIL_DIR}/sent
451 References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
452 User-Agent: Notmuch/XXX Emacs/XXX
453 --text follows this line--
454 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
456 > I saw the announcement this morning, and was very excited, as I had been
457 > hoping sup would be turned into a library,
458 > since I like the concept more than the UI (I'd rather an emacs interface).
460 > I did a preliminary compile which worked out fine, but
461 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
462 > FreeBSD, so notmuch_config_open segfaulted.
464 > Attached is a patch that supplies a default buffer size of 64 in cases where
467 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
468 > is acceptable behavior,
469 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
472 > _______________________________________________
473 > notmuch mailing list
474 > notmuch@notmuchmail.org
475 > http://notmuchmail.org/mailman/listinfo/notmuch
477 test_expect_equal_file OUTPUT EXPECTED
479 test_begin_subtest "Reply within emacs to an html-only message"
480 add_message '[content-type]="text/html"' \
481 '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
482 test_emacs "(let ((message-hidden-headers '()) (mm-text-html-renderer 'html2text))
483 (notmuch-show \"id:${gen_msg_id}\")
486 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
488 From: Notmuch Test Suite <test_suite@notmuchmail.org>
490 Subject: Re: Reply within emacs to an html-only message
491 In-Reply-To: <${gen_msg_id}>
492 Fcc: ${MAIL_DIR}/sent
493 References: <${gen_msg_id}>
494 User-Agent: Notmuch/XXX Emacs/XXX
495 --text follows this line--
496 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
498 > Hi,This is an HTML test message.OK?
500 test_expect_equal_file OUTPUT EXPECTED
502 test_begin_subtest "Quote MML tags in reply"
503 message_id='test-emacs-mml-quoting@message.id'
504 add_message [id]="$message_id" \
505 "[subject]='$test_subtest_name'" \
506 '[body]="<#part disposition=inline>"'
507 test_emacs "(let ((message-hidden-headers '()))
508 (notmuch-show \"id:$message_id\")
511 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
513 From: Notmuch Test Suite <test_suite@notmuchmail.org>
515 Subject: Re: Quote MML tags in reply
516 In-Reply-To: <test-emacs-mml-quoting@message.id>
517 Fcc: ${MAIL_DIR}/sent
518 References: <test-emacs-mml-quoting@message.id>
519 User-Agent: Notmuch/XXX Emacs/XXX
520 --text follows this line--
521 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
523 > <#!part disposition=inline>
525 test_expect_equal_file OUTPUT EXPECTED
527 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
528 # save as archive to test that Emacs does not re-compress .gz
529 test_emacs '(let ((standard-input "\"attachment1.gz\""))
530 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
531 (notmuch-show-save-attachments))'
532 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
534 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
535 # save as archive to test that Emacs does not re-compress .gz
536 test_emacs '(let ((standard-input "\"attachment2.gz\""))
537 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
538 (search-forward "0001-Deal-with")
539 (notmuch-show-save-part))'
540 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
542 test_begin_subtest "Save 8bit attachment from within emacs using notmuch-show-save-attachments"
544 add_message '[subject]="Attachment with 8bit chars"' \
545 '[header]="MIME-Version: 1.0"' \
546 '[content-type]="multipart/mixed; boundary=\"abcd\""' \
548 Content-Type: text/plain
553 Content-Type: application/octet-stream; name=\"sample\"
554 Content-Transfer-Encoding: 8bit
555 Content-Disposition: attachment; filename=\"sample\"
557 “¡ Hey ! It compiles ¡ Ship it !”
561 test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
562 (delete-file "OUTPUT")
563 (let ((standard-input "\"OUTPUT\""))
564 (notmuch-show-save-attachments))'
566 test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
568 test_begin_subtest "View raw message within emacs"
569 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
570 (notmuch-show-view-raw-message)
572 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
574 test_begin_subtest "Hiding/showing signature in notmuch-show view"
575 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
576 test_emacs "(notmuch-show \"$maildir_storage_thread\")
577 (search-forward \"Click/Enter to show.\")
578 (button-activate (button-at (point)))
579 (search-backward \"Click/Enter to hide.\")
580 (button-activate (button-at (point)))
582 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
584 test_begin_subtest "Detection and hiding of top-post quoting of message"
585 add_message '[subject]="The problem with top-posting"' \
586 [id]=top-post-target \
587 '[body]="A: Because it messes up the order in which people normally read text.
588 Q: Why is top-posting such a bad thing?
590 Q: What is the most annoying thing in e-mail?"'
591 add_message '[from]="Top Poster <top@poster.com>"' \
592 [in-reply-to]=top-post-target \
593 [references]=top-post-target \
594 '[subject]="Re: The problem with top-posting"' \
595 '[body]="Thanks for the advice! I will be sure to put it to good use.
599 ----- Original Message -----
600 From: Notmuch Test Suite <test_suite@notmuchmail.org>
601 To: Notmuch Test Suite <test_suite@notmuchmai.org>
602 Sent: Fri, 05 Jan 2001 15:43:57 +0000
603 Subject: The problem with top-posting
605 Q: Why is top-posting such a bad thing?
607 Q: What is the most annoying thing in e-mail?"'
608 test_emacs "(notmuch-show \"top-posting\")
609 (test-visible-output \"OUTPUT.raw\")"
610 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
611 Subject: The problem with top-posting
612 To: Notmuch Test Suite <test_suite@notmuchmail.org>
615 A: Because it messes up the order in which people normally read text.
616 Q: Why is top-posting such a bad thing?
618 Q: What is the most annoying thing in e-mail?
619 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
620 Subject: Re: The problem with top-posting
621 To: Notmuch Test Suite <test_suite@notmuchmail.org>
624 Thanks for the advice! I will be sure to put it to good use.
628 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
629 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
630 test_expect_equal_file OUTPUT EXPECTED
632 test_begin_subtest "Hiding message in notmuch-show view"
633 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
634 (notmuch-show-toggle-message)
635 (test-visible-output)'
636 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
638 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
639 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
640 (search-forward "Click/Enter to show.")
641 (button-activate (button-at (point)))
642 (notmuch-show-toggle-message)
643 (test-visible-output)'
644 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
646 test_begin_subtest "notmuch-show: show message headers"
648 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
649 (notmuch-message-headers-visible t))
650 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
651 (test-visible-output))'
652 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-visible
654 test_begin_subtest "notmuch-show: hide message headers"
656 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
657 (notmuch-message-headers-visible nil))
658 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
659 (test-visible-output))'
660 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
662 test_begin_subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-visibility-headers)"
664 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
665 (notmuch-message-headers-visible t))
666 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
667 (notmuch-show-toggle-visibility-headers)
668 (test-visible-output))'
669 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
671 test_begin_subtest "notmuch-show: collapse all messages in thread"
672 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
673 (let ((current-prefix-arg t))
674 (notmuch-show-open-or-close-all)
675 (test-visible-output))'
676 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-collapsed
678 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
679 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
680 (notmuch-show-open-or-close-all)
681 (test-visible-output)'
682 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed
684 test_begin_subtest "Stashing in notmuch-show"
685 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
686 '[from]="Some One <someone@somewhere.org>"' \
687 '[to]="Some One Else <notsomeone@somewhere.org>"' \
688 '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
689 '[subject]="Stash my stashables"' \
691 '[body]="Unable to stash body. Where did you get it in the first place?!?"'
692 notmuch tag +stashtest id:${gen_msg_id}
693 test_emacs '(notmuch-show "id:\"bought\"")
694 (notmuch-show-stash-date)
695 (notmuch-show-stash-from)
696 (notmuch-show-stash-to)
697 (notmuch-show-stash-cc)
698 (notmuch-show-stash-subject)
699 (notmuch-show-stash-message-id)
700 (notmuch-show-stash-message-id-stripped)
701 (notmuch-show-stash-tags)
702 (notmuch-show-stash-filename)
703 (notmuch-show-stash-mlarchive-link "Gmane")
704 (notmuch-show-stash-mlarchive-link "MARC")
705 (notmuch-show-stash-mlarchive-link "Mail Archive, The")
707 (generate-new-buffer "*test-stashing*"))
711 (rotate-yank-pointer 1))
712 (reverse-region (point-min) (point-max))
715 Sat, 01 Jan 2000 12:00:00 +0000
716 Some One <someone@somewhere.org>
717 Some One Else <notsomeone@somewhere.org>
718 Notmuch <notmuch@notmuchmail.org>
724 http://mid.gmane.org/bought
725 http://marc.info/?i=bought
726 http://mail-archive.com/search?l=mid&q=bought
728 test_expect_equal_file OUTPUT EXPECTED
730 test_begin_subtest "Stashing in notmuch-search"
731 test_emacs '(notmuch-search "id:\"bought\"")
733 (notmuch-search-stash-thread-id)
735 (generate-new-buffer "*test-stashing*"))
738 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
739 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
741 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
742 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
743 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
744 test_emacs "(notmuch-show \"$message2\")
745 (test-output \"EXPECTED\")"
746 test_emacs "(notmuch-search \"$message1 or $message2\")
748 (notmuch-search-show-thread)
749 (goto-char (point-max))
751 (notmuch-show-advance-and-archive)
753 test_expect_equal_file OUTPUT EXPECTED
755 test_begin_subtest "Refresh show buffer"
756 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
757 (test-visible-output "EXPECTED")
758 (notmuch-show-refresh-view)
759 (test-visible-output)'
760 test_expect_equal_file OUTPUT EXPECTED
762 test_begin_subtest "Refresh modified show buffer"
763 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
764 (notmuch-show-toggle-message)
765 (notmuch-show-next-message)
766 (notmuch-show-toggle-message)
767 (test-visible-output "EXPECTED")
768 (notmuch-show-refresh-view)
769 (test-visible-output)'
770 test_expect_equal_file OUTPUT EXPECTED
772 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
773 id='message-with-application/mpeg-attachment@notmuchmail.org'
775 'Message with application/mpeg attachment' \
778 (insert \"Message-ID: <$id>\n\")
780 (mml-insert-part \"application/mpeg\")
781 (insert \"a fake mp3 file\")"
782 notmuch_counter_reset
783 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
784 (notmuch-show \"id:$id\"))"
785 test_expect_equal $(notmuch_counter_value) 1
787 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
788 id='message-with-audio/mpeg-attachment@notmuchmail.org'
790 'Message with audio/mpeg attachment' \
793 (insert \"Message-ID: <$id>\n\")
795 (mml-insert-part \"audio/mpeg\")
796 (insert \"a fake mp3 file\")"
797 notmuch_counter_reset
798 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
799 (notmuch-show \"id:$id\"))"
800 test_expect_equal $(notmuch_counter_value) 1
802 test_begin_subtest "notmuch-hello-mode hook is called"
803 counter=$(test_emacs \
804 '(let ((notmuch-hello-mode-hook-counter 0))
805 (kill-buffer "*notmuch-hello*")
807 notmuch-hello-mode-hook-counter)'
809 test_expect_equal "$counter" 1
811 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
812 counter=$(test_emacs \
813 '(let ((notmuch-hello-mode-hook-counter 0))
814 (kill-buffer "*notmuch-hello*")
816 (notmuch-hello-update)
817 notmuch-hello-mode-hook-counter)'
819 test_expect_equal "$counter" 1
821 test_begin_subtest "notmuch-hello-refresh hook is called"
822 counter=$(test_emacs \
823 '(let ((notmuch-hello-refresh-hook-counter 0))
824 (kill-buffer "*notmuch-hello*")
826 notmuch-hello-refresh-hook-counter)'
828 test_expect_equal "$counter" 1
830 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
831 counter=$(test_emacs \
832 '(let ((notmuch-hello-refresh-hook-counter 0))
833 (kill-buffer "*notmuch-hello*")
835 (notmuch-hello-update)
836 notmuch-hello-refresh-hook-counter)'
838 test_expect_equal "$counter" 2
841 add_message '[subject]="HTML mail with images"' \
842 '[content-type]="multipart/related; boundary=abcd"' \
844 Content-Type: text/html
846 <img src="cid:330@goomoji.gmail"> smiley
849 Content-Type: image/gif
850 Content-Transfer-Encoding: base64
851 Content-ID: <330@goomoji.gmail>
853 R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMl
854 WLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7
856 test_emacs "(let ((mm-text-html-renderer
857 (if (assq 'shr mm-text-html-renderer-alist)
859 (notmuch-show \"id:${gen_msg_id}\"))
860 (test-output)" > /dev/null
861 # Different Emacs versions and renderers give very different results,
862 # so just check that something reasonable showed up. We first cat the
863 # output so the test framework will print it if the test fails.
864 test_expect_success "Rendering HTML mail with images" \
865 'cat OUTPUT && grep -q smiley OUTPUT'
868 test_begin_subtest "Search handles subprocess error exit codes"
869 cat > notmuch_fail <<EOF
874 chmod a+x notmuch_fail
875 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
876 (with-current-buffer \"*Messages*\" (erase-buffer))
877 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
879 (notmuch-search \"tag:inbox\")
881 (with-current-buffer \"*Messages*\"
882 (test-output \"MESSAGES\"))
883 (with-current-buffer \"*Notmuch errors*\"
884 (test-output \"ERROR\"))
887 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
889 End of search results.
891 YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
894 YYY/notmuch_fail exited with status 1
895 command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox
898 test_begin_subtest "Search handles subprocess warnings"
899 cat > notmuch_fail <<EOF
902 echo This is a warning >&2
903 echo This is another warning >&2
906 chmod a+x notmuch_fail
907 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
908 (with-current-buffer \"*Messages*\" (erase-buffer))
909 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
911 (notmuch-search \"tag:inbox\")
913 (with-current-buffer \"*Messages*\"
914 (test-output \"MESSAGES\"))
915 (with-current-buffer \"*Notmuch errors*\"
916 (test-output \"ERROR\"))
918 sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
919 test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
920 End of search results.
922 This is a warning (see *Notmuch errors* for more details)
926 This is another warning"
928 test_begin_subtest "Search thread tag operations are race-free"
929 add_message '[subject]="Search race test"'
930 gen_msg_id_1=$gen_msg_id
931 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
932 '[references]="<'$gen_msg_id_1'>"' \
933 '[subject]="Search race test two"'
934 test_emacs '(notmuch-search "subject:\"search race test\"")
937 (execute-kbd-macro "+search-thread-race-tag")'
938 output=$(notmuch search --output=messages 'tag:search-thread-race-tag')
939 test_expect_equal "$output" "id:$gen_msg_id_1"
941 test_begin_subtest "Search global tag operations are race-free"
942 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
943 '[references]="<'$gen_msg_id_1'>"' \
944 '[subject]="Re: Search race test"'
945 test_emacs '(notmuch-search "subject:\"search race test\" -subject:two")
948 (execute-kbd-macro "*+search-global-race-tag")'
949 output=$(notmuch search --output=messages 'tag:search-global-race-tag')
950 test_expect_equal "$output" "id:$gen_msg_id_1"