]> git.notmuchmail.org Git - notmuch/blob - test/emacs
test: add sanity check for dump --format=batch-tag.
[notmuch] / test / emacs
1 #!/usr/bin/env bash
2
3 test_description="emacs interface"
4 . ./test-lib.sh
5
6 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
7
8 add_email_corpus
9
10 test_begin_subtest "Basic notmuch-hello view in emacs"
11 test_emacs '(notmuch-hello)
12             (test-output)'
13 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
14
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"))))
21               (notmuch-hello)
22               (test-output))'
23 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
24
25 test_begin_subtest "No saved searches displayed (all with 0 results)"
26 test_emacs '(let ((notmuch-saved-searches
27                    '\''(("empty" . "tag:doesnotexist"))))
28               (notmuch-hello)
29               (test-output))'
30 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
31
32 test_begin_subtest "Basic notmuch-search view in emacs"
33 test_emacs '(notmuch-search "tag:inbox")
34             (notmuch-test-wait)
35             (test-output)'
36 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
37
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\")
42             (notmuch-test-wait)
43             (ad-disable-advice 'notmuch-search-process-filter 'around 'pessimal)
44             (ad-activate 'notmuch-search-process-filter)
45             (test-output)"
46 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
47
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)))
53             (notmuch-test-wait)
54             (test-output)'
55 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
56
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\")
60             (test-output)"
61 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
62
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\")
67               (test-output))"
68 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
69
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\")
74               (test-output))"
75 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation
76
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\")
81               (test-output))"
82 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation
83
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)"
90 cat <<EOF >EXPECTED
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
95
96 This is just a test message (#1)
97 EOF
98 test_expect_equal_file OUTPUT EXPECTED
99
100 test_begin_subtest "Navigation of notmuch-search to thread view"
101 test_emacs '(notmuch-search "tag:inbox")
102             (notmuch-test-wait)
103             (goto-char (point-min))
104             (re-search-forward "Working with Maildir")
105             (notmuch-search-show-thread)
106             (notmuch-test-wait)
107             (test-output)'
108 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
109
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\")
113             (notmuch-test-wait)
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)"
117
118 test_begin_subtest "Remove tag from search view"
119 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
120             (notmuch-test-wait)
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)"
124
125 test_begin_subtest "Add tag from notmuch-show view"
126 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
127             (execute-kbd-macro \"+tag-from-show-view\")"
128 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
129 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)"
130
131 test_begin_subtest "Remove tag from notmuch-show view"
132 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
133             (execute-kbd-macro \"-tag-from-show-view\")"
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 unread)"
136
137 test_begin_subtest "Message with .. in Message-Id:"
138 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
139 test_emacs '(notmuch-search "id:\"123..456@example\"")
140             (notmuch-test-wait)
141             (execute-kbd-macro "+search-add")
142             (execute-kbd-macro "+search-remove")
143             (execute-kbd-macro "-search-remove")
144             (notmuch-show "id:\"123..456@example\"")
145             (notmuch-test-wait)
146             (execute-kbd-macro "+show-add")
147             (execute-kbd-macro "+show-remove")
148             (execute-kbd-macro "-show-remove")'
149 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
150 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
151
152 test_begin_subtest "Message with quote in Message-Id:"
153 add_message '[id]="\"quote\"@example"' '[subject]="Message with quote in Message-Id"'
154 test_emacs '(notmuch-search "subject:\"Message with quote\"")
155             (notmuch-test-wait)
156             (execute-kbd-macro "+search-add")
157             (notmuch-search-show-thread)
158             (notmuch-test-wait)
159             (execute-kbd-macro "+show-add")'
160 output=$(notmuch search 'id:"""quote""@example"' | notmuch_search_sanitize)
161 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)"
162
163 test_begin_subtest "Sending a message via (fake) SMTP"
164 emacs_deliver_message \
165     'Testing message sent via SMTP' \
166     'This is a test that messages are sent via SMTP' \
167     '(message-goto-to)
168      (kill-whole-line)
169      (insert "To: user@example.com\n")'
170 sed \
171     -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
172     -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' \
173     -e s',^\(Content-Type: text/plain\); charset=us-ascii$,\1,' < sent_message >OUTPUT
174 cat <<EOF >EXPECTED
175 From: Notmuch Test Suite <test_suite@notmuchmail.org>
176 To: user@example.com
177 Subject: Testing message sent via SMTP
178 Date: 01 Jan 2000 12:00:00 -0000
179 User-Agent: Notmuch/XXX Emacs/XXX
180 Message-ID: <XXX>
181 MIME-Version: 1.0
182 Content-Type: text/plain
183
184 This is a test that messages are sent via SMTP
185 EOF
186 test_expect_equal_file OUTPUT EXPECTED
187
188 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
189 notmuch new > /dev/null
190 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
191 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
192
193 test_begin_subtest "notmuch-fcc-dirs set to nil"
194 test_emacs "(let ((notmuch-fcc-dirs nil))
195               (notmuch-mua-mail)
196               (test-output))"
197 cat <<EOF >EXPECTED
198 From: Notmuch Test Suite <test_suite@notmuchmail.org>
199 To: 
200 Subject: 
201 --text follows this line--
202 EOF
203 test_expect_equal_file OUTPUT EXPECTED
204
205 # Make another FCC maildir specific for the next test
206 mkdir -p mail/sent-string/cur
207 mkdir -p mail/sent-string/new
208 mkdir -p mail/sent-string/tmp
209
210 test_begin_subtest "notmuch-fcc-dirs set to a string"
211 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
212               (notmuch-mua-mail)
213               (test-output))"
214 cat <<EOF >EXPECTED
215 From: Notmuch Test Suite <test_suite@notmuchmail.org>
216 To: 
217 Subject: 
218 Fcc: ${MAIL_DIR}/sent-string
219 --text follows this line--
220 EOF
221 test_expect_equal_file OUTPUT EXPECTED
222
223 # Make more FCC maildirs specific for the next test
224 mkdir -p mail/sent-list-match/cur
225 mkdir -p mail/sent-list-match/new
226 mkdir -p mail/sent-list-match/tmp
227 mkdir -p mail/failure/cur
228 mkdir -p mail/failure/new
229 mkdir -p mail/failure/tmp
230
231 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
232 test_emacs "(let ((notmuch-fcc-dirs
233                    '((\"notmuchmail.org\" . \"sent-list-match\")
234                      (\".*\" . \"failure\"))))
235               (notmuch-mua-mail)
236               (test-output))"
237 cat <<EOF >EXPECTED
238 From: Notmuch Test Suite <test_suite@notmuchmail.org>
239 To: 
240 Subject: 
241 Fcc: ${MAIL_DIR}/sent-list-match
242 --text follows this line--
243 EOF
244 test_expect_equal_file OUTPUT EXPECTED
245
246 # Make another FCC maildir specific for the next test
247 mkdir -p mail/sent-list-catch-all/cur
248 mkdir -p mail/sent-list-catch-all/new
249 mkdir -p mail/sent-list-catch-all/tmp
250
251 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
252 test_emacs "(let ((notmuch-fcc-dirs
253                    '((\"example.com\" . \"failure\")
254                      (\".*\" . \"sent-list-catch-all\"))))
255               (notmuch-mua-mail)
256               (test-output))"
257 cat <<EOF >EXPECTED
258 From: Notmuch Test Suite <test_suite@notmuchmail.org>
259 To: 
260 Subject: 
261 Fcc: ${MAIL_DIR}/sent-list-catch-all
262 --text follows this line--
263 EOF
264 test_expect_equal_file OUTPUT EXPECTED
265
266 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
267 test_emacs "(let ((notmuch-fcc-dirs
268                    '((\"example.com\" . \"failure\")
269                      (\"nomatchhere.net\" . \"failure\"))))
270               (notmuch-mua-mail)
271               (test-output))"
272 cat <<EOF >EXPECTED
273 From: Notmuch Test Suite <test_suite@notmuchmail.org>
274 To: 
275 Subject: 
276 --text follows this line--
277 EOF
278 test_expect_equal_file OUTPUT EXPECTED
279
280 test_begin_subtest "Reply within emacs"
281 test_emacs '(let ((message-hidden-headers ''()))
282             (notmuch-search "subject:\"testing message sent via SMTP\"")
283             (notmuch-test-wait)
284             (notmuch-search-reply-to-thread)
285             (test-output))'
286 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
287 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
288 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
289 cat <<EOF >EXPECTED
290 From: Notmuch Test Suite <test_suite@notmuchmail.org>
291 To: user@example.com
292 Subject: Re: Testing message sent via SMTP
293 In-Reply-To: <XXX>
294 Fcc: ${MAIL_DIR}/sent
295 References: <XXX>
296 User-Agent: Notmuch/XXX Emacs/XXX
297 --text follows this line--
298 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
299
300 > This is a test that messages are sent via SMTP
301 EOF
302 test_expect_equal_file OUTPUT EXPECTED
303
304 test_begin_subtest "Reply from alternate address within emacs"
305 add_message '[from]="Sender <sender@example.com>"' \
306              [to]=test_suite_other@notmuchmail.org
307
308 test_emacs "(let ((message-hidden-headers '()))
309             (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
310             (notmuch-test-wait)
311             (notmuch-search-reply-to-thread)
312             (test-output))"
313 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
314 cat <<EOF >EXPECTED
315 From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
316 To: Sender <sender@example.com>
317 Subject: Re: ${test_subtest_name}
318 In-Reply-To: <${gen_msg_id}>
319 Fcc: ${MAIL_DIR}/sent
320 References: <${gen_msg_id}>
321 User-Agent: Notmuch/XXX Emacs/XXX
322 --text follows this line--
323 Sender <sender@example.com> writes:
324
325 > This is just a test message (#${gen_msg_cnt})
326 EOF
327 test_expect_equal_file OUTPUT EXPECTED
328
329 test_begin_subtest "Reply from address in named group list within emacs"
330 add_message '[from]="Sender <sender@example.com>"' \
331             '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
332              [cc]=test_suite_other@notmuchmail.org
333
334 test_emacs "(let ((message-hidden-headers '()))
335             (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
336             (notmuch-test-wait)
337             (notmuch-search-reply-to-thread)
338             (test-output))"
339 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
340 cat <<EOF >EXPECTED
341 From: Notmuch Test Suite <test_suite@notmuchmail.org>
342 To: Sender <sender@example.com>, someone@example.com
343 Subject: Re: ${test_subtest_name}
344 In-Reply-To: <${gen_msg_id}>
345 Fcc: ${MAIL_DIR}/sent
346 References: <${gen_msg_id}>
347 User-Agent: Notmuch/XXX Emacs/XXX
348 --text follows this line--
349 Sender <sender@example.com> writes:
350
351 > This is just a test message (#${gen_msg_cnt})
352 EOF
353 test_expect_equal_file OUTPUT EXPECTED
354
355 test_begin_subtest "Reply within emacs to a multipart/mixed message"
356 test_emacs '(let ((message-hidden-headers ''()))
357             (notmuch-show "id:20091118002059.067214ed@hikari")
358                 (notmuch-show-reply)
359                 (test-output))'
360 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
361 cat <<EOF >EXPECTED
362 From: Notmuch Test Suite <test_suite@notmuchmail.org>
363 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
364 Subject: Re: [notmuch] Introducing myself
365 In-Reply-To: <20091118002059.067214ed@hikari>
366 Fcc: ${MAIL_DIR}/sent
367 References: <20091118002059.067214ed@hikari>
368 User-Agent: Notmuch/XXX Emacs/XXX
369 --text follows this line--
370 Adrian Perez de Castro <aperez@igalia.com> writes:
371
372 > Hello to all,
373 >
374 > I have just heard about Not Much today in some random Linux-related news
375 > site (LWN?), my name is Adrian Perez and I work as systems administrator
376 > (although I can do some code as well :P). I have always thought that the
377 > ideas behind Sup were great, but after some time using it, I got tired of
378 > the oddities that it has. I also do not like doing things like having to
379 > install Ruby just for reading and sorting mails. Some time ago I thought
380 > about doing something like Not Much and in fact I played a bit with the
381 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
382 > to code things in Python when I am not working and also it is installed
383 > by default on most distribution. I got to have some mailboxes indexed and
384 > basic searching working a couple of months ago. Lately I have been very
385 > busy and had no time for coding, and them... boom! Not Much appears -- and
386 > it is almost exactly what I was trying to do, but faster. I have been
387 > playing a bit with Not Much today, and I think it has potential.
388 >
389 > Also, I would like to share one idea I had in mind, that you might find
390 > interesting: One thing I have found very annoying is having to re-tag my
391 > mail when the indexes get b0rked (it happened a couple of times to me while
392 > using Sup), so I was planning to mails as read/unread and adding the tags
393 > not just to the index, but to the mail text itself, e.g. by adding a
394 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
395 > could be totally recreated by re-reading the mail directories, and this
396 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
397 > local maildir, tagging and indexing the mails with the e-mail reader and
398 > then syncing back the messages with the "X-Tags" header to the IMAP server.
399 > This would allow to use the mail reader from a different computer and still
400 > have everything tagged finely.
401 >
402 > Best regards,
403 >
404 >
405 > ---
406 > [1] http://software.complete.org/software/projects/show/offlineimap
407 >
408 > -- 
409 > Adrian Perez de Castro <aperez@igalia.com>
410 > Igalia - Free Software Engineering
411 > _______________________________________________
412 > notmuch mailing list
413 > notmuch@notmuchmail.org
414 > http://notmuchmail.org/mailman/listinfo/notmuch
415 EOF
416 test_expect_equal_file OUTPUT EXPECTED
417
418 test_begin_subtest "Reply within emacs to a multipart/alternative message"
419 test_emacs '(let ((message-hidden-headers ''()))
420             (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
421                 (notmuch-show-reply)
422                 (test-output))'
423 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
424 cat <<EOF >EXPECTED
425 From: Notmuch Test Suite <test_suite@notmuchmail.org>
426 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
427 Subject: Re: [notmuch] preliminary FreeBSD support
428 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
429 Fcc: ${MAIL_DIR}/sent
430 References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
431 User-Agent: Notmuch/XXX Emacs/XXX
432 --text follows this line--
433 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
434
435 > I saw the announcement this morning, and was very excited, as I had been
436 > hoping sup would be turned into a library,
437 > since I like the concept more than the UI (I'd rather an emacs interface).
438 >
439 > I did a preliminary compile which worked out fine, but
440 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
441 > FreeBSD, so notmuch_config_open segfaulted.
442 >
443 > Attached is a patch that supplies a default buffer size of 64 in cases where
444 > -1 is returned.
445 >
446 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
447 > is acceptable behavior,
448 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
449 > uses 64 as the
450 > buffer size.
451 > _______________________________________________
452 > notmuch mailing list
453 > notmuch@notmuchmail.org
454 > http://notmuchmail.org/mailman/listinfo/notmuch
455 EOF
456 test_expect_equal_file OUTPUT EXPECTED
457
458 test_begin_subtest "Reply within emacs to an html-only message"
459 add_message '[content-type]="text/html"' \
460             '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
461 test_emacs "(let ((message-hidden-headers '()) (mm-text-html-renderer 'html2text))
462             (notmuch-show \"id:${gen_msg_id}\")
463             (notmuch-show-reply)
464             (test-output))"
465 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
466 cat <<EOF >EXPECTED
467 From: Notmuch Test Suite <test_suite@notmuchmail.org>
468 To: 
469 Subject: Re: Reply within emacs to an html-only message
470 In-Reply-To: <${gen_msg_id}>
471 Fcc: ${MAIL_DIR}/sent
472 References: <${gen_msg_id}>
473 User-Agent: Notmuch/XXX Emacs/XXX
474 --text follows this line--
475 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
476
477 > Hi,This is an HTML test message.OK?
478 EOF
479 test_expect_equal_file OUTPUT EXPECTED
480
481 test_begin_subtest "Quote MML tags in reply"
482 message_id='test-emacs-mml-quoting@message.id'
483 add_message [id]="$message_id" \
484             "[subject]='$test_subtest_name'" \
485             '[body]="<#part disposition=inline>"'
486 test_emacs "(let ((message-hidden-headers '()))
487               (notmuch-show \"id:$message_id\")
488               (notmuch-show-reply)
489               (test-output))"
490 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
491 cat <<EOF >EXPECTED
492 From: Notmuch Test Suite <test_suite@notmuchmail.org>
493 To: 
494 Subject: Re: Quote MML tags in reply
495 In-Reply-To: <test-emacs-mml-quoting@message.id>
496 Fcc: ${MAIL_DIR}/sent
497 References: <test-emacs-mml-quoting@message.id>
498 User-Agent: Notmuch/XXX Emacs/XXX
499 --text follows this line--
500 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
501
502 > <#!part disposition=inline>
503 EOF
504 test_expect_equal_file OUTPUT EXPECTED
505
506 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
507 # save as archive to test that Emacs does not re-compress .gz
508 test_emacs '(let ((standard-input "\"attachment1.gz\""))
509               (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
510               (notmuch-show-save-attachments))'
511 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
512
513 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
514 # save as archive to test that Emacs does not re-compress .gz
515 test_emacs '(let ((standard-input "\"attachment2.gz\""))
516               (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
517 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
518
519 test_begin_subtest "Save 8bit attachment from within emacs using notmuch-show-save-attachments"
520
521 add_message '[subject]="Attachment with 8bit chars"' \
522         '[header]="MIME-Version: 1.0"' \
523         '[content-type]="multipart/mixed; boundary=\"abcd\""' \
524         '[body]="--abcd
525 Content-Type: text/plain
526
527 Attachment follows:
528
529 --abcd
530 Content-Type: application/octet-stream; name=\"sample\"
531 Content-Transfer-Encoding: 8bit
532 Content-Disposition: attachment; filename=\"sample\"
533
534 “¡ Hey ! It compiles ¡ Ship it !”
535
536 --abcd--
537 "'
538 test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
539             (delete-file "OUTPUT")
540             (let ((standard-input "\"OUTPUT\""))
541               (notmuch-show-save-attachments))'
542
543 test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
544
545 test_begin_subtest "View raw message within emacs"
546 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
547             (notmuch-show-view-raw-message)
548             (test-output)'
549 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
550
551 test_begin_subtest "Hiding/showing signature in notmuch-show view"
552 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
553 test_emacs "(notmuch-show \"$maildir_storage_thread\")
554             (search-forward \"Click/Enter to show.\")
555             (button-activate (button-at (point)))
556             (search-backward \"Click/Enter to hide.\")
557             (button-activate (button-at (point)))
558             (test-output)"
559 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
560
561 test_begin_subtest "Detection and hiding of top-post quoting of message"
562 add_message '[subject]="The problem with top-posting"' \
563             [id]=top-post-target \
564             '[body]="A: Because it messes up the order in which people normally read text.
565 Q: Why is top-posting such a bad thing?
566 A: Top-posting.
567 Q: What is the most annoying thing in e-mail?"'
568 add_message '[from]="Top Poster <top@poster.com>"' \
569             [in-reply-to]=top-post-target \
570             [references]=top-post-target \
571             '[subject]="Re: The problem with top-posting"' \
572             '[body]="Thanks for the advice! I will be sure to put it to good use.
573
574 -Top Poster
575
576 ----- Original Message -----
577 From: Notmuch Test Suite <test_suite@notmuchmail.org>
578 To: Notmuch Test Suite <test_suite@notmuchmai.org>
579 Sent: Fri, 05 Jan 2001 15:43:57 +0000
580 Subject: The problem with top-posting
581
582 Q: Why is top-posting such a bad thing?
583 A: Top-posting.
584 Q: What is the most annoying thing in e-mail?"'
585 test_emacs "(notmuch-show \"top-posting\")
586             (test-visible-output)"
587 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
588 Subject: The problem with top-posting
589 To: Notmuch Test Suite <test_suite@notmuchmail.org>
590 Date: Fri, 05 Jan 2001 15:43:57 +0000
591
592 A: Because it messes up the order in which people normally read text.
593 Q: Why is top-posting such a bad thing?
594 A: Top-posting.
595 Q: What is the most annoying thing in e-mail?
596 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
597 Subject: Re: The problem with top-posting
598 To: Notmuch Test Suite <test_suite@notmuchmail.org>
599 Date: Fri, 05 Jan 2001 15:43:57 +0000
600
601 Thanks for the advice! I will be sure to put it to good use.
602
603 -Top Poster
604
605 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
606 test_expect_equal_file OUTPUT EXPECTED
607
608 test_begin_subtest "Hiding message in notmuch-show view"
609 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
610             (notmuch-show-toggle-message)
611             (test-visible-output)'
612 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
613
614 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
615 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
616             (search-forward "Click/Enter to show.")
617             (button-activate (button-at (point)))
618             (notmuch-show-toggle-message)
619             (test-visible-output)'
620 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
621
622 test_begin_subtest "notmuch-show: show message headers"
623 test_emacs \
624         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
625                (notmuch-message-headers-visible t))
626            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
627            (test-visible-output))'
628 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-visible
629
630 test_begin_subtest "notmuch-show: hide message headers"
631 test_emacs \
632         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
633                (notmuch-message-headers-visible nil))
634            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
635            (test-visible-output))'
636 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
637
638 test_begin_subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-visibility-headers)"
639 test_emacs \
640         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
641                (notmuch-message-headers-visible t))
642            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
643            (notmuch-show-toggle-visibility-headers)
644            (test-visible-output))'
645 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
646
647 test_begin_subtest "notmuch-show: collapse all messages in thread"
648 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
649         (let ((current-prefix-arg t))
650           (notmuch-show-open-or-close-all)
651           (test-visible-output))'
652 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-collapsed
653
654 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
655 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
656         (notmuch-show-open-or-close-all)
657         (test-visible-output)'
658 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed
659
660 test_begin_subtest "Stashing in notmuch-show"
661 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
662     '[from]="Some One <someone@somewhere.org>"' \
663     '[to]="Some One Else <notsomeone@somewhere.org>"' \
664     '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
665     '[subject]="Stash my stashables"' \
666     '[id]="bought"' \
667     '[body]="Unable to stash body. Where did you get it in the first place?!?"'
668 notmuch tag +stashtest id:${gen_msg_id}
669 test_emacs '(notmuch-show "id:\"bought\"")
670         (notmuch-show-stash-date)
671         (notmuch-show-stash-from)
672         (notmuch-show-stash-to)
673         (notmuch-show-stash-cc)
674         (notmuch-show-stash-subject)
675         (notmuch-show-stash-message-id)
676         (notmuch-show-stash-message-id-stripped)
677         (notmuch-show-stash-tags)
678         (notmuch-show-stash-filename)
679         (notmuch-show-stash-mlarchive-link "Gmane")
680         (notmuch-show-stash-mlarchive-link "MARC")
681         (notmuch-show-stash-mlarchive-link "Mail Archive, The")
682         (switch-to-buffer
683           (generate-new-buffer "*test-stashing*"))
684         (dotimes (i 12)
685           (yank)
686           (insert "\n")
687           (rotate-yank-pointer 1))
688         (reverse-region (point-min) (point-max))
689             (test-output)'
690 cat <<EOF >EXPECTED
691 Sat, 01 Jan 2000 12:00:00 +0000
692 Some One <someone@somewhere.org>
693 Some One Else <notsomeone@somewhere.org>
694 Notmuch <notmuch@notmuchmail.org>
695 Stash my stashables
696 id:bought
697 bought
698 inbox,stashtest
699 ${gen_msg_filename}
700 http://mid.gmane.org/bought
701 http://marc.info/?i=bought
702 http://mail-archive.com/search?l=mid&q=bought
703 EOF
704 test_expect_equal_file OUTPUT EXPECTED
705
706 test_begin_subtest "Stashing in notmuch-search"
707 test_emacs '(notmuch-search "id:\"bought\"")
708         (notmuch-test-wait)
709         (notmuch-search-stash-thread-id)
710         (switch-to-buffer
711           (generate-new-buffer "*test-stashing*"))
712         (yank)
713             (test-output)'
714 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
715 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
716
717 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
718 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
719 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
720 test_emacs "(notmuch-show \"$message2\")
721             (test-output \"EXPECTED\")"
722 test_emacs "(notmuch-search \"$message1 or $message2\")
723             (notmuch-test-wait)
724             (notmuch-search-show-thread)
725             (goto-char (point-max))
726             (redisplay)
727             (notmuch-show-advance-and-archive)
728             (test-output)"
729 test_expect_equal_file OUTPUT EXPECTED
730
731 test_begin_subtest "Refresh show buffer"
732 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
733             (test-visible-output "EXPECTED")
734             (notmuch-show-refresh-view)
735             (test-visible-output)'
736 test_expect_equal_file OUTPUT EXPECTED
737
738 test_begin_subtest "Refresh modified show buffer"
739 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
740             (notmuch-show-toggle-message)
741             (notmuch-show-next-message)
742             (notmuch-show-toggle-message)
743             (test-visible-output "EXPECTED")
744             (notmuch-show-refresh-view)
745             (test-visible-output)'
746 test_expect_equal_file OUTPUT EXPECTED
747
748 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
749 id='message-with-application/mpeg-attachment@notmuchmail.org'
750 emacs_deliver_message \
751     'Message with application/mpeg attachment' \
752     '' \
753     "(message-goto-eoh)
754      (insert \"Message-ID: <$id>\n\")
755      (message-goto-body)
756      (mml-insert-part \"application/mpeg\")
757      (insert \"a fake mp3 file\")"
758 notmuch_counter_reset
759 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
760               (notmuch-show \"id:$id\"))"
761 test_expect_equal $(notmuch_counter_value) 1
762
763 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
764 id='message-with-audio/mpeg-attachment@notmuchmail.org'
765 emacs_deliver_message \
766     'Message with audio/mpeg attachment' \
767     '' \
768     "(message-goto-eoh)
769      (insert \"Message-ID: <$id>\n\")
770      (message-goto-body)
771      (mml-insert-part \"audio/mpeg\")
772      (insert \"a fake mp3 file\")"
773 notmuch_counter_reset
774 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
775               (notmuch-show \"id:$id\"))"
776 test_expect_equal $(notmuch_counter_value) 1
777
778 test_begin_subtest "notmuch-hello-mode hook is called"
779 counter=$(test_emacs \
780     '(let ((notmuch-hello-mode-hook-counter 0))
781        (kill-buffer "*notmuch-hello*")
782        (notmuch-hello)
783        notmuch-hello-mode-hook-counter)'
784 )
785 test_expect_equal "$counter" 1
786
787 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
788 counter=$(test_emacs \
789     '(let ((notmuch-hello-mode-hook-counter 0))
790        (kill-buffer "*notmuch-hello*")
791        (notmuch-hello)
792        (notmuch-hello-update)
793        notmuch-hello-mode-hook-counter)'
794 )
795 test_expect_equal "$counter" 1
796
797 test_begin_subtest "notmuch-hello-refresh hook is called"
798 counter=$(test_emacs \
799     '(let ((notmuch-hello-refresh-hook-counter 0))
800        (kill-buffer "*notmuch-hello*")
801        (notmuch-hello)
802        notmuch-hello-refresh-hook-counter)'
803 )
804 test_expect_equal "$counter" 1
805
806 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
807 counter=$(test_emacs \
808     '(let ((notmuch-hello-refresh-hook-counter 0))
809        (kill-buffer "*notmuch-hello*")
810        (notmuch-hello)
811        (notmuch-hello-update)
812        notmuch-hello-refresh-hook-counter)'
813 )
814 test_expect_equal "$counter" 2
815
816
817 add_message '[subject]="HTML mail with images"' \
818     '[content-type]="multipart/related; boundary=abcd"' \
819     '[body]="--abcd
820 Content-Type: text/html
821
822 <img src="cid:330@goomoji.gmail"> smiley
823
824 --abcd
825 Content-Type: image/gif
826 Content-Transfer-Encoding: base64
827 Content-ID: <330@goomoji.gmail>
828
829 R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMl
830 WLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7
831 --abcd--"'
832 test_emacs "(let ((mm-text-html-renderer
833                    (if (assq 'shr mm-text-html-renderer-alist)
834                        'shr 'html2text)))
835               (notmuch-show \"id:${gen_msg_id}\"))
836             (test-output)" > /dev/null
837 # Different Emacs versions and renderers give very different results,
838 # so just check that something reasonable showed up.  We first cat the
839 # output so the test framework will print it if the test fails.
840 test_expect_success "Rendering HTML mail with images" \
841     'cat OUTPUT && grep -q smiley OUTPUT'
842
843
844 test_done