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