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',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
197 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
198 -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
200 From: Notmuch Test Suite <test_suite@notmuchmail.org>
202 Subject: Testing message sent via SMTP
203 Date: 01 Jan 2000 12:00:00 -0000
204 User-Agent: Notmuch/XXX Emacs/XXX
207 Content-Type: text/plain
209 This is a test that messages are sent via SMTP
211 test_expect_equal_file OUTPUT EXPECTED
213 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
214 notmuch new > /dev/null
215 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
216 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
218 test_begin_subtest "notmuch-fcc-dirs set to nil"
219 test_emacs "(let ((notmuch-fcc-dirs nil))
223 From: Notmuch Test Suite <test_suite@notmuchmail.org>
226 --text follows this line--
228 test_expect_equal_file OUTPUT EXPECTED
230 # Make another FCC maildir specific for the next test
231 mkdir -p mail/sent-string/cur
232 mkdir -p mail/sent-string/new
233 mkdir -p mail/sent-string/tmp
235 test_begin_subtest "notmuch-fcc-dirs set to a string"
236 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
240 From: Notmuch Test Suite <test_suite@notmuchmail.org>
243 Fcc: ${MAIL_DIR}/sent-string
244 --text follows this line--
246 test_expect_equal_file OUTPUT EXPECTED
248 # Make more FCC maildirs specific for the next test
249 mkdir -p mail/sent-list-match/cur
250 mkdir -p mail/sent-list-match/new
251 mkdir -p mail/sent-list-match/tmp
252 mkdir -p mail/failure/cur
253 mkdir -p mail/failure/new
254 mkdir -p mail/failure/tmp
256 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
257 test_emacs "(let ((notmuch-fcc-dirs
258 '((\"notmuchmail.org\" . \"sent-list-match\")
259 (\".*\" . \"failure\"))))
263 From: Notmuch Test Suite <test_suite@notmuchmail.org>
266 Fcc: ${MAIL_DIR}/sent-list-match
267 --text follows this line--
269 test_expect_equal_file OUTPUT EXPECTED
271 # Make another FCC maildir specific for the next test
272 mkdir -p mail/sent-list-catch-all/cur
273 mkdir -p mail/sent-list-catch-all/new
274 mkdir -p mail/sent-list-catch-all/tmp
276 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
277 test_emacs "(let ((notmuch-fcc-dirs
278 '((\"example.com\" . \"failure\")
279 (\".*\" . \"sent-list-catch-all\"))))
283 From: Notmuch Test Suite <test_suite@notmuchmail.org>
286 Fcc: ${MAIL_DIR}/sent-list-catch-all
287 --text follows this line--
289 test_expect_equal_file OUTPUT EXPECTED
291 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
292 test_emacs "(let ((notmuch-fcc-dirs
293 '((\"example.com\" . \"failure\")
294 (\"nomatchhere.net\" . \"failure\"))))
298 From: Notmuch Test Suite <test_suite@notmuchmail.org>
301 --text follows this line--
303 test_expect_equal_file OUTPUT EXPECTED
305 test_begin_subtest "Reply within emacs"
306 test_emacs '(let ((message-hidden-headers ''()))
307 (notmuch-search "subject:\"testing message sent via SMTP\"")
309 (notmuch-search-reply-to-thread)
311 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
312 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
313 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
315 From: Notmuch Test Suite <test_suite@notmuchmail.org>
317 Subject: Re: Testing message sent via SMTP
319 Fcc: ${MAIL_DIR}/sent
321 User-Agent: Notmuch/XXX Emacs/XXX
322 --text follows this line--
323 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
325 > This is a test that messages are sent via SMTP
327 test_expect_equal_file OUTPUT EXPECTED
329 test_begin_subtest "Reply from alternate address within emacs"
330 add_message '[from]="Sender <sender@example.com>"' \
331 [to]=test_suite_other@notmuchmail.org
333 test_emacs "(let ((message-hidden-headers '()))
334 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
336 (notmuch-search-reply-to-thread)
338 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
340 From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
341 To: Sender <sender@example.com>
342 Subject: Re: ${test_subtest_name}
343 In-Reply-To: <${gen_msg_id}>
344 Fcc: ${MAIL_DIR}/sent
345 References: <${gen_msg_id}>
346 User-Agent: Notmuch/XXX Emacs/XXX
347 --text follows this line--
348 Sender <sender@example.com> writes:
350 > This is just a test message (#${gen_msg_cnt})
352 test_expect_equal_file OUTPUT EXPECTED
354 test_begin_subtest "Reply from address in named group list within emacs"
355 add_message '[from]="Sender <sender@example.com>"' \
356 '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
357 [cc]=test_suite_other@notmuchmail.org
359 test_emacs "(let ((message-hidden-headers '()))
360 (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
362 (notmuch-search-reply-to-thread)
364 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
366 From: Notmuch Test Suite <test_suite@notmuchmail.org>
367 To: Sender <sender@example.com>, someone@example.com
368 Subject: Re: ${test_subtest_name}
369 In-Reply-To: <${gen_msg_id}>
370 Fcc: ${MAIL_DIR}/sent
371 References: <${gen_msg_id}>
372 User-Agent: Notmuch/XXX Emacs/XXX
373 --text follows this line--
374 Sender <sender@example.com> writes:
376 > This is just a test message (#${gen_msg_cnt})
378 test_expect_equal_file OUTPUT EXPECTED
380 test_begin_subtest "Reply within emacs to a multipart/mixed message"
381 test_emacs '(let ((message-hidden-headers ''()))
382 (notmuch-show "id:20091118002059.067214ed@hikari")
385 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
387 From: Notmuch Test Suite <test_suite@notmuchmail.org>
388 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
389 Subject: Re: [notmuch] Introducing myself
390 In-Reply-To: <20091118002059.067214ed@hikari>
391 Fcc: ${MAIL_DIR}/sent
392 References: <20091118002059.067214ed@hikari>
393 User-Agent: Notmuch/XXX Emacs/XXX
394 --text follows this line--
395 Adrian Perez de Castro <aperez@igalia.com> writes:
397 > [ Unknown signature status ]
401 > I have just heard about Not Much today in some random Linux-related news
402 > site (LWN?), my name is Adrian Perez and I work as systems administrator
403 > (although I can do some code as well :P). I have always thought that the
404 > ideas behind Sup were great, but after some time using it, I got tired of
405 > the oddities that it has. I also do not like doing things like having to
406 > install Ruby just for reading and sorting mails. Some time ago I thought
407 > about doing something like Not Much and in fact I played a bit with the
408 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
409 > to code things in Python when I am not working and also it is installed
410 > by default on most distribution. I got to have some mailboxes indexed and
411 > basic searching working a couple of months ago. Lately I have been very
412 > busy and had no time for coding, and them... boom! Not Much appears -- and
413 > it is almost exactly what I was trying to do, but faster. I have been
414 > playing a bit with Not Much today, and I think it has potential.
416 > Also, I would like to share one idea I had in mind, that you might find
417 > interesting: One thing I have found very annoying is having to re-tag my
418 > mail when the indexes get b0rked (it happened a couple of times to me while
419 > using Sup), so I was planning to mails as read/unread and adding the tags
420 > not just to the index, but to the mail text itself, e.g. by adding a
421 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
422 > could be totally recreated by re-reading the mail directories, and this
423 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
424 > local maildir, tagging and indexing the mails with the e-mail reader and
425 > then syncing back the messages with the "X-Tags" header to the IMAP server.
426 > This would allow to use the mail reader from a different computer and still
427 > have everything tagged finely.
433 > [1] http://software.complete.org/software/projects/show/offlineimap
436 > Adrian Perez de Castro <aperez@igalia.com>
437 > Igalia - Free Software Engineering
438 > _______________________________________________
439 > notmuch mailing list
440 > notmuch@notmuchmail.org
441 > http://notmuchmail.org/mailman/listinfo/notmuch
443 test_expect_equal_file OUTPUT EXPECTED
445 test_begin_subtest "Reply within emacs to a multipart/alternative message"
446 test_emacs '(let ((message-hidden-headers ''()))
447 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
450 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
452 From: Notmuch Test Suite <test_suite@notmuchmail.org>
453 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
454 Subject: Re: [notmuch] preliminary FreeBSD support
455 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
456 Fcc: ${MAIL_DIR}/sent
457 References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
458 User-Agent: Notmuch/XXX Emacs/XXX
459 --text follows this line--
460 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
462 > I saw the announcement this morning, and was very excited, as I had been
463 > hoping sup would be turned into a library,
464 > since I like the concept more than the UI (I'd rather an emacs interface).
466 > I did a preliminary compile which worked out fine, but
467 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
468 > FreeBSD, so notmuch_config_open segfaulted.
470 > Attached is a patch that supplies a default buffer size of 64 in cases where
473 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
474 > is acceptable behavior,
475 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
478 > From e3bc4bbd7b9d0d086816ab5f8f2d6ffea1dd3ea4 Mon Sep 17 00:00:00 2001
479 > From: Alexander Botero-Lowry <alex.boterolowry@gmail.com>
480 > Date: Tue, 17 Nov 2009 11:30:39 -0800
481 > Subject: [PATCH] Deal with situation where sysconf(_SC_GETPW_R_SIZE_MAX) returns -1
484 > notmuch-config.c | 2 ++
485 > 1 files changed, 2 insertions(+), 0 deletions(-)
487 > diff --git a/notmuch-config.c b/notmuch-config.c
488 > index 248149c..e7220d8 100644
489 > --- a/notmuch-config.c
490 > +++ b/notmuch-config.c
491 > @@ -77,6 +77,7 @@ static char *
492 > get_name_from_passwd_file (void *ctx)
494 > long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
495 > + if (pw_buf_size == -1) pw_buf_size = 64;
496 > char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
497 > struct passwd passwd, *ignored;
499 > @@ -101,6 +102,7 @@ static char *
500 > get_username_from_passwd_file (void *ctx)
502 > long pw_buf_size = sysconf(_SC_GETPW_R_SIZE_MAX);
503 > + if (pw_buf_size == -1) pw_buf_size = 64;
504 > char *pw_buf = talloc_zero_size (ctx, pw_buf_size);
505 > struct passwd passwd, *ignored;
510 > _______________________________________________
511 > notmuch mailing list
512 > notmuch@notmuchmail.org
513 > http://notmuchmail.org/mailman/listinfo/notmuch
515 test_expect_equal_file OUTPUT EXPECTED
517 test_begin_subtest "Reply within emacs to an html-only message"
518 add_message '[content-type]="text/html"' \
519 '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
520 test_emacs "(let ((message-hidden-headers '()))
521 (notmuch-show \"id:${gen_msg_id}\")
524 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
526 From: Notmuch Test Suite <test_suite@notmuchmail.org>
528 Subject: Re: Reply within emacs to an html-only message
529 In-Reply-To: <${gen_msg_id}>
530 Fcc: ${MAIL_DIR}/sent
531 References: <${gen_msg_id}>
532 User-Agent: Notmuch/XXX Emacs/XXX
533 --text follows this line--
534 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
536 > Hi,This is an HTML test message.OK?
538 test_expect_equal_file OUTPUT EXPECTED
540 test_begin_subtest "Quote MML tags in reply"
541 message_id='test-emacs-mml-quoting@message.id'
542 add_message [id]="$message_id" \
543 "[subject]='$test_subtest_name'" \
544 '[body]="<#part disposition=inline>"'
545 test_emacs "(let ((message-hidden-headers '()))
546 (notmuch-show \"id:$message_id\")
549 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
551 From: Notmuch Test Suite <test_suite@notmuchmail.org>
553 Subject: Re: Quote MML tags in reply
554 In-Reply-To: <test-emacs-mml-quoting@message.id>
555 Fcc: ${MAIL_DIR}/sent
556 References: <test-emacs-mml-quoting@message.id>
557 User-Agent: Notmuch/XXX Emacs/XXX
558 --text follows this line--
559 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
561 > <#!part disposition=inline>
563 test_expect_equal_file OUTPUT EXPECTED
565 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
566 # save as archive to test that Emacs does not re-compress .gz
567 test_emacs '(let ((standard-input "\"attachment1.gz\""))
568 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
569 (notmuch-show-save-attachments))'
570 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
572 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
573 # save as archive to test that Emacs does not re-compress .gz
574 test_emacs '(let ((standard-input "\"attachment2.gz\""))
575 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
576 (search-forward "0001-Deal-with")
577 (notmuch-show-save-part))'
578 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
580 test_begin_subtest "Save 8bit attachment from within emacs using notmuch-show-save-attachments"
582 add_message '[subject]="Attachment with 8bit chars"' \
583 '[header]="MIME-Version: 1.0"' \
584 '[content-type]="multipart/mixed; boundary=\"abcd\""' \
586 Content-Type: text/plain
591 Content-Type: application/octet-stream; name=\"sample\"
592 Content-Transfer-Encoding: 8bit
593 Content-Disposition: attachment; filename=\"sample\"
595 “¡ Hey ! It compiles ¡ Ship it !”
599 test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
600 (delete-file "OUTPUT")
601 (let ((standard-input "\"OUTPUT\""))
602 (notmuch-show-save-attachments))'
604 test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
606 test_begin_subtest "View raw message within emacs"
607 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
608 (notmuch-show-view-raw-message)
610 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
612 test_begin_subtest "Hiding/showing signature in notmuch-show view"
613 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
614 test_emacs "(notmuch-show \"$maildir_storage_thread\")
615 (search-forward \"Click/Enter to show.\")
616 (button-activate (button-at (point)))
617 (search-backward \"Click/Enter to hide.\")
618 (button-activate (button-at (point)))
620 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
622 test_begin_subtest "Detection and hiding of top-post quoting of message"
623 add_message '[subject]="The problem with top-posting"' \
624 [id]=top-post-target \
625 '[body]="A: Because it messes up the order in which people normally read text.
626 Q: Why is top-posting such a bad thing?
628 Q: What is the most annoying thing in e-mail?"'
629 add_message '[from]="Top Poster <top@poster.com>"' \
630 [in-reply-to]=top-post-target \
631 [references]=top-post-target \
632 '[subject]="Re: The problem with top-posting"' \
633 '[body]="Thanks for the advice! I will be sure to put it to good use.
637 ----- Original Message -----
638 From: Notmuch Test Suite <test_suite@notmuchmail.org>
639 To: Notmuch Test Suite <test_suite@notmuchmai.org>
640 Sent: Fri, 05 Jan 2001 15:43:57 +0000
641 Subject: The problem with top-posting
643 Q: Why is top-posting such a bad thing?
645 Q: What is the most annoying thing in e-mail?"'
646 test_emacs "(notmuch-show \"top-posting\")
647 (test-visible-output \"OUTPUT.raw\")"
648 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
649 Subject: The problem with top-posting
650 To: Notmuch Test Suite <test_suite@notmuchmail.org>
653 A: Because it messes up the order in which people normally read text.
654 Q: Why is top-posting such a bad thing?
656 Q: What is the most annoying thing in e-mail?
657 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
658 Subject: Re: The problem with top-posting
659 To: Notmuch Test Suite <test_suite@notmuchmail.org>
662 Thanks for the advice! I will be sure to put it to good use.
666 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
667 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
668 test_expect_equal_file OUTPUT EXPECTED
670 test_begin_subtest "Hiding message in notmuch-show view"
671 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
672 (notmuch-show-toggle-message)
673 (test-visible-output)'
674 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
676 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
677 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
678 (search-forward "Click/Enter to show.")
679 (button-activate (button-at (point)))
680 (notmuch-show-toggle-message)
681 (test-visible-output)'
682 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
684 test_begin_subtest "notmuch-show: show message 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 (test-visible-output))'
690 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-visible
692 test_begin_subtest "notmuch-show: hide message headers"
694 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
695 (notmuch-message-headers-visible nil))
696 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
697 (test-visible-output))'
698 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
700 test_begin_subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-visibility-headers)"
702 '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
703 (notmuch-message-headers-visible t))
704 (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
705 (notmuch-show-toggle-visibility-headers)
706 (test-visible-output))'
707 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
709 test_begin_subtest "notmuch-show: collapse all messages in thread"
710 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
711 (let ((current-prefix-arg t))
712 (notmuch-show-open-or-close-all)
713 (test-visible-output))'
714 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-collapsed
716 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
717 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
718 (notmuch-show-open-or-close-all)
719 (test-visible-output)'
720 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed
722 test_begin_subtest "Stashing in notmuch-show"
723 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
724 '[from]="Some One <someone@somewhere.org>"' \
725 '[to]="Some One Else <notsomeone@somewhere.org>"' \
726 '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
727 '[subject]="Stash my stashables"' \
729 '[body]="Unable to stash body. Where did you get it in the first place?!?"'
730 notmuch tag +stashtest id:${gen_msg_id}
731 test_emacs '(notmuch-show "id:\"bought\"")
732 (notmuch-show-stash-date)
733 (notmuch-show-stash-from)
734 (notmuch-show-stash-to)
735 (notmuch-show-stash-cc)
736 (notmuch-show-stash-subject)
737 (notmuch-show-stash-message-id)
738 (notmuch-show-stash-message-id-stripped)
739 (notmuch-show-stash-tags)
740 (notmuch-show-stash-filename)
741 (notmuch-show-stash-mlarchive-link "Gmane")
742 (notmuch-show-stash-mlarchive-link "MARC")
743 (notmuch-show-stash-mlarchive-link "Mail Archive, The")
745 (generate-new-buffer "*test-stashing*"))
749 (rotate-yank-pointer 1))
750 (reverse-region (point-min) (point-max))
753 Sat, 01 Jan 2000 12:00:00 +0000
754 Some One <someone@somewhere.org>
755 Some One Else <notsomeone@somewhere.org>
756 Notmuch <notmuch@notmuchmail.org>
762 http://mid.gmane.org/bought
763 https://marc.info/?i=bought
764 https://mid.mail-archive.com/bought
766 test_expect_equal_file OUTPUT EXPECTED
768 test_begin_subtest "Stashing in notmuch-search"
769 test_emacs '(notmuch-search "id:\"bought\"")
771 (notmuch-search-stash-thread-id)
773 (generate-new-buffer "*test-stashing*"))
776 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
777 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
779 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
780 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
781 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
782 test_emacs "(notmuch-show \"$message2\")
783 (test-output \"EXPECTED\")"
784 test_emacs "(notmuch-search \"$message1 or $message2\")
786 (notmuch-search-show-thread)
787 (goto-char (point-max))
789 (notmuch-show-advance-and-archive)
791 test_expect_equal_file OUTPUT EXPECTED
793 test_begin_subtest "Refresh show buffer"
794 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
795 (test-visible-output "EXPECTED")
796 (notmuch-show-refresh-view)
797 (test-visible-output)'
798 test_expect_equal_file OUTPUT EXPECTED
800 test_begin_subtest "Refresh modified show buffer"
801 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
802 (notmuch-show-toggle-message)
803 (notmuch-show-next-message)
804 (notmuch-show-toggle-message)
805 (test-visible-output "EXPECTED")
806 (notmuch-show-refresh-view)
807 (test-visible-output)'
808 test_expect_equal_file OUTPUT EXPECTED
810 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
811 id='message-with-application/mpeg-attachment@notmuchmail.org'
813 'Message with application/mpeg attachment' \
816 (insert \"Message-ID: <$id>\n\")
818 (mml-insert-part \"application/mpeg\")
819 (insert \"a fake mp3 file\")"
820 notmuch_counter_reset
821 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
822 (notmuch-show \"id:$id\"))"
823 test_expect_equal $(notmuch_counter_value) 1
825 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
826 id='message-with-audio/mpeg-attachment@notmuchmail.org'
828 'Message with audio/mpeg attachment' \
831 (insert \"Message-ID: <$id>\n\")
833 (mml-insert-part \"audio/mpeg\")
834 (insert \"a fake mp3 file\")"
835 notmuch_counter_reset
836 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
837 (notmuch-show \"id:$id\"))"
838 test_expect_equal $(notmuch_counter_value) 1
840 test_begin_subtest "notmuch-hello-mode hook is called"
841 counter=$(test_emacs \
842 '(let ((notmuch-hello-mode-hook-counter 0))
843 (kill-buffer "*notmuch-hello*")
845 notmuch-hello-mode-hook-counter)'
847 test_expect_equal "$counter" 1
849 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
850 counter=$(test_emacs \
851 '(let ((notmuch-hello-mode-hook-counter 0))
852 (kill-buffer "*notmuch-hello*")
854 (notmuch-hello-update)
855 notmuch-hello-mode-hook-counter)'
857 test_expect_equal "$counter" 1
859 test_begin_subtest "notmuch-hello-refresh hook is called"
860 counter=$(test_emacs \
861 '(let ((notmuch-hello-refresh-hook-counter 0))
862 (kill-buffer "*notmuch-hello*")
864 notmuch-hello-refresh-hook-counter)'
866 test_expect_equal "$counter" 1
868 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
869 counter=$(test_emacs \
870 '(let ((notmuch-hello-refresh-hook-counter 0))
871 (kill-buffer "*notmuch-hello*")
873 (notmuch-hello-update)
874 notmuch-hello-refresh-hook-counter)'
876 test_expect_equal "$counter" 2
879 add_message '[subject]="HTML mail with images"' \
880 '[content-type]="multipart/related; boundary=abcd"' \
882 Content-Type: text/html
884 <img src="cid:330@goomoji.gmail"> smiley
887 Content-Type: image/gif
888 Content-Transfer-Encoding: base64
889 Content-ID: <330@goomoji.gmail>
891 R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMl
892 WLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7
894 test_emacs "(let ((mm-text-html-renderer
895 (if (assq 'shr mm-text-html-renderer-alist)
897 (notmuch-show \"id:${gen_msg_id}\"))
898 (test-output)" > /dev/null
899 # Different Emacs versions and renderers give very different results,
900 # so just check that something reasonable showed up. We first cat the
901 # output so the test framework will print it if the test fails.
902 test_expect_success "Rendering HTML mail with images" \
903 'cat OUTPUT && grep -q smiley OUTPUT'
906 test_begin_subtest "Search handles subprocess error exit codes"
907 cat > notmuch_fail <<EOF
912 chmod a+x notmuch_fail
913 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
914 (with-current-buffer \"*Messages*\"
915 (let ((inhibit-read-only t)) (erase-buffer)))
916 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
918 (notmuch-search \"tag:inbox\")
920 (with-current-buffer \"*Messages*\"
921 (test-output \"MESSAGES\"))
922 (with-current-buffer \"*Notmuch errors*\"
923 (test-output \"ERROR\"))
926 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
928 End of search results.
930 YYY/notmuch_fail exited with status 1 (see *Notmuch errors* for more details)
933 YYY/notmuch_fail exited with status 1
934 command: YYY/notmuch_fail search --format\=sexp --format-version\=2 --sort\=newest-first tag\:inbox
937 test_begin_subtest "Search handles subprocess warnings"
938 cat > notmuch_fail <<EOF
941 echo This is a warning >&2
942 echo This is another warning >&2
945 chmod a+x notmuch_fail
946 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
947 (with-current-buffer \"*Messages*\"
948 (let ((inhibit-read-only t)) (erase-buffer)))
949 (with-current-buffer (get-buffer-create \"*Notmuch errors*\")
951 (notmuch-search \"tag:inbox\")
953 (with-current-buffer \"*Messages*\"
954 (test-output \"MESSAGES\"))
955 (with-current-buffer \"*Notmuch errors*\"
956 (test-output \"ERROR\"))
958 sed -i -e 's/^\[.*\]$/[XXX]/' ERROR
959 test_expect_equal "$(cat OUTPUT; echo ---; cat MESSAGES; echo ---; cat ERROR)" "\
960 End of search results.
962 This is a warning (see *Notmuch errors* for more details)
966 This is another warning"
968 test_begin_subtest "Search thread tag operations are race-free"
969 add_message '[subject]="Search race test"'
970 gen_msg_id_1=$gen_msg_id
971 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
972 '[references]="<'$gen_msg_id_1'>"' \
973 '[subject]="Search race test two"'
974 test_emacs '(notmuch-search "subject:\"search race test\"")
977 (execute-kbd-macro "+search-thread-race-tag")'
978 output=$(notmuch search --output=messages 'tag:search-thread-race-tag')
979 test_expect_equal "$output" "id:$gen_msg_id_1"
981 test_begin_subtest "Search global tag operations are race-free"
982 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
983 '[references]="<'$gen_msg_id_1'>"' \
984 '[subject]="Re: Search race test"'
985 test_emacs '(notmuch-search "subject:\"search race test\" -subject:two")
988 (execute-kbd-macro "*+search-global-race-tag")'
989 output=$(notmuch search --output=messages 'tag:search-global-race-tag')
990 test_expect_equal "$output" "id:$gen_msg_id_1"
992 test_begin_subtest "Term escaping"
993 output=$(test_emacs "(mapcar 'notmuch-escape-boolean-term (list
995 \"abc\`~\!@#\$%^&*-=_+123\"
1000 \"\\x201cxyz\\x201d\"))")
1001 test_expect_equal "$output" '("\"\"" "abc`~!@#$%^&*-=_+123" "\"(abc\"" "\")abc\"" "\"\"\"abc\"" "\"'$'\x01''xyz\"" "\"“xyz”\"")'