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