]> git.notmuchmail.org Git - notmuch/blob - test/emacs
afe35bae09f26a8e938657575e8ff48672c4f685
[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>,' < sent_message >OUTPUT
173 cat <<EOF >EXPECTED
174 From: Notmuch Test Suite <test_suite@notmuchmail.org>
175 To: user@example.com
176 Subject: Testing message sent via SMTP
177 Date: 01 Jan 2000 12:00:00 -0000
178 User-Agent: Notmuch/XXX Emacs/XXX
179 Message-ID: <XXX>
180 MIME-Version: 1.0
181 Content-Type: text/plain; charset=us-ascii
182
183 This is a test that messages are sent via SMTP
184 EOF
185 test_expect_equal_file OUTPUT EXPECTED
186
187 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
188 notmuch new > /dev/null
189 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
190 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
191
192 test_begin_subtest "notmuch-fcc-dirs set to nil"
193 test_emacs "(let ((notmuch-fcc-dirs nil))
194               (notmuch-mua-mail)
195               (test-output))"
196 cat <<EOF >EXPECTED
197 From: Notmuch Test Suite <test_suite@notmuchmail.org>
198 To: 
199 Subject: 
200 --text follows this line--
201 EOF
202 test_expect_equal_file OUTPUT EXPECTED
203
204 # Make another FCC maildir specific for the next test
205 mkdir -p mail/sent-string/cur
206 mkdir -p mail/sent-string/new
207 mkdir -p mail/sent-string/tmp
208
209 test_begin_subtest "notmuch-fcc-dirs set to a string"
210 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
211               (notmuch-mua-mail)
212               (test-output))"
213 cat <<EOF >EXPECTED
214 From: Notmuch Test Suite <test_suite@notmuchmail.org>
215 To: 
216 Subject: 
217 Fcc: ${MAIL_DIR}/sent-string
218 --text follows this line--
219 EOF
220 test_expect_equal_file OUTPUT EXPECTED
221
222 # Make more FCC maildirs specific for the next test
223 mkdir -p mail/sent-list-match/cur
224 mkdir -p mail/sent-list-match/new
225 mkdir -p mail/sent-list-match/tmp
226 mkdir -p mail/failure/cur
227 mkdir -p mail/failure/new
228 mkdir -p mail/failure/tmp
229
230 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
231 test_emacs "(let ((notmuch-fcc-dirs
232                    '((\"notmuchmail.org\" . \"sent-list-match\")
233                      (\".*\" . \"failure\"))))
234               (notmuch-mua-mail)
235               (test-output))"
236 cat <<EOF >EXPECTED
237 From: Notmuch Test Suite <test_suite@notmuchmail.org>
238 To: 
239 Subject: 
240 Fcc: ${MAIL_DIR}/sent-list-match
241 --text follows this line--
242 EOF
243 test_expect_equal_file OUTPUT EXPECTED
244
245 # Make another FCC maildir specific for the next test
246 mkdir -p mail/sent-list-catch-all/cur
247 mkdir -p mail/sent-list-catch-all/new
248 mkdir -p mail/sent-list-catch-all/tmp
249
250 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
251 test_emacs "(let ((notmuch-fcc-dirs
252                    '((\"example.com\" . \"failure\")
253                      (\".*\" . \"sent-list-catch-all\"))))
254               (notmuch-mua-mail)
255               (test-output))"
256 cat <<EOF >EXPECTED
257 From: Notmuch Test Suite <test_suite@notmuchmail.org>
258 To: 
259 Subject: 
260 Fcc: ${MAIL_DIR}/sent-list-catch-all
261 --text follows this line--
262 EOF
263 test_expect_equal_file OUTPUT EXPECTED
264
265 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
266 test_emacs "(let ((notmuch-fcc-dirs
267                    '((\"example.com\" . \"failure\")
268                      (\"nomatchhere.net\" . \"failure\"))))
269               (notmuch-mua-mail)
270               (test-output))"
271 cat <<EOF >EXPECTED
272 From: Notmuch Test Suite <test_suite@notmuchmail.org>
273 To: 
274 Subject: 
275 --text follows this line--
276 EOF
277 test_expect_equal_file OUTPUT EXPECTED
278
279 test_begin_subtest "Reply within emacs"
280 test_emacs '(let ((message-hidden-headers ''()))
281             (notmuch-search "subject:\"testing message sent via SMTP\"")
282             (notmuch-test-wait)
283             (notmuch-search-reply-to-thread)
284             (test-output))'
285 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
286 sed -i -e 's/^References: <.*>$/References: <XXX>/' OUTPUT
287 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
288 cat <<EOF >EXPECTED
289 From: Notmuch Test Suite <test_suite@notmuchmail.org>
290 To: user@example.com
291 Subject: Re: Testing message sent via SMTP
292 In-Reply-To: <XXX>
293 Fcc: ${MAIL_DIR}/sent
294 References: <XXX>
295 User-Agent: Notmuch/XXX Emacs/XXX
296 --text follows this line--
297 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
298
299 > This is a test that messages are sent via SMTP
300 EOF
301 test_expect_equal_file OUTPUT EXPECTED
302
303 test_begin_subtest "Reply from alternate address within emacs"
304 add_message '[from]="Sender <sender@example.com>"' \
305              [to]=test_suite_other@notmuchmail.org
306
307 test_emacs "(let ((message-hidden-headers '()))
308             (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
309             (notmuch-test-wait)
310             (notmuch-search-reply-to-thread)
311             (test-output))"
312 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
313 cat <<EOF >EXPECTED
314 From: Notmuch Test Suite <test_suite_other@notmuchmail.org>
315 To: Sender <sender@example.com>
316 Subject: Re: ${test_subtest_name}
317 In-Reply-To: <${gen_msg_id}>
318 Fcc: ${MAIL_DIR}/sent
319 References: <${gen_msg_id}>
320 User-Agent: Notmuch/XXX Emacs/XXX
321 --text follows this line--
322 Sender <sender@example.com> writes:
323
324 > This is just a test message (#${gen_msg_cnt})
325 EOF
326 test_expect_equal_file OUTPUT EXPECTED
327
328 test_begin_subtest "Reply from address in named group list within emacs"
329 add_message '[from]="Sender <sender@example.com>"' \
330             '[to]=group:test_suite@notmuchmail.org,someone@example.com\;' \
331              [cc]=test_suite_other@notmuchmail.org
332
333 test_emacs "(let ((message-hidden-headers '()))
334             (notmuch-search \"id:\\\"${gen_msg_id}\\\"\")
335             (notmuch-test-wait)
336             (notmuch-search-reply-to-thread)
337             (test-output))"
338 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
339 cat <<EOF >EXPECTED
340 From: Notmuch Test Suite <test_suite@notmuchmail.org>
341 To: Sender <sender@example.com>, someone@example.com
342 Subject: Re: ${test_subtest_name}
343 In-Reply-To: <${gen_msg_id}>
344 Fcc: ${MAIL_DIR}/sent
345 References: <${gen_msg_id}>
346 User-Agent: Notmuch/XXX Emacs/XXX
347 --text follows this line--
348 Sender <sender@example.com> writes:
349
350 > This is just a test message (#${gen_msg_cnt})
351 EOF
352 test_expect_equal_file OUTPUT EXPECTED
353
354 test_begin_subtest "Reply within emacs to a multipart/mixed message"
355 test_emacs '(let ((message-hidden-headers ''()))
356             (notmuch-show "id:20091118002059.067214ed@hikari")
357                 (notmuch-show-reply)
358                 (test-output))'
359 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
360 cat <<EOF >EXPECTED
361 From: Notmuch Test Suite <test_suite@notmuchmail.org>
362 To: Adrian Perez de Castro <aperez@igalia.com>, notmuch@notmuchmail.org
363 Subject: Re: [notmuch] Introducing myself
364 In-Reply-To: <20091118002059.067214ed@hikari>
365 Fcc: ${MAIL_DIR}/sent
366 References: <20091118002059.067214ed@hikari>
367 User-Agent: Notmuch/XXX Emacs/XXX
368 --text follows this line--
369 Adrian Perez de Castro <aperez@igalia.com> writes:
370
371 > Hello to all,
372 >
373 > I have just heard about Not Much today in some random Linux-related news
374 > site (LWN?), my name is Adrian Perez and I work as systems administrator
375 > (although I can do some code as well :P). I have always thought that the
376 > ideas behind Sup were great, but after some time using it, I got tired of
377 > the oddities that it has. I also do not like doing things like having to
378 > install Ruby just for reading and sorting mails. Some time ago I thought
379 > about doing something like Not Much and in fact I played a bit with the
380 > Python+Xapian and the Python+Whoosh combinations, because I find relaxing
381 > to code things in Python when I am not working and also it is installed
382 > by default on most distribution. I got to have some mailboxes indexed and
383 > basic searching working a couple of months ago. Lately I have been very
384 > busy and had no time for coding, and them... boom! Not Much appears -- and
385 > it is almost exactly what I was trying to do, but faster. I have been
386 > playing a bit with Not Much today, and I think it has potential.
387 >
388 > Also, I would like to share one idea I had in mind, that you might find
389 > interesting: One thing I have found very annoying is having to re-tag my
390 > mail when the indexes get b0rked (it happened a couple of times to me while
391 > using Sup), so I was planning to mails as read/unread and adding the tags
392 > not just to the index, but to the mail text itself, e.g. by adding a
393 > "X-Tags" header field or by reusing the "Keywords" one. This way, the index
394 > could be totally recreated by re-reading the mail directories, and this
395 > would also allow to a tools like OfflineIMAP [1] to get the mails into a
396 > local maildir, tagging and indexing the mails with the e-mail reader and
397 > then syncing back the messages with the "X-Tags" header to the IMAP server.
398 > This would allow to use the mail reader from a different computer and still
399 > have everything tagged finely.
400 >
401 > Best regards,
402 >
403 >
404 > ---
405 > [1] http://software.complete.org/software/projects/show/offlineimap
406 >
407 > -- 
408 > Adrian Perez de Castro <aperez@igalia.com>
409 > Igalia - Free Software Engineering
410 > _______________________________________________
411 > notmuch mailing list
412 > notmuch@notmuchmail.org
413 > http://notmuchmail.org/mailman/listinfo/notmuch
414 EOF
415 test_expect_equal_file OUTPUT EXPECTED
416
417 test_begin_subtest "Reply within emacs to a multipart/alternative message"
418 test_emacs '(let ((message-hidden-headers ''()))
419             (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
420                 (notmuch-show-reply)
421                 (test-output))'
422 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
423 cat <<EOF >EXPECTED
424 From: Notmuch Test Suite <test_suite@notmuchmail.org>
425 To: Alex Botero-Lowry <alex.boterolowry@gmail.com>, notmuch@notmuchmail.org
426 Subject: Re: [notmuch] preliminary FreeBSD support
427 In-Reply-To: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
428 Fcc: ${MAIL_DIR}/sent
429 References: <cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com>
430 User-Agent: Notmuch/XXX Emacs/XXX
431 --text follows this line--
432 Alex Botero-Lowry <alex.boterolowry@gmail.com> writes:
433
434 > I saw the announcement this morning, and was very excited, as I had been
435 > hoping sup would be turned into a library,
436 > since I like the concept more than the UI (I'd rather an emacs interface).
437 >
438 > I did a preliminary compile which worked out fine, but
439 > sysconf(_SC_SC_GETPW_R_SIZE_MAX) returns -1 on
440 > FreeBSD, so notmuch_config_open segfaulted.
441 >
442 > Attached is a patch that supplies a default buffer size of 64 in cases where
443 > -1 is returned.
444 >
445 > http://www.opengroup.org/austin/docs/austin_328.txt - seems to indicate this
446 > is acceptable behavior,
447 > and http://mail-index.netbsd.org/pkgsrc-bugs/2006/06/07/msg016808.htmlspecifically
448 > uses 64 as the
449 > buffer size.
450 > _______________________________________________
451 > notmuch mailing list
452 > notmuch@notmuchmail.org
453 > http://notmuchmail.org/mailman/listinfo/notmuch
454 EOF
455 test_expect_equal_file OUTPUT EXPECTED
456
457 test_begin_subtest "Reply within emacs to an html-only message"
458 add_message '[content-type]="text/html"' \
459             '[body]="Hi,<br />This is an <b>HTML</b> test message.<br /><br />OK?"'
460 test_emacs "(let ((message-hidden-headers '()) (mm-text-html-renderer 'html2text))
461             (notmuch-show \"id:${gen_msg_id}\")
462             (notmuch-show-reply)
463             (test-output))"
464 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
465 cat <<EOF >EXPECTED
466 From: Notmuch Test Suite <test_suite@notmuchmail.org>
467 To: 
468 Subject: Re: Reply within emacs to an html-only message
469 In-Reply-To: <${gen_msg_id}>
470 Fcc: ${MAIL_DIR}/sent
471 References: <${gen_msg_id}>
472 User-Agent: Notmuch/XXX Emacs/XXX
473 --text follows this line--
474 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
475
476 > Hi,This is an HTML test message.OK?
477 EOF
478 test_expect_equal_file OUTPUT EXPECTED
479
480 test_begin_subtest "Quote MML tags in reply"
481 message_id='test-emacs-mml-quoting@message.id'
482 add_message [id]="$message_id" \
483             "[subject]='$test_subtest_name'" \
484             '[body]="<#part disposition=inline>"'
485 test_emacs "(let ((message-hidden-headers '()))
486               (notmuch-show \"id:$message_id\")
487               (notmuch-show-reply)
488               (test-output))"
489 sed -i -e 's,^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' OUTPUT
490 cat <<EOF >EXPECTED
491 From: Notmuch Test Suite <test_suite@notmuchmail.org>
492 To: 
493 Subject: Re: Quote MML tags in reply
494 In-Reply-To: <test-emacs-mml-quoting@message.id>
495 Fcc: ${MAIL_DIR}/sent
496 References: <test-emacs-mml-quoting@message.id>
497 User-Agent: Notmuch/XXX Emacs/XXX
498 --text follows this line--
499 Notmuch Test Suite <test_suite@notmuchmail.org> writes:
500
501 > <#!part disposition=inline>
502 EOF
503 test_expect_equal_file OUTPUT EXPECTED
504
505 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
506 # save as archive to test that Emacs does not re-compress .gz
507 test_emacs '(let ((standard-input "\"attachment1.gz\""))
508               (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
509               (notmuch-show-save-attachments))'
510 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
511
512 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
513 # save as archive to test that Emacs does not re-compress .gz
514 test_emacs '(let ((standard-input "\"attachment2.gz\""))
515               (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
516 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
517
518 test_begin_subtest "View raw message within emacs"
519 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
520             (notmuch-show-view-raw-message)
521             (test-output)'
522 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
523
524 test_begin_subtest "Hiding/showing signature in notmuch-show view"
525 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
526 test_emacs "(notmuch-show \"$maildir_storage_thread\")
527             (search-forward \"Click/Enter to show.\")
528             (button-activate (button-at (point)))
529             (search-backward \"Click/Enter to hide.\")
530             (button-activate (button-at (point)))
531             (test-output)"
532 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
533
534 test_begin_subtest "Detection and hiding of top-post quoting of message"
535 add_message '[subject]="The problem with top-posting"' \
536             [id]=top-post-target \
537             '[body]="A: Because it messes up the order in which people normally read text.
538 Q: Why is top-posting such a bad thing?
539 A: Top-posting.
540 Q: What is the most annoying thing in e-mail?"'
541 add_message '[from]="Top Poster <top@poster.com>"' \
542             [in-reply-to]=top-post-target \
543             [references]=top-post-target \
544             '[subject]="Re: The problem with top-posting"' \
545             '[body]="Thanks for the advice! I will be sure to put it to good use.
546
547 -Top Poster
548
549 ----- Original Message -----
550 From: Notmuch Test Suite <test_suite@notmuchmail.org>
551 To: Notmuch Test Suite <test_suite@notmuchmai.org>
552 Sent: Fri, 05 Jan 2001 15:43:57 +0000
553 Subject: The problem with top-posting
554
555 Q: Why is top-posting such a bad thing?
556 A: Top-posting.
557 Q: What is the most annoying thing in e-mail?"'
558 test_emacs "(notmuch-show \"top-posting\")
559             (test-visible-output)"
560 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
561 Subject: The problem with top-posting
562 To: Notmuch Test Suite <test_suite@notmuchmail.org>
563 Date: Fri, 05 Jan 2001 15:43:57 +0000
564
565 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 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
570 Subject: Re: The problem with top-posting
571 To: Notmuch Test Suite <test_suite@notmuchmail.org>
572 Date: Fri, 05 Jan 2001 15:43:57 +0000
573
574 Thanks for the advice! I will be sure to put it to good use.
575
576 -Top Poster
577
578 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
579 test_expect_equal_file OUTPUT EXPECTED
580
581 test_begin_subtest "Hiding message in notmuch-show view"
582 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
583             (notmuch-show-toggle-message)
584             (test-visible-output)'
585 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
586
587 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
588 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
589             (search-forward "Click/Enter to show.")
590             (button-activate (button-at (point)))
591             (notmuch-show-toggle-message)
592             (test-visible-output)'
593 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
594
595 test_begin_subtest "Stashing in notmuch-show"
596 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
597     '[from]="Some One <someone@somewhere.org>"' \
598     '[to]="Some One Else <notsomeone@somewhere.org>"' \
599     '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
600     '[subject]="Stash my stashables"' \
601     '[id]="bought"' \
602     '[body]="Unable to stash body. Where did you get it in the first place?!?"'
603 notmuch tag +stashtest id:${gen_msg_id}
604 test_emacs '(notmuch-show "id:\"bought\"")
605         (notmuch-show-stash-date)
606         (notmuch-show-stash-from)
607         (notmuch-show-stash-to)
608         (notmuch-show-stash-cc)
609         (notmuch-show-stash-subject)
610         (notmuch-show-stash-message-id)
611         (notmuch-show-stash-message-id-stripped)
612         (notmuch-show-stash-tags)
613         (notmuch-show-stash-filename)
614         (notmuch-show-stash-mlarchive-link "Gmane")
615         (notmuch-show-stash-mlarchive-link "MARC")
616         (notmuch-show-stash-mlarchive-link "Mail Archive, The")
617         (switch-to-buffer
618           (generate-new-buffer "*test-stashing*"))
619         (dotimes (i 12)
620           (yank)
621           (insert "\n")
622           (rotate-yank-pointer 1))
623         (reverse-region (point-min) (point-max))
624             (test-output)'
625 cat <<EOF >EXPECTED
626 Sat, 01 Jan 2000 12:00:00 +0000
627 Some One <someone@somewhere.org>
628 Some One Else <notsomeone@somewhere.org>
629 Notmuch <notmuch@notmuchmail.org>
630 Stash my stashables
631 id:"bought"
632 bought
633 inbox,stashtest
634 ${gen_msg_filename}
635 http://mid.gmane.org/bought
636 http://marc.info/?i=bought
637 http://mail-archive.com/search?l=mid&q=bought
638 EOF
639 test_expect_equal_file OUTPUT EXPECTED
640
641 test_begin_subtest "Stashing in notmuch-search"
642 test_emacs '(notmuch-search "id:\"bought\"")
643         (notmuch-test-wait)
644         (notmuch-search-stash-thread-id)
645         (switch-to-buffer
646           (generate-new-buffer "*test-stashing*"))
647         (yank)
648             (test-output)'
649 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
650 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
651
652 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
653 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
654 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
655 test_emacs "(notmuch-search \"$message1 or $message2\")
656             (notmuch-test-wait)
657             (notmuch-search-show-thread)
658             (goto-char (point-max))
659             (redisplay)
660             (notmuch-show-advance-and-archive)
661             (test-output)"
662 test_emacs "(notmuch-show \"$message2\")
663             (test-output \"EXPECTED\")"
664 test_expect_equal_file OUTPUT EXPECTED
665
666 test_begin_subtest "Refresh show buffer"
667 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
668             (test-visible-output "EXPECTED")
669             (notmuch-show-refresh-view)
670             (test-visible-output)'
671 test_expect_equal_file OUTPUT EXPECTED
672
673 test_begin_subtest "Refresh modified show buffer"
674 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
675             (notmuch-show-toggle-message)
676             (notmuch-show-next-message)
677             (notmuch-show-toggle-message)
678             (test-visible-output "EXPECTED")
679             (notmuch-show-refresh-view)
680             (test-visible-output)'
681 test_expect_equal_file OUTPUT EXPECTED
682
683 test_begin_subtest "Do not call notmuch for non-inlinable application/mpeg parts"
684 id='message-with-application/mpeg-attachment@notmuchmail.org'
685 emacs_deliver_message \
686     'Message with application/mpeg attachment' \
687     '' \
688     "(message-goto-eoh)
689      (insert \"Message-ID: <$id>\n\")
690      (message-goto-body)
691      (mml-insert-part \"application/mpeg\")
692      (insert \"a fake mp3 file\")"
693 notmuch_counter_reset
694 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
695               (notmuch-show \"id:$id\"))"
696 test_expect_equal $(notmuch_counter_value) 1
697
698 test_begin_subtest "Do not call notmuch for non-inlinable audio/mpeg parts"
699 id='message-with-audio/mpeg-attachment@notmuchmail.org'
700 emacs_deliver_message \
701     'Message with audio/mpeg attachment' \
702     '' \
703     "(message-goto-eoh)
704      (insert \"Message-ID: <$id>\n\")
705      (message-goto-body)
706      (mml-insert-part \"audio/mpeg\")
707      (insert \"a fake mp3 file\")"
708 notmuch_counter_reset
709 test_emacs "(let ((notmuch-command \"$notmuch_counter_command\"))
710               (notmuch-show \"id:$id\"))"
711 test_expect_equal $(notmuch_counter_value) 1
712
713 test_begin_subtest "notmuch-hello-mode hook is called"
714 counter=$(test_emacs \
715     '(let ((notmuch-hello-mode-hook-counter 0))
716        (kill-buffer "*notmuch-hello*")
717        (notmuch-hello)
718        notmuch-hello-mode-hook-counter)'
719 )
720 test_expect_equal "$counter" 1
721
722 test_begin_subtest "notmuch-hello-mode hook is not called on updates"
723 counter=$(test_emacs \
724     '(let ((notmuch-hello-mode-hook-counter 0))
725        (kill-buffer "*notmuch-hello*")
726        (notmuch-hello)
727        (notmuch-hello-update)
728        notmuch-hello-mode-hook-counter)'
729 )
730 test_expect_equal "$counter" 1
731
732 test_begin_subtest "notmuch-hello-refresh hook is called"
733 counter=$(test_emacs \
734     '(let ((notmuch-hello-refresh-hook-counter 0))
735        (kill-buffer "*notmuch-hello*")
736        (notmuch-hello)
737        notmuch-hello-refresh-hook-counter)'
738 )
739 test_expect_equal "$counter" 1
740
741 test_begin_subtest "notmuch-hello-refresh hook is called on updates"
742 counter=$(test_emacs \
743     '(let ((notmuch-hello-refresh-hook-counter 0))
744        (kill-buffer "*notmuch-hello*")
745        (notmuch-hello)
746        (notmuch-hello-update)
747        notmuch-hello-refresh-hook-counter)'
748 )
749 test_expect_equal "$counter" 2
750
751 test_done