]> git.notmuchmail.org Git - notmuch/blob - test/emacs
test/emacs: test saving of attachment containing 8bit octets
[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 test_subtest_known_broken
521
522 add_message '[subject]="Attachment with 8bit chars"' \
523         '[header]="MIME-Version: 1.0"' \
524         '[content-type]="multipart/mixed; boundary=\"abcd\""' \
525         '[body]="--abcd
526 Content-Type: text/plain
527
528 Attachment follows:
529
530 --abcd
531 Content-Type: application/octet-stream; name=\"sample\"
532 Content-Transfer-Encoding: 8bit
533 Content-Disposition: attachment; filename=\"sample\"
534
535 “¡ Hey ! It compiles ¡ Ship it !”
536
537 --abcd--
538 "'
539 test_emacs '(notmuch-show "id:'"${gen_msg_id}"'")
540             (delete-file "OUTPUT")
541             (let ((standard-input "\"OUTPUT\""))
542               (notmuch-show-save-attachments))'
543
544 test_expect_equal "$(cat OUTPUT)" '“¡ Hey ! It compiles ¡ Ship it !”'
545
546 test_begin_subtest "View raw message within emacs"
547 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
548             (notmuch-show-view-raw-message)
549             (test-output)'
550 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
551
552 test_begin_subtest "Hiding/showing signature in notmuch-show view"
553 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
554 test_emacs "(notmuch-show \"$maildir_storage_thread\")
555             (search-forward \"Click/Enter to show.\")
556             (button-activate (button-at (point)))
557             (search-backward \"Click/Enter to hide.\")
558             (button-activate (button-at (point)))
559             (test-output)"
560 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
561
562 test_begin_subtest "Detection and hiding of top-post quoting of message"
563 add_message '[subject]="The problem with top-posting"' \
564             [id]=top-post-target \
565             '[body]="A: Because it messes up the order in which people normally read text.
566 Q: Why is top-posting such a bad thing?
567 A: Top-posting.
568 Q: What is the most annoying thing in e-mail?"'
569 add_message '[from]="Top Poster <top@poster.com>"' \
570             [in-reply-to]=top-post-target \
571             [references]=top-post-target \
572             '[subject]="Re: The problem with top-posting"' \
573             '[body]="Thanks for the advice! I will be sure to put it to good use.
574
575 -Top Poster
576
577 ----- Original Message -----
578 From: Notmuch Test Suite <test_suite@notmuchmail.org>
579 To: Notmuch Test Suite <test_suite@notmuchmai.org>
580 Sent: Fri, 05 Jan 2001 15:43:57 +0000
581 Subject: The problem with top-posting
582
583 Q: Why is top-posting such a bad thing?
584 A: Top-posting.
585 Q: What is the most annoying thing in e-mail?"'
586 test_emacs "(notmuch-show \"top-posting\")
587             (test-visible-output)"
588 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
589 Subject: The problem with top-posting
590 To: Notmuch Test Suite <test_suite@notmuchmail.org>
591 Date: Fri, 05 Jan 2001 15:43:57 +0000
592
593 A: Because it messes up the order in which people normally read text.
594 Q: Why is top-posting such a bad thing?
595 A: Top-posting.
596 Q: What is the most annoying thing in e-mail?
597 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
598 Subject: Re: The problem with top-posting
599 To: Notmuch Test Suite <test_suite@notmuchmail.org>
600 Date: Fri, 05 Jan 2001 15:43:57 +0000
601
602 Thanks for the advice! I will be sure to put it to good use.
603
604 -Top Poster
605
606 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
607 test_expect_equal_file OUTPUT EXPECTED
608
609 test_begin_subtest "Hiding message in notmuch-show view"
610 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
611             (notmuch-show-toggle-message)
612             (test-visible-output)'
613 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
614
615 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
616 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
617             (search-forward "Click/Enter to show.")
618             (button-activate (button-at (point)))
619             (notmuch-show-toggle-message)
620             (test-visible-output)'
621 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
622
623 test_begin_subtest "notmuch-show: show message headers"
624 test_emacs \
625         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
626                (notmuch-message-headers-visible t))
627            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
628            (test-visible-output))'
629 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-visible
630
631 test_begin_subtest "notmuch-show: hide message headers"
632 test_emacs \
633         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
634                (notmuch-message-headers-visible nil))
635            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
636            (test-visible-output))'
637 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
638
639 test_begin_subtest "notmuch-show: hide message headers (w/ notmuch-show-toggle-visibility-headers)"
640 test_emacs \
641         '(let ((notmuch-message-headers '\''("Subject" "To" "Cc" "Date"))
642                (notmuch-message-headers-visible t))
643            (notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
644            (notmuch-show-toggle-visibility-headers)
645            (test-visible-output))'
646 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-message-with-headers-hidden
647
648 test_begin_subtest "notmuch-show: collapse all messages in thread"
649 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
650         (let ((current-prefix-arg t))
651           (notmuch-show-open-or-close-all)
652           (test-visible-output))'
653 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-collapsed
654
655 test_begin_subtest "notmuch-show: uncollapse all messages in thread"
656 test_emacs '(notmuch-show "id:f35dbb950911171435ieecd458o853c873e35f4be95@mail.gmail.com")
657         (notmuch-show-open-or-close-all)
658         (test-visible-output)'
659 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-all-messages-uncollapsed
660
661 test_begin_subtest "Stashing in notmuch-show"
662 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
663     '[from]="Some One <someone@somewhere.org>"' \
664     '[to]="Some One Else <notsomeone@somewhere.org>"' \
665     '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
666     '[subject]="Stash my stashables"' \
667     '[id]="bought"' \
668     '[body]="Unable to stash body. Where did you get it in the first place?!?"'
669 notmuch tag +stashtest id:${gen_msg_id}
670 test_emacs '(notmuch-show "id:\"bought\"")
671         (notmuch-show-stash-date)
672         (notmuch-show-stash-from)
673         (notmuch-show-stash-to)
674         (notmuch-show-stash-cc)
675         (notmuch-show-stash-subject)
676         (notmuch-show-stash-message-id)
677         (notmuch-show-stash-message-id-stripped)
678         (notmuch-show-stash-tags)
679         (notmuch-show-stash-filename)
680         (notmuch-show-stash-mlarchive-link "Gmane")
681         (notmuch-show-stash-mlarchive-link "MARC")
682         (notmuch-show-stash-mlarchive-link "Mail Archive, The")
683         (switch-to-buffer
684           (generate-new-buffer "*test-stashing*"))
685         (dotimes (i 12)
686           (yank)
687           (insert "\n")
688           (rotate-yank-pointer 1))
689         (reverse-region (point-min) (point-max))
690             (test-output)'
691 cat <<EOF >EXPECTED
692 Sat, 01 Jan 2000 12:00:00 +0000
693 Some One <someone@somewhere.org>
694 Some One Else <notsomeone@somewhere.org>
695 Notmuch <notmuch@notmuchmail.org>
696 Stash my stashables
697 id:bought
698 bought
699 inbox,stashtest
700 ${gen_msg_filename}
701 http://mid.gmane.org/bought
702 http://marc.info/?i=bought
703 http://mail-archive.com/search?l=mid&q=bought
704 EOF
705 test_expect_equal_file OUTPUT EXPECTED
706
707 test_begin_subtest "Stashing in notmuch-search"
708 test_emacs '(notmuch-search "id:\"bought\"")
709         (notmuch-test-wait)
710         (notmuch-search-stash-thread-id)
711         (switch-to-buffer
712           (generate-new-buffer "*test-stashing*"))
713         (yank)
714             (test-output)'
715 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
716 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
717
718 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
719 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
720 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
721 test_emacs "(notmuch-show \"$message2\")
722             (test-output \"EXPECTED\")"
723 test_emacs "(notmuch-search \"$message1 or $message2\")
724             (notmuch-test-wait)
725             (notmuch-search-show-thread)
726             (goto-char (point-max))
727             (redisplay)
728             (notmuch-show-advance-and-archive)
729             (test-output)"
730 test_expect_equal_file OUTPUT EXPECTED
731
732 test_begin_subtest "Refresh show buffer"
733 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
734             (test-visible-output "EXPECTED")
735             (notmuch-show-refresh-view)
736             (test-visible-output)'
737 test_expect_equal_file OUTPUT EXPECTED
738
739 test_begin_subtest "Refresh modified show buffer"
740 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
741             (notmuch-show-toggle-message)
742             (notmuch-show-next-message)
743             (notmuch-show-toggle-message)
744             (test-visible-output "EXPECTED")
745             (notmuch-show-refresh-view)
746             (test-visible-output)'
747 test_expect_equal_file OUTPUT EXPECTED
748
749 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
750 id='message-with-application/mpeg-attachment@notmuchmail.org'
751 emacs_deliver_message \
752     'Message with application/mpeg attachment' \
753     '' \
754     "(message-goto-eoh)
755      (insert \"Message-ID: <$id>\n\")
756      (message-goto-body)
757      (mml-insert-part \"application/mpeg\")
758      (insert \"a fake mp3 file\")"
759 notmuch_counter_reset
760 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
761               (notmuch-show \"id:$id\"))"
762 test_expect_equal $(notmuch_counter_value) 1
763
764 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
765 id='message-with-audio/mpeg-attachment@notmuchmail.org'
766 emacs_deliver_message \
767     'Message with audio/mpeg attachment' \
768     '' \
769     "(message-goto-eoh)
770      (insert \"Message-ID: <$id>\n\")
771      (message-goto-body)
772      (mml-insert-part \"audio/mpeg\")
773      (insert \"a fake mp3 file\")"
774 notmuch_counter_reset
775 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
776               (notmuch-show \"id:$id\"))"
777 test_expect_equal $(notmuch_counter_value) 1
778
779 test_begin_subtest "notmuch-hello-mode hook is called"
780 counter=$(test_emacs \
781     '(let ((notmuch-hello-mode-hook-counter 0))
782        (kill-buffer "*notmuch-hello*")
783        (notmuch-hello)
784        notmuch-hello-mode-hook-counter)'
785 )
786 test_expect_equal "$counter" 1
787
788 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
789 counter=$(test_emacs \
790     '(let ((notmuch-hello-mode-hook-counter 0))
791        (kill-buffer "*notmuch-hello*")
792        (notmuch-hello)
793        (notmuch-hello-update)
794        notmuch-hello-mode-hook-counter)'
795 )
796 test_expect_equal "$counter" 1
797
798 test_begin_subtest "notmuch-hello-refresh hook is called"
799 counter=$(test_emacs \
800     '(let ((notmuch-hello-refresh-hook-counter 0))
801        (kill-buffer "*notmuch-hello*")
802        (notmuch-hello)
803        notmuch-hello-refresh-hook-counter)'
804 )
805 test_expect_equal "$counter" 1
806
807 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
808 counter=$(test_emacs \
809     '(let ((notmuch-hello-refresh-hook-counter 0))
810        (kill-buffer "*notmuch-hello*")
811        (notmuch-hello)
812        (notmuch-hello-update)
813        notmuch-hello-refresh-hook-counter)'
814 )
815 test_expect_equal "$counter" 2
816
817
818 add_message '[subject]="HTML mail with images"' \
819     '[content-type]="multipart/related; boundary=abcd"' \
820     '[body]="--abcd
821 Content-Type: text/html
822
823 <img src="cid:330@goomoji.gmail"> smiley
824
825 --abcd
826 Content-Type: image/gif
827 Content-Transfer-Encoding: base64
828 Content-ID: <330@goomoji.gmail>
829
830 R0lGODlhDAAMAKIFAF5LAP/zxAAAANyuAP/gaP///wAAAAAAACH5BAEAAAUALAAAAAAMAAwAAAMl
831 WLPcGjDKFYi9lxKBOaGcF35DhWHamZUW0K4mAbiwWtuf0uxFAgA7
832 --abcd--"'
833 test_emacs "(let ((mm-text-html-renderer
834                    (if (assq 'shr mm-text-html-renderer-alist)
835                        'shr 'html2text)))
836               (notmuch-show \"id:${gen_msg_id}\"))
837             (test-output)" > /dev/null
838 # Different Emacs versions and renderers give very different results,
839 # so just check that something reasonable showed up.  We first cat the
840 # output so the test framework will print it if the test fails.
841 test_expect_success "Rendering HTML mail with images" \
842     'cat OUTPUT && grep -q smiley OUTPUT'
843
844
845 test_done