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 "notmuch-show for message with invalid From"
54 add_message "[subject]=\"message-with-invalid-from\"" \
55 "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
56 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
57 test_emacs "(notmuch-show \"$thread\")
60 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
61 Subject: message-with-invalid-from
62 To: Notmuch Test Suite <test_suite@notmuchmail.org>
63 Date: Tue, 05 Jan 2001 15:43:57 -0000
65 This is just a test message (#1)
67 test_expect_equal_file OUTPUT EXPECTED
69 test_begin_subtest "Navigation of notmuch-search to thread view"
70 test_emacs '(notmuch-search "tag:inbox")
72 (goto-char (point-min))
73 (re-search-forward "Working with Maildir")
74 (notmuch-search-show-thread)
77 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
79 test_begin_subtest "Add tag from search view"
80 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
81 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
83 (notmuch-search-add-tag \"tag-from-search-view\")"
84 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
85 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)"
87 test_begin_subtest "Remove tag from search view"
88 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
90 (notmuch-search-remove-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 unread)"
94 test_begin_subtest "Add tag from notmuch-show view"
95 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
96 (notmuch-show-add-tag \"tag-from-show-view\")"
97 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
98 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)"
100 test_begin_subtest "Remove tag from notmuch-show view"
101 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
102 (notmuch-show-remove-tag \"tag-from-show-view\")"
103 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
104 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)"
106 test_begin_subtest "Message with .. in Message-Id:"
107 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
108 test_emacs '(notmuch-search "id:\"123..456@example\"")
110 (notmuch-search-add-tag "search-add")
111 (notmuch-search-add-tag "search-remove")
112 (notmuch-search-remove-tag "search-remove")
113 (notmuch-show "id:\"123..456@example\"")
115 (notmuch-show-add-tag "show-add")
116 (notmuch-show-add-tag "show-remove")
117 (notmuch-show-remove-tag "show-remove")'
118 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
119 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
121 test_begin_subtest "Sending a message via (fake) SMTP"
122 emacs_deliver_message \
123 'Testing message sent via SMTP' \
124 'This is a test that messages are sent via SMTP' \
127 (insert "To: user@example.com\n")'
129 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
130 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
132 From: Notmuch Test Suite <test_suite@notmuchmail.org>
134 Subject: Testing message sent via SMTP
135 Date: 01 Jan 2000 12:00:00 -0000
136 User-Agent: Notmuch/XXX Emacs/XXX
139 Content-Type: text/plain; charset=us-ascii
141 This is a test that messages are sent via SMTP
143 test_expect_equal_file OUTPUT EXPECTED
145 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
146 notmuch new > /dev/null
147 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
148 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
150 test_begin_subtest "notmuch-fcc-dirs set to nil"
151 test_emacs "(let ((notmuch-fcc-dirs nil))
155 From: Notmuch Test Suite <test_suite@notmuchmail.org>
158 --text follows this line--
160 test_expect_equal_file OUTPUT EXPECTED
162 # Make another FCC maildir specific for the next test
163 mkdir -p mail/sent-string/cur
164 mkdir -p mail/sent-string/new
165 mkdir -p mail/sent-string/tmp
167 test_begin_subtest "notmuch-fcc-dirs set to a string"
168 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
172 From: Notmuch Test Suite <test_suite@notmuchmail.org>
175 Fcc: ${MAIL_DIR}/sent-string
176 --text follows this line--
178 test_expect_equal_file OUTPUT EXPECTED
180 # Make more FCC maildirs specific for the next test
181 mkdir -p mail/sent-list-match/cur
182 mkdir -p mail/sent-list-match/new
183 mkdir -p mail/sent-list-match/tmp
184 mkdir -p mail/failure/cur
185 mkdir -p mail/failure/new
186 mkdir -p mail/failure/tmp
188 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
189 test_emacs "(let ((notmuch-fcc-dirs
190 '((\"notmuchmail.org\" . \"sent-list-match\")
191 (\".*\" . \"failure\"))))
195 From: Notmuch Test Suite <test_suite@notmuchmail.org>
198 Fcc: ${MAIL_DIR}/sent-list-match
199 --text follows this line--
201 test_expect_equal_file OUTPUT EXPECTED
203 # Make another FCC maildir specific for the next test
204 mkdir -p mail/sent-list-catch-all/cur
205 mkdir -p mail/sent-list-catch-all/new
206 mkdir -p mail/sent-list-catch-all/tmp
208 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
209 test_emacs "(let ((notmuch-fcc-dirs
210 '((\"example.com\" . \"failure\")
211 (\".*\" . \"sent-list-catch-all\"))))
215 From: Notmuch Test Suite <test_suite@notmuchmail.org>
218 Fcc: ${MAIL_DIR}/sent-list-catch-all
219 --text follows this line--
221 test_expect_equal_file OUTPUT EXPECTED
223 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
224 test_emacs "(let ((notmuch-fcc-dirs
225 '((\"example.com\" . \"failure\")
226 (\"nomatchhere.net\" . \"failure\"))))
230 From: Notmuch Test Suite <test_suite@notmuchmail.org>
233 --text follows this line--
235 test_expect_equal_file OUTPUT EXPECTED
237 test_begin_subtest "Reply within emacs"
238 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
240 (notmuch-search-reply-to-thread)
242 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
244 From: Notmuch Test Suite <test_suite@notmuchmail.org>
246 Subject: Re: Testing message sent via SMTP
248 Fcc: $(pwd)/mail/sent
249 --text follows this line--
250 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
251 > This is a test that messages are sent via SMTP
253 test_expect_equal_file OUTPUT EXPECTED
255 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
256 # save as archive to test that Emacs does not re-compress .gz
257 test_emacs '(let ((standard-input "\"attachment1.gz\""))
258 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
259 (notmuch-show-save-attachments))' > /dev/null 2>&1
260 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
262 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
263 # save as archive to test that Emacs does not re-compress .gz
264 test_emacs '(let ((standard-input "\"attachment2.gz\""))
265 (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/null 2>&1
266 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
268 test_begin_subtest "View raw message within emacs"
269 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
270 (notmuch-show-view-raw-message)
272 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
274 test_begin_subtest "Hiding/showing signature in notmuch-show view"
275 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
276 test_emacs "(notmuch-show \"$maildir_storage_thread\")
277 (search-forward \"Click/Enter to show.\")
278 (button-activate (button-at (point)))
279 (search-backward \"Click/Enter to hide.\")
280 (button-activate (button-at (point)))
282 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
284 test_begin_subtest "Detection and hiding of top-post quoting of message"
285 add_message '[subject]="The problem with top-posting"' \
286 [id]=top-post-target \
287 '[body]="A: Because it messes up the order in which people normally read text.
288 Q: Why is top-posting such a bad thing?
290 Q: What is the most annoying thing in e-mail?"'
291 add_message '[from]="Top Poster <top@poster.com>"' \
292 [in-reply-to]=top-post-target \
293 [references]=top-post-target \
294 '[subject]="Re: The problem with top-posting"' \
295 '[body]="Thanks for the advice! I will be sure to put it to good use.
299 ----- Original Message -----
300 From: Notmuch Test Suite <test_suite@notmuchmail.org>
301 To: Notmuch Test Suite <test_suite@notmuchmai.org>
302 Sent: Tue, 05 Jan 2001 15:43:57 -0000
303 Subject: The problem with top-posting
305 Q: Why is top-posting such a bad thing?
307 Q: What is the most annoying thing in e-mail?"'
308 test_emacs "(notmuch-show \"top-posting\")
309 (test-visible-output)"
310 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
311 Subject: The problem with top-posting
312 To: Notmuch Test Suite <test_suite@notmuchmail.org>
313 Date: Tue, 05 Jan 2001 15:43:57 -0000
315 A: Because it messes up the order in which people normally read text.
316 Q: Why is top-posting such a bad thing?
318 Q: What is the most annoying thing in e-mail?
319 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
320 Subject: Re: The problem with top-posting
321 To: Notmuch Test Suite <test_suite@notmuchmail.org>
322 Date: Tue, 05 Jan 2001 15:43:57 -0000
324 Thanks for the advice! I will be sure to put it to good use.
328 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
329 test_expect_equal_file OUTPUT EXPECTED
331 test_begin_subtest "Hiding message in notmuch-show view"
332 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
333 (notmuch-show-toggle-message)
334 (test-visible-output)'
335 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
337 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
338 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
339 (search-forward "Click/Enter to show.")
340 (button-activate (button-at (point)))
341 (notmuch-show-toggle-message)
342 (test-visible-output)'
343 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
345 test_begin_subtest 'Hiding message following HTML part'
346 test_subtest_known_broken
347 id='html-message@notmuchmail.org'
348 emacs_deliver_message \
352 (insert \"Message-ID: <$id>\n\")
354 (mml-insert-part \"text/html\")
355 (insert \"<body>This is a test HTML message</body>\")"
356 emacs_deliver_message \
357 'Reply to HTML message' \
358 'This is a reply to the test HTML message' \
360 (insert \"In-Reply-To: <$id>\n\")"
361 test_emacs "(notmuch-show \"id:$id\") \
362 (notmuch-show-next-message) \
363 (command-execute (key-binding (kbd \"RET\"))) \
364 (test-visible-output)"
365 test_emacs "(notmuch-show \"id:$id\") \
366 (notmuch-show-next-message) \
367 (notmuch-show-toggle-message) \
368 (test-visible-output \"EXPECTED\")"
369 test_expect_equal_file OUTPUT EXPECTED
371 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
372 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
373 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
374 test_emacs "(notmuch-search \"$message1 or $message2\")
376 (notmuch-search-show-thread)
377 (goto-char (point-max))
379 (notmuch-show-advance-and-archive)
381 test_emacs "(notmuch-show \"$message2\")
382 (test-output \"EXPECTED\")"
383 test_expect_equal_file OUTPUT EXPECTED
385 test_begin_subtest "Refresh show buffer"
386 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
387 (test-visible-output "EXPECTED")
388 (notmuch-show-refresh-view)
389 (test-visible-output)'
390 test_expect_equal_file OUTPUT EXPECTED
392 test_begin_subtest "Refresh modified show buffer"
393 test_subtest_known_broken
394 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
395 (notmuch-show-toggle-message)
396 (notmuch-show-next-message)
397 (notmuch-show-toggle-message)
398 (test-visible-output "EXPECTED")
399 (notmuch-show-refresh-view)
400 (test-visible-output)'
401 test_expect_equal_file OUTPUT EXPECTED