3 test_description="emacs interface"
6 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
10 test_begin_subtest "Basic notmuch-hello view in emacs"
11 test_emacs '(notmuch-hello)
13 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
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"))))
23 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
25 test_begin_subtest "No saved searches displayed (all with 0 results)"
26 test_emacs '(let ((notmuch-saved-searches
27 '\''(("empty" . "tag:doesnotexist"))))
30 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
32 test_begin_subtest "Basic notmuch-search view in emacs"
33 test_emacs '(notmuch-search "tag:inbox")
36 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
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))
45 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
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\")
51 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
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-indent-messages-width 1))
56 (notmuch-show \"$maildir_storage_thread\")
58 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
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-indent-messages-width 0))
63 (notmuch-show \"$maildir_storage_thread\")
65 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation
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-indent-messages-width 4))
70 (notmuch-show \"$maildir_storage_thread\")
72 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-with-fourfold-indentation
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\")
81 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
82 Subject: message-with-invalid-from
83 To: Notmuch Test Suite <test_suite@notmuchmail.org>
84 Date: Tue, 05 Jan 2001 15:43:57 -0000
86 This is just a test message (#1)
88 test_expect_equal_file OUTPUT EXPECTED
90 test_begin_subtest "Navigation of notmuch-search to thread view"
91 test_emacs '(notmuch-search "tag:inbox")
93 (goto-char (point-min))
94 (re-search-forward "Working with Maildir")
95 (notmuch-search-show-thread)
98 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
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\")
104 (notmuch-search-add-tag \"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)"
108 test_begin_subtest "Remove tag from search view"
109 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
111 (notmuch-search-remove-tag \"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)"
115 test_begin_subtest "Add tag from notmuch-show view"
116 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
117 (notmuch-show-add-tag \"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)"
121 test_begin_subtest "Remove tag from notmuch-show view"
122 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
123 (notmuch-show-remove-tag \"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)"
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\"")
131 (notmuch-search-add-tag "search-add")
132 (notmuch-search-add-tag "search-remove")
133 (notmuch-search-remove-tag "search-remove")
134 (notmuch-show "id:\"123..456@example\"")
136 (notmuch-show-add-tag "show-add")
137 (notmuch-show-add-tag "show-remove")
138 (notmuch-show-remove-tag "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)"
142 test_begin_subtest "Sending a message via (fake) SMTP"
143 emacs_deliver_message \
144 'Testing message sent via SMTP' \
145 'This is a test that messages are sent via SMTP' \
148 (insert "To: user@example.com\n")'
150 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
151 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
153 From: Notmuch Test Suite <test_suite@notmuchmail.org>
155 Subject: Testing message sent via SMTP
156 Date: 01 Jan 2000 12:00:00 -0000
157 User-Agent: Notmuch/XXX Emacs/XXX
160 Content-Type: text/plain; charset=us-ascii
162 This is a test that messages are sent via SMTP
164 test_expect_equal_file OUTPUT EXPECTED
166 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
167 notmuch new > /dev/null
168 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
169 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
171 test_begin_subtest "notmuch-fcc-dirs set to nil"
172 test_emacs "(let ((notmuch-fcc-dirs nil))
176 From: Notmuch Test Suite <test_suite@notmuchmail.org>
179 --text follows this line--
181 test_expect_equal_file OUTPUT EXPECTED
183 # Make another FCC maildir specific for the next test
184 mkdir -p mail/sent-string/cur
185 mkdir -p mail/sent-string/new
186 mkdir -p mail/sent-string/tmp
188 test_begin_subtest "notmuch-fcc-dirs set to a string"
189 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
193 From: Notmuch Test Suite <test_suite@notmuchmail.org>
196 Fcc: ${MAIL_DIR}/sent-string
197 --text follows this line--
199 test_expect_equal_file OUTPUT EXPECTED
201 # Make more FCC maildirs specific for the next test
202 mkdir -p mail/sent-list-match/cur
203 mkdir -p mail/sent-list-match/new
204 mkdir -p mail/sent-list-match/tmp
205 mkdir -p mail/failure/cur
206 mkdir -p mail/failure/new
207 mkdir -p mail/failure/tmp
209 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
210 test_emacs "(let ((notmuch-fcc-dirs
211 '((\"notmuchmail.org\" . \"sent-list-match\")
212 (\".*\" . \"failure\"))))
216 From: Notmuch Test Suite <test_suite@notmuchmail.org>
219 Fcc: ${MAIL_DIR}/sent-list-match
220 --text follows this line--
222 test_expect_equal_file OUTPUT EXPECTED
224 # Make another FCC maildir specific for the next test
225 mkdir -p mail/sent-list-catch-all/cur
226 mkdir -p mail/sent-list-catch-all/new
227 mkdir -p mail/sent-list-catch-all/tmp
229 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
230 test_emacs "(let ((notmuch-fcc-dirs
231 '((\"example.com\" . \"failure\")
232 (\".*\" . \"sent-list-catch-all\"))))
236 From: Notmuch Test Suite <test_suite@notmuchmail.org>
239 Fcc: ${MAIL_DIR}/sent-list-catch-all
240 --text follows this line--
242 test_expect_equal_file OUTPUT EXPECTED
244 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
245 test_emacs "(let ((notmuch-fcc-dirs
246 '((\"example.com\" . \"failure\")
247 (\"nomatchhere.net\" . \"failure\"))))
251 From: Notmuch Test Suite <test_suite@notmuchmail.org>
254 --text follows this line--
256 test_expect_equal_file OUTPUT EXPECTED
258 test_begin_subtest "Reply within emacs"
259 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
261 (notmuch-search-reply-to-thread)
263 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
265 From: Notmuch Test Suite <test_suite@notmuchmail.org>
267 Subject: Re: Testing message sent via SMTP
269 Fcc: $(pwd)/mail/sent
270 --text follows this line--
271 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
272 > This is a test that messages are sent via SMTP
274 test_expect_equal_file OUTPUT EXPECTED
276 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
277 # save as archive to test that Emacs does not re-compress .gz
278 test_emacs '(let ((standard-input "\"attachment1.gz\""))
279 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
280 (notmuch-show-save-attachments))'
281 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
283 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
284 # save as archive to test that Emacs does not re-compress .gz
285 test_emacs '(let ((standard-input "\"attachment2.gz\""))
286 (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
287 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
289 test_begin_subtest "View raw message within emacs"
290 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
291 (notmuch-show-view-raw-message)
293 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
295 test_begin_subtest "Hiding/showing signature in notmuch-show view"
296 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
297 test_emacs "(notmuch-show \"$maildir_storage_thread\")
298 (search-forward \"Click/Enter to show.\")
299 (button-activate (button-at (point)))
300 (search-backward \"Click/Enter to hide.\")
301 (button-activate (button-at (point)))
303 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
305 test_begin_subtest "Detection and hiding of top-post quoting of message"
306 add_message '[subject]="The problem with top-posting"' \
307 [id]=top-post-target \
308 '[body]="A: Because it messes up the order in which people normally read text.
309 Q: Why is top-posting such a bad thing?
311 Q: What is the most annoying thing in e-mail?"'
312 add_message '[from]="Top Poster <top@poster.com>"' \
313 [in-reply-to]=top-post-target \
314 [references]=top-post-target \
315 '[subject]="Re: The problem with top-posting"' \
316 '[body]="Thanks for the advice! I will be sure to put it to good use.
320 ----- Original Message -----
321 From: Notmuch Test Suite <test_suite@notmuchmail.org>
322 To: Notmuch Test Suite <test_suite@notmuchmai.org>
323 Sent: Tue, 05 Jan 2001 15:43:57 -0000
324 Subject: The problem with top-posting
326 Q: Why is top-posting such a bad thing?
328 Q: What is the most annoying thing in e-mail?"'
329 test_emacs "(notmuch-show \"top-posting\")
330 (test-visible-output)"
331 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
332 Subject: The problem with top-posting
333 To: Notmuch Test Suite <test_suite@notmuchmail.org>
334 Date: Tue, 05 Jan 2001 15:43:57 -0000
336 A: Because it messes up the order in which people normally read text.
337 Q: Why is top-posting such a bad thing?
339 Q: What is the most annoying thing in e-mail?
340 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
341 Subject: Re: The problem with top-posting
342 To: Notmuch Test Suite <test_suite@notmuchmail.org>
343 Date: Tue, 05 Jan 2001 15:43:57 -0000
345 Thanks for the advice! I will be sure to put it to good use.
349 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
350 test_expect_equal_file OUTPUT EXPECTED
352 test_begin_subtest "Hiding message in notmuch-show view"
353 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
354 (notmuch-show-toggle-message)
355 (test-visible-output)'
356 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
358 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
359 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
360 (search-forward "Click/Enter to show.")
361 (button-activate (button-at (point)))
362 (notmuch-show-toggle-message)
363 (test-visible-output)'
364 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
366 test_begin_subtest "Stashing in notmuch-show"
367 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
368 '[from]="Some One <someone@somewhere.org>"' \
369 '[to]="Some One Else <notsomeone@somewhere.org>"' \
370 '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
371 '[subject]="Stash my stashables"' \
373 '[body]="Unable to stash body. Where did you get it in the first place?!?"'
374 notmuch tag +stashtest id:${gen_msg_id}
375 test_emacs '(notmuch-show "id:\"bought\"")
376 (notmuch-show-stash-date)
377 (notmuch-show-stash-from)
378 (notmuch-show-stash-to)
379 (notmuch-show-stash-cc)
380 (notmuch-show-stash-subject)
381 (notmuch-show-stash-message-id)
382 (notmuch-show-stash-message-id-stripped)
383 (notmuch-show-stash-tags)
384 (notmuch-show-stash-filename)
386 (generate-new-buffer "*test-stashing*"))
390 (rotate-yank-pointer 1))
391 (reverse-region (point-min) (point-max))
394 Sat, 01 Jan 2000 12:00:00 -0000
395 Some One <someone@somewhere.org>
396 Some One Else <notsomeone@somewhere.org>
397 Notmuch <notmuch@notmuchmail.org>
404 test_expect_equal_file OUTPUT EXPECTED
406 test_begin_subtest "Stashing in notmuch-search"
407 test_emacs '(notmuch-search "id:\"bought\"")
409 (notmuch-search-stash-thread-id)
411 (generate-new-buffer "*test-stashing*"))
414 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
415 test_expect_equal "$(cat OUTPUT)" "thread:XXX"
417 test_begin_subtest 'Hiding message following HTML part'
418 test_subtest_known_broken
419 id='html-message@notmuchmail.org'
420 emacs_deliver_message \
424 (insert \"Message-ID: <$id>\n\")
426 (mml-insert-part \"text/html\")
427 (insert \"<body>This is a test HTML message</body>\")"
428 emacs_deliver_message \
429 'Reply to HTML message' \
430 'This is a reply to the test HTML message' \
432 (insert \"In-Reply-To: <$id>\n\")"
433 test_emacs "(notmuch-show \"id:$id\") \
434 (notmuch-show-next-message) \
435 (command-execute (key-binding (kbd \"RET\"))) \
436 (test-visible-output)"
437 test_emacs "(notmuch-show \"id:$id\") \
438 (notmuch-show-next-message) \
439 (notmuch-show-toggle-message) \
440 (test-visible-output \"EXPECTED\")"
441 test_expect_equal_file OUTPUT EXPECTED
443 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
444 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
445 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
446 test_emacs "(notmuch-search \"$message1 or $message2\")
448 (notmuch-search-show-thread)
449 (goto-char (point-max))
451 (notmuch-show-advance-and-archive)
453 test_emacs "(notmuch-show \"$message2\")
454 (test-output \"EXPECTED\")"
455 test_expect_equal_file OUTPUT EXPECTED
457 test_begin_subtest "Refresh show buffer"
458 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
459 (test-visible-output "EXPECTED")
460 (notmuch-show-refresh-view)
461 (test-visible-output)'
462 test_expect_equal_file OUTPUT EXPECTED
464 test_begin_subtest "Refresh modified show buffer"
465 test_subtest_known_broken
466 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
467 (notmuch-show-toggle-message)
468 (notmuch-show-next-message)
469 (notmuch-show-toggle-message)
470 (test-visible-output "EXPECTED")
471 (notmuch-show-refresh-view)
472 (test-visible-output)'
473 test_expect_equal_file OUTPUT EXPECTED