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 "notmuch-show for message with invalid From"
61 add_message "[subject]=\"message-with-invalid-from\"" \
62 "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
63 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
64 test_emacs "(notmuch-show \"$thread\")
67 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
68 Subject: message-with-invalid-from
69 To: Notmuch Test Suite <test_suite@notmuchmail.org>
70 Date: Tue, 05 Jan 2001 15:43:57 -0000
72 This is just a test message (#1)
74 test_expect_equal_file OUTPUT EXPECTED
76 test_begin_subtest "Navigation of notmuch-search to thread view"
77 test_emacs '(notmuch-search "tag:inbox")
79 (goto-char (point-min))
80 (re-search-forward "Working with Maildir")
81 (notmuch-search-show-thread)
84 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
86 test_begin_subtest "Add tag from search view"
87 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
88 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
90 (notmuch-search-add-tag \"tag-from-search-view\")"
91 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
92 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)"
94 test_begin_subtest "Remove tag from search view"
95 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
97 (notmuch-search-remove-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 unread)"
101 test_begin_subtest "Add tag from notmuch-show view"
102 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
103 (notmuch-show-add-tag \"tag-from-show-view\")"
104 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
105 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)"
107 test_begin_subtest "Remove tag from notmuch-show view"
108 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
109 (notmuch-show-remove-tag \"tag-from-show-view\")"
110 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
111 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)"
113 test_begin_subtest "Message with .. in Message-Id:"
114 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
115 test_emacs '(notmuch-search "id:\"123..456@example\"")
117 (notmuch-search-add-tag "search-add")
118 (notmuch-search-add-tag "search-remove")
119 (notmuch-search-remove-tag "search-remove")
120 (notmuch-show "id:\"123..456@example\"")
122 (notmuch-show-add-tag "show-add")
123 (notmuch-show-add-tag "show-remove")
124 (notmuch-show-remove-tag "show-remove")'
125 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
126 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
128 test_begin_subtest "Sending a message via (fake) SMTP"
129 emacs_deliver_message \
130 'Testing message sent via SMTP' \
131 'This is a test that messages are sent via SMTP' \
134 (insert "To: user@example.com\n")'
136 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
137 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
139 From: Notmuch Test Suite <test_suite@notmuchmail.org>
141 Subject: Testing message sent via SMTP
142 Date: 01 Jan 2000 12:00:00 -0000
143 User-Agent: Notmuch/XXX Emacs/XXX
146 Content-Type: text/plain; charset=us-ascii
148 This is a test that messages are sent via SMTP
150 test_expect_equal_file OUTPUT EXPECTED
152 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
153 notmuch new > /dev/null
154 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
155 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
157 test_begin_subtest "notmuch-fcc-dirs set to nil"
158 test_emacs "(let ((notmuch-fcc-dirs nil))
162 From: Notmuch Test Suite <test_suite@notmuchmail.org>
165 --text follows this line--
167 test_expect_equal_file OUTPUT EXPECTED
169 # Make another FCC maildir specific for the next test
170 mkdir -p mail/sent-string/cur
171 mkdir -p mail/sent-string/new
172 mkdir -p mail/sent-string/tmp
174 test_begin_subtest "notmuch-fcc-dirs set to a string"
175 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
179 From: Notmuch Test Suite <test_suite@notmuchmail.org>
182 Fcc: ${MAIL_DIR}/sent-string
183 --text follows this line--
185 test_expect_equal_file OUTPUT EXPECTED
187 # Make more FCC maildirs specific for the next test
188 mkdir -p mail/sent-list-match/cur
189 mkdir -p mail/sent-list-match/new
190 mkdir -p mail/sent-list-match/tmp
191 mkdir -p mail/failure/cur
192 mkdir -p mail/failure/new
193 mkdir -p mail/failure/tmp
195 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
196 test_emacs "(let ((notmuch-fcc-dirs
197 '((\"notmuchmail.org\" . \"sent-list-match\")
198 (\".*\" . \"failure\"))))
202 From: Notmuch Test Suite <test_suite@notmuchmail.org>
205 Fcc: ${MAIL_DIR}/sent-list-match
206 --text follows this line--
208 test_expect_equal_file OUTPUT EXPECTED
210 # Make another FCC maildir specific for the next test
211 mkdir -p mail/sent-list-catch-all/cur
212 mkdir -p mail/sent-list-catch-all/new
213 mkdir -p mail/sent-list-catch-all/tmp
215 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
216 test_emacs "(let ((notmuch-fcc-dirs
217 '((\"example.com\" . \"failure\")
218 (\".*\" . \"sent-list-catch-all\"))))
222 From: Notmuch Test Suite <test_suite@notmuchmail.org>
225 Fcc: ${MAIL_DIR}/sent-list-catch-all
226 --text follows this line--
228 test_expect_equal_file OUTPUT EXPECTED
230 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
231 test_emacs "(let ((notmuch-fcc-dirs
232 '((\"example.com\" . \"failure\")
233 (\"nomatchhere.net\" . \"failure\"))))
237 From: Notmuch Test Suite <test_suite@notmuchmail.org>
240 --text follows this line--
242 test_expect_equal_file OUTPUT EXPECTED
244 test_begin_subtest "Reply within emacs"
245 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
247 (notmuch-search-reply-to-thread)
249 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
251 From: Notmuch Test Suite <test_suite@notmuchmail.org>
253 Subject: Re: Testing message sent via SMTP
255 Fcc: $(pwd)/mail/sent
256 --text follows this line--
257 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
258 > This is a test that messages are sent via SMTP
260 test_expect_equal_file OUTPUT EXPECTED
262 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
263 # save as archive to test that Emacs does not re-compress .gz
264 test_emacs '(let ((standard-input "\"attachment1.gz\""))
265 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
266 (notmuch-show-save-attachments))'
267 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
269 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
270 # save as archive to test that Emacs does not re-compress .gz
271 test_emacs '(let ((standard-input "\"attachment2.gz\""))
272 (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
273 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
275 test_begin_subtest "View raw message within emacs"
276 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
277 (notmuch-show-view-raw-message)
279 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
281 test_begin_subtest "Hiding/showing signature in notmuch-show view"
282 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
283 test_emacs "(notmuch-show \"$maildir_storage_thread\")
284 (search-forward \"Click/Enter to show.\")
285 (button-activate (button-at (point)))
286 (search-backward \"Click/Enter to hide.\")
287 (button-activate (button-at (point)))
289 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
291 test_begin_subtest "Detection and hiding of top-post quoting of message"
292 add_message '[subject]="The problem with top-posting"' \
293 [id]=top-post-target \
294 '[body]="A: Because it messes up the order in which people normally read text.
295 Q: Why is top-posting such a bad thing?
297 Q: What is the most annoying thing in e-mail?"'
298 add_message '[from]="Top Poster <top@poster.com>"' \
299 [in-reply-to]=top-post-target \
300 [references]=top-post-target \
301 '[subject]="Re: The problem with top-posting"' \
302 '[body]="Thanks for the advice! I will be sure to put it to good use.
306 ----- Original Message -----
307 From: Notmuch Test Suite <test_suite@notmuchmail.org>
308 To: Notmuch Test Suite <test_suite@notmuchmai.org>
309 Sent: Tue, 05 Jan 2001 15:43:57 -0000
310 Subject: The problem with top-posting
312 Q: Why is top-posting such a bad thing?
314 Q: What is the most annoying thing in e-mail?"'
315 test_emacs "(notmuch-show \"top-posting\")
316 (test-visible-output)"
317 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
318 Subject: The problem with top-posting
319 To: Notmuch Test Suite <test_suite@notmuchmail.org>
320 Date: Tue, 05 Jan 2001 15:43:57 -0000
322 A: Because it messes up the order in which people normally read text.
323 Q: Why is top-posting such a bad thing?
325 Q: What is the most annoying thing in e-mail?
326 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
327 Subject: Re: The problem with top-posting
328 To: Notmuch Test Suite <test_suite@notmuchmail.org>
329 Date: Tue, 05 Jan 2001 15:43:57 -0000
331 Thanks for the advice! I will be sure to put it to good use.
335 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
336 test_expect_equal_file OUTPUT EXPECTED
338 test_begin_subtest "Hiding message in notmuch-show view"
339 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
340 (notmuch-show-toggle-message)
341 (test-visible-output)'
342 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
344 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
345 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
346 (search-forward "Click/Enter to show.")
347 (button-activate (button-at (point)))
348 (notmuch-show-toggle-message)
349 (test-visible-output)'
350 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
352 test_begin_subtest "Stashing in notmuch-show"
353 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
354 '[from]="Some One <someone@somewhere.org>"' \
355 '[to]="Some One Else <notsomeone@somewhere.org>"' \
356 '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
357 '[subject]="Stash my stashables"' \
359 '[body]="Unable to stash body. Where did you get it in the first place?!?"'
360 notmuch tag +stashtest id:${gen_msg_id}
361 test_emacs '(notmuch-show "id:\"bought\"")
362 (notmuch-show-stash-date)
363 (notmuch-show-stash-from)
364 (notmuch-show-stash-to)
365 (notmuch-show-stash-cc)
366 (notmuch-show-stash-subject)
367 (notmuch-show-stash-message-id)
368 (notmuch-show-stash-message-id-stripped)
369 (notmuch-show-stash-tags)
370 (notmuch-show-stash-filename)
372 (generate-new-buffer "*test-stashing*"))
376 (rotate-yank-pointer 1))
377 (reverse-region (point-min) (point-max))
380 Sat, 01 Jan 2000 12:00:00 -0000
381 Some One <someone@somewhere.org>
382 Some One Else <notsomeone@somewhere.org>
383 Notmuch <notmuch@notmuchmail.org>
390 test_expect_equal_file OUTPUT EXPECTED
392 test_begin_subtest "Stashing in notmuch-search"
393 test_emacs '(notmuch-search "id:\"bought\"")
395 (notmuch-search-stash-thread-id)
397 (generate-new-buffer "*test-stashing*"))
400 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
401 test_expect_equal $(cat OUTPUT) "thread:XXX"
403 test_begin_subtest 'Hiding message following HTML part'
404 test_subtest_known_broken
405 id='html-message@notmuchmail.org'
406 emacs_deliver_message \
410 (insert \"Message-ID: <$id>\n\")
412 (mml-insert-part \"text/html\")
413 (insert \"<body>This is a test HTML message</body>\")"
414 emacs_deliver_message \
415 'Reply to HTML message' \
416 'This is a reply to the test HTML message' \
418 (insert \"In-Reply-To: <$id>\n\")"
419 test_emacs "(notmuch-show \"id:$id\") \
420 (notmuch-show-next-message) \
421 (command-execute (key-binding (kbd \"RET\"))) \
422 (test-visible-output)"
423 test_emacs "(notmuch-show \"id:$id\") \
424 (notmuch-show-next-message) \
425 (notmuch-show-toggle-message) \
426 (test-visible-output \"EXPECTED\")"
427 test_expect_equal_file OUTPUT EXPECTED
429 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
430 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
431 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
432 test_emacs "(notmuch-search \"$message1 or $message2\")
434 (notmuch-search-show-thread)
435 (goto-char (point-max))
437 (notmuch-show-advance-and-archive)
439 test_emacs "(notmuch-show \"$message2\")
440 (test-output \"EXPECTED\")"
441 test_expect_equal_file OUTPUT EXPECTED
443 test_begin_subtest "Refresh show buffer"
444 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
445 (test-visible-output "EXPECTED")
446 (notmuch-show-refresh-view)
447 (test-visible-output)'
448 test_expect_equal_file OUTPUT EXPECTED
450 test_begin_subtest "Refresh modified show buffer"
451 test_subtest_known_broken
452 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
453 (notmuch-show-toggle-message)
454 (notmuch-show-next-message)
455 (notmuch-show-toggle-message)
456 (test-visible-output "EXPECTED")
457 (notmuch-show-refresh-view)
458 (test-visible-output)'
459 test_expect_equal_file OUTPUT EXPECTED