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\")
91 "Invalid " (2001-01-05) (inbox)
92 Subject: message-with-invalid-from
93 To: Notmuch Test Suite <test_suite@notmuchmail.org>
94 Date: Fri, 05 Jan 2001 15:43:57 +0000
96 This is just a test message (#1)
98 test_expect_equal_file OUTPUT EXPECTED
100 test_begin_subtest "Navigation of notmuch-search to thread view"
101 test_emacs '(notmuch-search "tag:inbox")
103 (goto-char (point-min))
104 (re-search-forward "Working with Maildir")
105 (notmuch-search-show-thread)
108 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
110 test_begin_subtest "Add tag from search view"
111 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
112 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
114 (execute-kbd-macro \"+tag-from-search-view\")"
115 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
116 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)"
118 test_begin_subtest "Remove tag from search view"
119 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
121 (execute-kbd-macro \"-tag-from-search-view\")"
122 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
123 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)"
125 test_begin_subtest "Add tag (large query)"
126 # We use a long query to force us into batch mode and use a funny tag
127 # that requires escaping for batch tagging.
128 test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (make-string notmuch-tag-argument-limit ?x)) (list \"+tag-from-%-large-query\"))"
129 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
130 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)"
131 notmuch tag -tag-from-%-large-query $os_x_darwin_thread
133 test_begin_subtest "notmuch-show: add single tag to single message"
134 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
135 (execute-kbd-macro \"+tag-from-show-view\")"
136 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
137 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)"
139 test_begin_subtest "notmuch-show: remove single tag from single message"
140 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
141 (execute-kbd-macro \"-tag-from-show-view\")"
142 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
143 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)"
145 test_begin_subtest "notmuch-show: add multiple tags to single message"
146 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
147 (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
148 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
149 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)"
151 test_begin_subtest "notmuch-show: remove multiple tags from single message"
152 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
153 (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
154 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
155 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)"
157 test_begin_subtest "Message with .. in Message-Id:"
158 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
159 test_emacs '(notmuch-search "id:\"123..456@example\"")
161 (execute-kbd-macro "+search-add")
162 (execute-kbd-macro "+search-remove")
163 (execute-kbd-macro "-search-remove")
164 (notmuch-show "id:\"123..456@example\"")
166 (execute-kbd-macro "+show-add")
167 (execute-kbd-macro "+show-remove")
168 (execute-kbd-macro "-show-remove")'
169 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
170 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
172 test_begin_subtest "Message with quote in Message-Id:"
173 add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
174 test_emacs '(notmuch-search "subject:\"Message with quote\"")
176 (execute-kbd-macro "+search-add")
177 (notmuch-search-show-thread)
179 (execute-kbd-macro "+show-add")'
180 output=$(notmuch search 'id:"""quote""@example"' | notmuch_search_sanitize)
181 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)"
183 test_begin_subtest "Sending a message via (fake) SMTP"
184 emacs_deliver_message \
185 'Testing message sent via SMTP' \
186 'This is a test that messages are sent via SMTP' \
189 (insert "To: user@example.com\n")'
191 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
192 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
193 -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
195 From: Notmuch Test Suite <test_suite@notmuchmail.org>
197 Subject: Testing message sent via SMTP
198 Date: 01 Jan 2000 12:00:00 -0000
199 User-Agent: Notmuch/XXX Emacs/XXX
202 Content-Type: text/plain
204 This is a test that messages are sent via SMTP
206 test_expect_equal_file OUTPUT EXPECTED
208 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
209 notmuch new > /dev/null
210 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
211 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
213 test_begin_subtest "notmuch-fcc-dirs set to nil"
214 test_emacs "(let ((notmuch-fcc-dirs nil))
218 From: Notmuch Test Suite <test_suite@notmuchmail.org>
221 --text follows this line--
223 test_expect_equal_file OUTPUT EXPECTED
225 # Make another FCC maildir specific for the next test
226 mkdir -p mail/sent-string/cur
227 mkdir -p mail/sent-string/new
228 mkdir -p mail/sent-string/tmp
230 test_begin_subtest "notmuch-fcc-dirs set to a string"
231 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
235 From: Notmuch Test Suite <test_suite@notmuchmail.org>
238 Fcc: ${MAIL_DIR}/sent-string
239 --text follows this line--
241 test_expect_equal_file OUTPUT EXPECTED
243 # Make more FCC maildirs specific for the next test
244 mkdir -p mail/sent-list-match/cur
245 mkdir -p mail/sent-list-match/new
246 mkdir -p mail/sent-list-match/tmp
247 mkdir -p mail/failure/cur
248 mkdir -p mail/failure/new
249 mkdir -p mail/failure/tmp
251 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
252 test_emacs "(let ((notmuch-fcc-dirs
253 '((\"notmuchmail.org\" . \"sent-list-match\")
254 (\".*\" . \"failure\"))))
258 From: Notmuch Test Suite <test_suite@notmuchmail.org>
261 Fcc: ${MAIL_DIR}/sent-list-match
262 --text follows this line--
264 test_expect_equal_file OUTPUT EXPECTED
266 # Make another FCC maildir specific for the next test
267 mkdir -p mail/sent-list-catch-all/cur
268 mkdir -p mail/sent-list-catch-all/new
269 mkdir -p mail/sent-list-catch-all/tmp
271 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
272 test_emacs "(let ((notmuch-fcc-dirs
273 '((\"example.com\" . \"failure\")
274 (\".*\" . \"sent-list-catch-all\"))))
278 From: Notmuch Test Suite <test_suite@notmuchmail.org>
281 Fcc: ${MAIL_DIR}/sent-list-catch-all
282 --text follows this line--
284 test_expect_equal_file OUTPUT EXPECTED
286 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
287 test_emacs "(let ((notmuch-fcc-dirs
288 '((\"example.com\" . \"failure\")
289 (\"nomatchhere.net\" . \"failure\"))))
293 From: Notmuch Test Suite <test_suite@notmuchmail.org>
296 --text follows this line--
298 test_expect_equal_file OUTPUT EXPECTED
300 test_begin_subtest "Reply within emacs"
301 test_emacs '(let ((message-hidden-headers ''()))
302 (notmuch-search "subject:\"testing message sent via SMTP\"")
304 (notmuch-search-reply-to-thread)
306 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
307 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
308 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
310 From: Notmuch Test Suite <test_suite@notmuchmail.org>
312 Subject: Re: Testing message sent via SMTP
314 Fcc: ${MAIL_DIR}/sent
316 User-Agent: Notmuch/XXX Emacs/XXX
317 --text follows this line--
318 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
320 > This is a test that messages are sent via SMTP
322 test_expect_equal_file OUTPUT EXPECTED
324 test_begin_subtest "Reply from alternate address within emacs"
325 add_message '[from]="Sender <sender@example.com>"' \
326 [to]=test_suite_other@notmuchmail.org
328 test_emacs "(let ((message-hidden-headers '()))
329 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
331 (notmuch-search-reply-to-thread)
333 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
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 User-Agent: Notmuch/XXX Emacs/XXX
342 --text follows this line--
343 Sender <sender@example.com> writes:
345 > This is just a test message (#${gen_msg_cnt})
347 test_expect_equal_file OUTPUT EXPECTED
349 test_begin_subtest "Reply from address in named group list within emacs"
350 add_message '[from]="Sender <sender@example.com>"' \
351 '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
352 [cc]=test_suite_other@notmuchmail.org
354 test_emacs "(let ((message-hidden-headers '()))
355 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
357 (notmuch-search-reply-to-thread)
359 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
361 From: Notmuch Test Suite <test_suite@notmuchmail.org>
362 To: Sender <sender@example.com>, someone@example.com
363 Subject: Re: ${test_subtest_name}
364 In-Reply-To: <${gen_msg_id}>
365 Fcc: ${MAIL_DIR}/sent
366 References: <${gen_msg_id}>
367 User-Agent: Notmuch/XXX Emacs/XXX
368 --text follows this line--
369 Sender <sender@example.com> writes:
371 > This is just a test message (#${gen_msg_cnt})
373 test_expect_equal_file OUTPUT EXPECTED
375 test_begin_subtest "Reply within emacs to a multipart/mixed message"
376 test_emacs '(let ((message-hidden-headers ''()))
377 (notmuch-show "id:20091118002059.067214ed@hikari")
380 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
382 From: Notmuch Test Suite <test_suite@notmuchmail.org>
383 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
384 Subject: Re: [notmuch] Introducing myself
385 In-Reply-To: <20091118002059.067214ed@hikari>
386 Fcc: ${MAIL_DIR}/sent
387 References: <20091118002059.067214ed@hikari>
388 User-Agent: Notmuch/XXX Emacs/XXX
389 --text follows this line--
390 Adrian Perez de Castro <aperez@igalia.com> writes:
394 > I have just heard about Not Much today in some random Linux-related news
395 > site (LWN?), my name is Adrian Perez and I work as systems administrator
396 > (although I can do some code as well :P). I have always thought that the
397 > ideas behind Sup were great, but after some time using it, I got tired of
398 > the oddities that it has. I also do not like doing things like having to
399 > install Ruby just for reading and sorting mails. Some time ago I thought
400 > about doing something like Not Much and in fact I played a bit with the
401 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
402 > to code things in Python when I am not working and also it is installed
403 > by default on most distribution. I got to have some mailboxes indexed and
404 > basic searching working a couple of months ago. Lately I have been very
405 > busy and had no time for coding, and them... boom! Not Much appears -- and
406 > it is almost exactly what I was trying to do, but faster. I have been
407 > playing a bit with Not Much today, and I think it has potential.
409 > Also, I would like to share one idea I had in mind, that you might find
410 > interesting: One thing I have found very annoying is having to re-tag my
411 > mail when the indexes get b0rked (it happened a couple of times to me while
412 > using Sup), so I was planning to mails as read/unread and adding the tags
413 > not just to the index, but to the mail text itself, e.g. by adding a
414 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
415 > could be totally recreated by re-reading the mail directories, and this
416 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
417 > local maildir, tagging and indexing the mails with the e-mail reader and
418 > then syncing back the messages with the "X-Tags" header to the IMAP server.
419 > This would allow to use the mail reader from a different computer and still
420 > have everything tagged finely.
426 > [1] http://software.complete.org/software/projects/show/offlineimap
429 > Adrian Perez de Castro <aperez@igalia.com>
430 > Igalia - Free Software Engineering
431 > _______________________________________________
432 > notmuch mailing list
433 > notmuch@notmuchmail.org
434 > http://notmuchmail.org/mailman/listinfo/notmuch
436 test_expect_equal_file OUTPUT EXPECTED
438 test_begin_subtest "Reply within emacs to a multipart/alternative message"
439 test_emacs '(let ((message-hidden-headers ''()))
440 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
443 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
445 From: Notmuch Test Suite <test_suite@notmuchmail.org>
446 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
447 Subject: Re: [notmuch] preliminary FreeBSD support
448 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
449 Fcc: ${MAIL_DIR}/sent
450 References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
451 User-Agent: Notmuch/XXX Emacs/XXX
452 --text follows this line--
453 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
455 > I saw the announcement this morning, and was very excited, as I had been
456 > hoping sup would be turned into a library,
457 > since I like the concept more than the UI (I'd rather an emacs interface).
459 > I did a preliminary compile which worked out fine, but
460 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
461 > FreeBSD, so notmuch_config_open segfaulted.
463 > Attached is a patch that supplies a default buffer size of 64 in cases where
466 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
467 > is acceptable behavior,
468 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
471 > _______________________________________________
472 > notmuch mailing list
473 > notmuch@notmuchmail.org
474 > http://notmuchmail.org/mailman/listinfo/notmuch
476 test_expect_equal_file OUTPUT EXPECTED
478 test_begin_subtest "Reply within emacs to an html-only message"
479 add_message '[content-type]="text/html"' \
480 '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
481 test_emacs "(let ((message-hidden-headers '()) (mm-text-html-renderer 'html2text))
482 (notmuch-show \"id:${gen_msg_id}\")
485 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
487 From: Notmuch Test Suite <test_suite@notmuchmail.org>
489 Subject: Re: Reply within emacs to an html-only message
490 In-Reply-To: <${gen_msg_id}>
491 Fcc: ${MAIL_DIR}/sent
492 References: <${gen_msg_id}>
493 User-Agent: Notmuch/XXX Emacs/XXX
494 --text follows this line--
495 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
497 > Hi,This is an HTML test message.OK?
499 test_expect_equal_file OUTPUT EXPECTED
501 test_begin_subtest "Quote MML tags in reply"
502 message_id='test-emacs-mml-quoting@message.id'
503 add_message [id]="$message_id" \
504 "[subject]='$test_subtest_name'" \
505 '[body]="<#part disposition=inline>"'
506 test_emacs "(let ((message-hidden-headers '()))
507 (notmuch-show \"id:$message_id\")
510 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
512 From: Notmuch Test Suite <test_suite@notmuchmail.org>
514 Subject: Re: Quote MML tags in reply
515 In-Reply-To: <test-emacs-mml-quoting@message.id>
516 Fcc: ${MAIL_DIR}/sent
517 References: <test-emacs-mml-quoting@message.id>
518 User-Agent: Notmuch/XXX Emacs/XXX
519 --text follows this line--
520 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
522 > <#!part disposition=inline>
524 test_expect_equal_file OUTPUT EXPECTED
526 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
527 # save as archive to test that Emacs does not re-compress .gz
528 test_emacs '(let ((standard-input "\"attachment1.gz\""))
529 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
530 (notmuch-show-save-attachments))'
531 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
533 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
534 # save as archive to test that Emacs does not re-compress .gz
535 test_emacs '(let ((standard-input "\"attachment2.gz\""))
536 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
537 (search-forward "0001-Deal-with")
538 (notmuch-show-save-part))'
539 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
541 test_begin_subtest "Save 8bit attachment from within emacs using notmuch-show-save-attachments"
543 add_message '[subject]="Attachment with 8bit chars"' \
544 '[header]="MIME-Version: 1.0"' \
545 '[content-type]="multipart/mixed; boundary=\"abcd\""' \
547 Content-Type: text/plain
552 Content-Type: application/octet-stream; name=\"sample\"
553 Content-Transfer-Encoding: 8bit
554 Content-Disposition: attachment; filename=\"sample\"
556 “¡ Hey ! It compiles ¡ Ship it !”
560 test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
561 (delete-file "OUTPUT")
562 (let ((standard-input "\"OUTPUT\""))
563 (notmuch-show-save-attachments))'
565 test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
567 test_begin_subtest "View raw message within emacs"
568 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
569 (notmuch-show-view-raw-message)
571 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
573 test_begin_subtest "Hiding/showing signature in notmuch-show view"
574 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
575 test_emacs "(notmuch-show \"$maildir_storage_thread\")
576 (search-forward \"Click/Enter to show.\")
577 (button-activate (button-at (point)))
578 (search-backward \"Click/Enter to hide.\")
579 (button-activate (button-at (point)))
581 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
583 test_begin_subtest "Detection and hiding of top-post quoting of message"
584 add_message '[subject]="The problem with top-posting"' \
585 [id]=top-post-target \
586 '[body]="A: Because it messes up the order in which people normally read text.
587 Q: Why is top-posting such a bad thing?
589 Q: What is the most annoying thing in e-mail?"'
590 add_message '[from]="Top Poster <top@poster.com>"' \
591 [in-reply-to]=top-post-target \
592 [references]=top-post-target \
593 '[subject]="Re: The problem with top-posting"' \
594 '[body]="Thanks for the advice! I will be sure to put it to good use.
598 ----- Original Message -----
599 From: Notmuch Test Suite <test_suite@notmuchmail.org>
600 To: Notmuch Test Suite <test_suite@notmuchmai.org>
601 Sent: Fri, 05 Jan 2001 15:43:57 +0000
602 Subject: The problem with top-posting
604 Q: Why is top-posting such a bad thing?
606 Q: What is the most annoying thing in e-mail?"'
607 test_emacs "(notmuch-show \"top-posting\")
608 (test-visible-output)"
609 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
610 Subject: The problem with top-posting
611 To: Notmuch Test Suite <test_suite@notmuchmail.org>
612 Date: Fri, 05 Jan 2001 15:43:57 +0000
614 A: Because it messes up the order in which people normally read text.
615 Q: Why is top-posting such a bad thing?
617 Q: What is the most annoying thing in e-mail?
618 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
619 Subject: Re: The problem with top-posting
620 To: Notmuch Test Suite <test_suite@notmuchmail.org>
621 Date: Fri, 05 Jan 2001 15:43:57 +0000
623 Thanks for the advice! I will be sure to put it to good use.
627 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
628 test_expect_equal_file OUTPUT EXPECTED
630 test_begin_subtest "Hiding message in notmuch-show view"
631 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
632 (notmuch-show-toggle-message)
633 (test-visible-output)'
634 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
636 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
637 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
638 (search-forward "Click/Enter to show.")
639 (button-activate (button-at (point)))
640 (notmuch-show-toggle-message)
641 (test-visible-output)'
642 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
644 test_begin_subtest "notmuch-show: show message headers"
646 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
647 (notmuch-message-headers-visible t))
648 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
649 (test-visible-output))'
650 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-visible
652 test_begin_subtest "notmuch-show: hide message headers"
654 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
655 (notmuch-message-headers-visible nil))
656 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
657 (test-visible-output))'
658 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
660 test_begin_subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-visibility-headers)"
662 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
663 (notmuch-message-headers-visible t))
664 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
665 (notmuch-show-toggle-visibility-headers)
666 (test-visible-output))'
667 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
669 test_begin_subtest "notmuch-show: collapse all messages in thread"
670 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
671 (let ((current-prefix-arg t))
672 (notmuch-show-open-or-close-all)
673 (test-visible-output))'
674 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-collapsed
676 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
677 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
678 (notmuch-show-open-or-close-all)
679 (test-visible-output)'
680 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed
682 test_begin_subtest "Stashing in notmuch-show"
683 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
684 '[from]="Some One <someone@somewhere.org>"' \
685 '[to]="Some One Else <notsomeone@somewhere.org>"' \
686 '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
687 '[subject]="Stash my stashables"' \
689 '[body]="Unable to stash body. Where did you get it in the first place?!?"'
690 notmuch tag +stashtest id:${gen_msg_id}
691 test_emacs '(notmuch-show "id:\"bought\"")
692 (notmuch-show-stash-date)
693 (notmuch-show-stash-from)
694 (notmuch-show-stash-to)
695 (notmuch-show-stash-cc)
696 (notmuch-show-stash-subject)
697 (notmuch-show-stash-message-id)
698 (notmuch-show-stash-message-id-stripped)
699 (notmuch-show-stash-tags)
700 (notmuch-show-stash-filename)
701 (notmuch-show-stash-mlarchive-link "Gmane")
702 (notmuch-show-stash-mlarchive-link "MARC")
703 (notmuch-show-stash-mlarchive-link "Mail Archive, The")
705 (generate-new-buffer "*test-stashing*"))
709 (rotate-yank-pointer 1))
710 (reverse-region (point-min) (point-max))
713 Sat, 01 Jan 2000 12:00:00 +0000
714 Some One <someone@somewhere.org>
715 Some One Else <notsomeone@somewhere.org>
716 Notmuch <notmuch@notmuchmail.org>
722 http://mid.gmane.org/bought
723 http://marc.info/?i=bought
724 http://mail-archive.com/search?l=mid&q=bought
726 test_expect_equal_file OUTPUT EXPECTED
728 test_begin_subtest "Stashing in notmuch-search"
729 test_emacs '(notmuch-search "id:\"bought\"")
731 (notmuch-search-stash-thread-id)
733 (generate-new-buffer "*test-stashing*"))
736 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
737 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
739 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
740 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
741 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
742 test_emacs "(notmuch-show \"$message2\")
743 (test-output \"EXPECTED\")"
744 test_emacs "(notmuch-search \"$message1 or $message2\")
746 (notmuch-search-show-thread)
747 (goto-char (point-max))
749 (notmuch-show-advance-and-archive)
751 test_expect_equal_file OUTPUT EXPECTED
753 test_begin_subtest "Refresh show buffer"
754 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
755 (test-visible-output "EXPECTED")
756 (notmuch-show-refresh-view)
757 (test-visible-output)'
758 test_expect_equal_file OUTPUT EXPECTED
760 test_begin_subtest "Refresh modified show buffer"
761 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
762 (notmuch-show-toggle-message)
763 (notmuch-show-next-message)
764 (notmuch-show-toggle-message)
765 (test-visible-output "EXPECTED")
766 (notmuch-show-refresh-view)
767 (test-visible-output)'
768 test_expect_equal_file OUTPUT EXPECTED
770 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
771 id='message-with-application/mpeg-attachment@notmuchmail.org'
772 emacs_deliver_message \
773 'Message with application/mpeg attachment' \
776 (insert \"Message-ID: <$id>\n\")
778 (mml-insert-part \"application/mpeg\")
779 (insert \"a fake mp3 file\")"
780 notmuch_counter_reset
781 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
782 (notmuch-show \"id:$id\"))"
783 test_expect_equal $(notmuch_counter_value) 1
785 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
786 id='message-with-audio/mpeg-attachment@notmuchmail.org'
787 emacs_deliver_message \
788 'Message with audio/mpeg attachment' \
791 (insert \"Message-ID: <$id>\n\")
793 (mml-insert-part \"audio/mpeg\")
794 (insert \"a fake mp3 file\")"
795 notmuch_counter_reset
796 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
797 (notmuch-show \"id:$id\"))"
798 test_expect_equal $(notmuch_counter_value) 1
800 test_begin_subtest "notmuch-hello-mode hook is called"
801 counter=$(test_emacs \
802 '(let ((notmuch-hello-mode-hook-counter 0))
803 (kill-buffer "*notmuch-hello*")
805 notmuch-hello-mode-hook-counter)'
807 test_expect_equal "$counter" 1
809 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
810 counter=$(test_emacs \
811 '(let ((notmuch-hello-mode-hook-counter 0))
812 (kill-buffer "*notmuch-hello*")
814 (notmuch-hello-update)
815 notmuch-hello-mode-hook-counter)'
817 test_expect_equal "$counter" 1
819 test_begin_subtest "notmuch-hello-refresh hook is called"
820 counter=$(test_emacs \
821 '(let ((notmuch-hello-refresh-hook-counter 0))
822 (kill-buffer "*notmuch-hello*")
824 notmuch-hello-refresh-hook-counter)'
826 test_expect_equal "$counter" 1
828 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
829 counter=$(test_emacs \
830 '(let ((notmuch-hello-refresh-hook-counter 0))
831 (kill-buffer "*notmuch-hello*")
833 (notmuch-hello-update)
834 notmuch-hello-refresh-hook-counter)'
836 test_expect_equal "$counter" 2
839 add_message '[subject]="HTML mail with images"' \
840 '[content-type]="multipart/related; boundary=abcd"' \
842 Content-Type: text/html
844 <img src="cid:330@goomoji.gmail"> smiley
847 Content-Type: image/gif
848 Content-Transfer-Encoding: base64
849 Content-ID: <330@goomoji.gmail>
851 R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMl
852 WLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7
854 test_emacs "(let ((mm-text-html-renderer
855 (if (assq 'shr mm-text-html-renderer-alist)
857 (notmuch-show \"id:${gen_msg_id}\"))
858 (test-output)" > /dev/null
859 # Different Emacs versions and renderers give very different results,
860 # so just check that something reasonable showed up. We first cat the
861 # output so the test framework will print it if the test fails.
862 test_expect_success "Rendering HTML mail with images" \
863 'cat OUTPUT && grep -q smiley OUTPUT'
866 test_begin_subtest "Search handles subprocess error exit codes"
867 cat > notmuch_fail <<EOF
872 chmod a+x notmuch_fail
873 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
874 (with-current-buffer \"*Messages*\" (erase-buffer))
875 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
877 (notmuch-search \"tag:inbox\")
879 (with-current-buffer \"*Messages*\"
880 (test-output \"MESSAGES\"))
881 (with-current-buffer \"*Notmuch errors*\"
882 (test-output \"ERROR\"))
885 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
887 End of search results.
889 YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
892 YYY/notmuch_fail exited with status 1
893 command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox
896 test_begin_subtest "Search handles subprocess warnings"
897 cat > notmuch_fail <<EOF
900 echo This is a warning >&2
901 echo This is another warning >&2
904 chmod a+x notmuch_fail
905 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
906 (with-current-buffer \"*Messages*\" (erase-buffer))
907 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
909 (notmuch-search \"tag:inbox\")
911 (with-current-buffer \"*Messages*\"
912 (test-output \"MESSAGES\"))
913 (with-current-buffer \"*Notmuch errors*\"
914 (test-output \"ERROR\"))
916 sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
917 test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
918 End of search results.
920 This is a warning (see *Notmuch errors* for more details)
924 This is another warning"
926 test_begin_subtest "Search thread tag operations are race-free"
927 add_message '[subject]="Search race test"'
928 gen_msg_id_1=$gen_msg_id
929 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
930 '[references]="<'$gen_msg_id_1'>"' \
931 '[subject]="Search race test two"'
932 test_emacs '(notmuch-search "subject:\"search race test\"")
935 (execute-kbd-macro "+search-thread-race-tag")'
936 output=$(notmuch search --output=messages 'tag:search-thread-race-tag')
937 test_expect_equal "$output" "id:$gen_msg_id_1"
939 test_begin_subtest "Search global tag operations are race-free"
940 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
941 '[references]="<'$gen_msg_id_1'>"' \
942 '[subject]="Re: Search race test"'
943 test_emacs '(notmuch-search "subject:\"search race test\" -subject:two")
946 (execute-kbd-macro "*+search-global-race-tag")'
947 output=$(notmuch search --output=messages 'tag:search-global-race-tag')
948 test_expect_equal "$output" "id:$gen_msg_id_1"