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 "notmuch-show for message with invalid From"
68 add_message "[subject]=\"message-with-invalid-from\"" \
69 "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
70 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
71 test_emacs "(notmuch-show \"$thread\")
74 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
75 Subject: message-with-invalid-from
76 To: Notmuch Test Suite <test_suite@notmuchmail.org>
77 Date: Tue, 05 Jan 2001 15:43:57 -0000
79 This is just a test message (#1)
81 test_expect_equal_file OUTPUT EXPECTED
83 test_begin_subtest "Navigation of notmuch-search to thread view"
84 test_emacs '(notmuch-search "tag:inbox")
86 (goto-char (point-min))
87 (re-search-forward "Working with Maildir")
88 (notmuch-search-show-thread)
91 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
93 test_begin_subtest "Add tag from search view"
94 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
95 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
97 (notmuch-search-add-tag \"tag-from-search-view\")"
98 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
99 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)"
101 test_begin_subtest "Remove tag from search view"
102 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
104 (notmuch-search-remove-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 unread)"
108 test_begin_subtest "Add tag from notmuch-show view"
109 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
110 (notmuch-show-add-tag \"tag-from-show-view\")"
111 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
112 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)"
114 test_begin_subtest "Remove tag from notmuch-show view"
115 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
116 (notmuch-show-remove-tag \"tag-from-show-view\")"
117 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
118 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)"
120 test_begin_subtest "Message with .. in Message-Id:"
121 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
122 test_emacs '(notmuch-search "id:\"123..456@example\"")
124 (notmuch-search-add-tag "search-add")
125 (notmuch-search-add-tag "search-remove")
126 (notmuch-search-remove-tag "search-remove")
127 (notmuch-show "id:\"123..456@example\"")
129 (notmuch-show-add-tag "show-add")
130 (notmuch-show-add-tag "show-remove")
131 (notmuch-show-remove-tag "show-remove")'
132 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
133 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
135 test_begin_subtest "Sending a message via (fake) SMTP"
136 emacs_deliver_message \
137 'Testing message sent via SMTP' \
138 'This is a test that messages are sent via SMTP' \
141 (insert "To: user@example.com\n")'
143 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
144 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
146 From: Notmuch Test Suite <test_suite@notmuchmail.org>
148 Subject: Testing message sent via SMTP
149 Date: 01 Jan 2000 12:00:00 -0000
150 User-Agent: Notmuch/XXX Emacs/XXX
153 Content-Type: text/plain; charset=us-ascii
155 This is a test that messages are sent via SMTP
157 test_expect_equal_file OUTPUT EXPECTED
159 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
160 notmuch new > /dev/null
161 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
162 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
164 test_begin_subtest "notmuch-fcc-dirs set to nil"
165 test_emacs "(let ((notmuch-fcc-dirs nil))
169 From: Notmuch Test Suite <test_suite@notmuchmail.org>
172 --text follows this line--
174 test_expect_equal_file OUTPUT EXPECTED
176 # Make another FCC maildir specific for the next test
177 mkdir -p mail/sent-string/cur
178 mkdir -p mail/sent-string/new
179 mkdir -p mail/sent-string/tmp
181 test_begin_subtest "notmuch-fcc-dirs set to a string"
182 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
186 From: Notmuch Test Suite <test_suite@notmuchmail.org>
189 Fcc: ${MAIL_DIR}/sent-string
190 --text follows this line--
192 test_expect_equal_file OUTPUT EXPECTED
194 # Make more FCC maildirs specific for the next test
195 mkdir -p mail/sent-list-match/cur
196 mkdir -p mail/sent-list-match/new
197 mkdir -p mail/sent-list-match/tmp
198 mkdir -p mail/failure/cur
199 mkdir -p mail/failure/new
200 mkdir -p mail/failure/tmp
202 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
203 test_emacs "(let ((notmuch-fcc-dirs
204 '((\"notmuchmail.org\" . \"sent-list-match\")
205 (\".*\" . \"failure\"))))
209 From: Notmuch Test Suite <test_suite@notmuchmail.org>
212 Fcc: ${MAIL_DIR}/sent-list-match
213 --text follows this line--
215 test_expect_equal_file OUTPUT EXPECTED
217 # Make another FCC maildir specific for the next test
218 mkdir -p mail/sent-list-catch-all/cur
219 mkdir -p mail/sent-list-catch-all/new
220 mkdir -p mail/sent-list-catch-all/tmp
222 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
223 test_emacs "(let ((notmuch-fcc-dirs
224 '((\"example.com\" . \"failure\")
225 (\".*\" . \"sent-list-catch-all\"))))
229 From: Notmuch Test Suite <test_suite@notmuchmail.org>
232 Fcc: ${MAIL_DIR}/sent-list-catch-all
233 --text follows this line--
235 test_expect_equal_file OUTPUT EXPECTED
237 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
238 test_emacs "(let ((notmuch-fcc-dirs
239 '((\"example.com\" . \"failure\")
240 (\"nomatchhere.net\" . \"failure\"))))
244 From: Notmuch Test Suite <test_suite@notmuchmail.org>
247 --text follows this line--
249 test_expect_equal_file OUTPUT EXPECTED
251 test_begin_subtest "Reply within emacs"
252 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
254 (notmuch-search-reply-to-thread)
256 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
258 From: Notmuch Test Suite <test_suite@notmuchmail.org>
260 Subject: Re: Testing message sent via SMTP
262 Fcc: $(pwd)/mail/sent
263 --text follows this line--
264 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
265 > This is a test that messages are sent via SMTP
267 test_expect_equal_file OUTPUT EXPECTED
269 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
270 # save as archive to test that Emacs does not re-compress .gz
271 test_emacs '(let ((standard-input "\"attachment1.gz\""))
272 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
273 (notmuch-show-save-attachments))'
274 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
276 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
277 # save as archive to test that Emacs does not re-compress .gz
278 test_emacs '(let ((standard-input "\"attachment2.gz\""))
279 (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
280 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
282 test_begin_subtest "View raw message within emacs"
283 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
284 (notmuch-show-view-raw-message)
286 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
288 test_begin_subtest "Hiding/showing signature in notmuch-show view"
289 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
290 test_emacs "(notmuch-show \"$maildir_storage_thread\")
291 (search-forward \"Click/Enter to show.\")
292 (button-activate (button-at (point)))
293 (search-backward \"Click/Enter to hide.\")
294 (button-activate (button-at (point)))
296 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
298 test_begin_subtest "Detection and hiding of top-post quoting of message"
299 add_message '[subject]="The problem with top-posting"' \
300 [id]=top-post-target \
301 '[body]="A: Because it messes up the order in which people normally read text.
302 Q: Why is top-posting such a bad thing?
304 Q: What is the most annoying thing in e-mail?"'
305 add_message '[from]="Top Poster <top@poster.com>"' \
306 [in-reply-to]=top-post-target \
307 [references]=top-post-target \
308 '[subject]="Re: The problem with top-posting"' \
309 '[body]="Thanks for the advice! I will be sure to put it to good use.
313 ----- Original Message -----
314 From: Notmuch Test Suite <test_suite@notmuchmail.org>
315 To: Notmuch Test Suite <test_suite@notmuchmai.org>
316 Sent: Tue, 05 Jan 2001 15:43:57 -0000
317 Subject: The problem with top-posting
319 Q: Why is top-posting such a bad thing?
321 Q: What is the most annoying thing in e-mail?"'
322 test_emacs "(notmuch-show \"top-posting\")
323 (test-visible-output)"
324 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
325 Subject: The problem with top-posting
326 To: Notmuch Test Suite <test_suite@notmuchmail.org>
327 Date: Tue, 05 Jan 2001 15:43:57 -0000
329 A: Because it messes up the order in which people normally read text.
330 Q: Why is top-posting such a bad thing?
332 Q: What is the most annoying thing in e-mail?
333 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
334 Subject: Re: The problem with top-posting
335 To: Notmuch Test Suite <test_suite@notmuchmail.org>
336 Date: Tue, 05 Jan 2001 15:43:57 -0000
338 Thanks for the advice! I will be sure to put it to good use.
342 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
343 test_expect_equal_file OUTPUT EXPECTED
345 test_begin_subtest "Hiding message in notmuch-show view"
346 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
347 (notmuch-show-toggle-message)
348 (test-visible-output)'
349 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
351 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
352 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
353 (search-forward "Click/Enter to show.")
354 (button-activate (button-at (point)))
355 (notmuch-show-toggle-message)
356 (test-visible-output)'
357 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
359 test_begin_subtest "Stashing in notmuch-show"
360 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
361 '[from]="Some One <someone@somewhere.org>"' \
362 '[to]="Some One Else <notsomeone@somewhere.org>"' \
363 '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
364 '[subject]="Stash my stashables"' \
366 '[body]="Unable to stash body. Where did you get it in the first place?!?"'
367 notmuch tag +stashtest id:${gen_msg_id}
368 test_emacs '(notmuch-show "id:\"bought\"")
369 (notmuch-show-stash-date)
370 (notmuch-show-stash-from)
371 (notmuch-show-stash-to)
372 (notmuch-show-stash-cc)
373 (notmuch-show-stash-subject)
374 (notmuch-show-stash-message-id)
375 (notmuch-show-stash-message-id-stripped)
376 (notmuch-show-stash-tags)
377 (notmuch-show-stash-filename)
379 (generate-new-buffer "*test-stashing*"))
383 (rotate-yank-pointer 1))
384 (reverse-region (point-min) (point-max))
387 Sat, 01 Jan 2000 12:00:00 -0000
388 Some One <someone@somewhere.org>
389 Some One Else <notsomeone@somewhere.org>
390 Notmuch <notmuch@notmuchmail.org>
397 test_expect_equal_file OUTPUT EXPECTED
399 test_begin_subtest "Stashing in notmuch-search"
400 test_emacs '(notmuch-search "id:\"bought\"")
402 (notmuch-search-stash-thread-id)
404 (generate-new-buffer "*test-stashing*"))
407 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
408 test_expect_equal $(cat OUTPUT) "thread:XXX"
410 test_begin_subtest 'Hiding message following HTML part'
411 test_subtest_known_broken
412 id='html-message@notmuchmail.org'
413 emacs_deliver_message \
417 (insert \"Message-ID: <$id>\n\")
419 (mml-insert-part \"text/html\")
420 (insert \"<body>This is a test HTML message</body>\")"
421 emacs_deliver_message \
422 'Reply to HTML message' \
423 'This is a reply to the test HTML message' \
425 (insert \"In-Reply-To: <$id>\n\")"
426 test_emacs "(notmuch-show \"id:$id\") \
427 (notmuch-show-next-message) \
428 (command-execute (key-binding (kbd \"RET\"))) \
429 (test-visible-output)"
430 test_emacs "(notmuch-show \"id:$id\") \
431 (notmuch-show-next-message) \
432 (notmuch-show-toggle-message) \
433 (test-visible-output \"EXPECTED\")"
434 test_expect_equal_file OUTPUT EXPECTED
436 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
437 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
438 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
439 test_emacs "(notmuch-search \"$message1 or $message2\")
441 (notmuch-search-show-thread)
442 (goto-char (point-max))
444 (notmuch-show-advance-and-archive)
446 test_emacs "(notmuch-show \"$message2\")
447 (test-output \"EXPECTED\")"
448 test_expect_equal_file OUTPUT EXPECTED
450 test_begin_subtest "Refresh show buffer"
451 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
452 (test-visible-output "EXPECTED")
453 (notmuch-show-refresh-view)
454 (test-visible-output)'
455 test_expect_equal_file OUTPUT EXPECTED
457 test_begin_subtest "Refresh modified show buffer"
458 test_subtest_known_broken
459 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
460 (notmuch-show-toggle-message)
461 (notmuch-show-next-message)
462 (notmuch-show-toggle-message)
463 (test-visible-output "EXPECTED")
464 (notmuch-show-refresh-view)
465 (test-visible-output)'
466 test_expect_equal_file OUTPUT EXPECTED