3 # Note: do not use `setq' for setting variables in Emacs tests because
4 # it affects other tests that may run in the same Emacs instance. Use
5 # `let' instead so the scope of the changed variables is limited to a
8 test_description="emacs interface"
11 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
15 test_begin_subtest "Basic notmuch-hello view in emacs"
16 test_emacs '(notmuch-hello)
18 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
20 test_begin_subtest "Saved search with 0 results"
21 test_emacs '(let ((notmuch-show-empty-saved-searches t)
22 (notmuch-saved-searches
23 '\''(("inbox" . "tag:inbox")
24 ("unread" . "tag:unread")
25 ("empty" . "tag:doesnotexist"))))
28 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
30 test_begin_subtest "No saved searches displayed (all with 0 results)"
31 test_emacs '(let ((notmuch-saved-searches
32 '\''(("empty" . "tag:doesnotexist"))))
35 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
37 test_begin_subtest "Basic notmuch-search view in emacs"
38 test_emacs '(notmuch-search "tag:inbox")
41 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
43 test_begin_subtest "Navigation of notmuch-hello to search results"
44 test_emacs '(notmuch-hello)
45 (goto-char (point-min))
46 (re-search-forward "inbox")
47 (widget-button-press (point))
50 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
52 test_begin_subtest "Basic notmuch-show view in emacs"
53 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
54 test_emacs "(notmuch-show \"$maildir_storage_thread\")
56 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
58 test_begin_subtest "notmuch-show for message with invalid From"
59 add_message "[subject]=\"message-with-invalid-from\"" \
60 "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
61 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
62 test_emacs "(notmuch-show \"$thread\")
65 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
66 Subject: message-with-invalid-from
67 To: Notmuch Test Suite <test_suite@notmuchmail.org>
68 Date: Tue, 05 Jan 2001 15:43:57 -0000
70 This is just a test message (#1)
72 test_expect_equal_file OUTPUT EXPECTED
74 test_begin_subtest "Navigation of notmuch-search to thread view"
75 test_emacs '(notmuch-search "tag:inbox")
77 (goto-char (point-min))
78 (re-search-forward "Working with Maildir")
79 (notmuch-search-show-thread)
82 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
84 test_begin_subtest "Add tag from search view"
85 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
86 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
88 (notmuch-search-add-tag \"tag-from-search-view\")"
89 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
90 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)"
92 test_begin_subtest "Remove tag from search view"
93 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
95 (notmuch-search-remove-tag \"tag-from-search-view\")"
96 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
97 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)"
99 test_begin_subtest "Add tag from notmuch-show view"
100 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
101 (notmuch-show-add-tag \"tag-from-show-view\")"
102 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
103 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)"
105 test_begin_subtest "Remove tag from notmuch-show view"
106 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
107 (notmuch-show-remove-tag \"tag-from-show-view\")"
108 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
109 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)"
111 test_begin_subtest "Message with .. in Message-Id:"
112 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
113 test_emacs '(notmuch-search "id:\"123..456@example\"")
115 (notmuch-search-add-tag "search-add")
116 (notmuch-search-add-tag "search-remove")
117 (notmuch-search-remove-tag "search-remove")
118 (notmuch-show "id:\"123..456@example\"")
120 (notmuch-show-add-tag "show-add")
121 (notmuch-show-add-tag "show-remove")
122 (notmuch-show-remove-tag "show-remove")'
123 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
124 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
126 test_begin_subtest "Sending a message via (fake) SMTP"
127 emacs_deliver_message \
128 'Testing message sent via SMTP' \
129 'This is a test that messages are sent via SMTP' \
132 (insert "To: user@example.com\n")'
134 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
135 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
137 From: Notmuch Test Suite <test_suite@notmuchmail.org>
139 Subject: Testing message sent via SMTP
140 Date: 01 Jan 2000 12:00:00 -0000
141 User-Agent: Notmuch/XXX Emacs/XXX
144 Content-Type: text/plain; charset=us-ascii
146 This is a test that messages are sent via SMTP
148 test_expect_equal_file OUTPUT EXPECTED
150 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
151 notmuch new > /dev/null
152 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
153 test_expect_equal "$output" "thread:XXX 2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
155 test_begin_subtest "notmuch-fcc-dirs set to nil"
156 test_emacs "(let ((notmuch-fcc-dirs nil))
160 From: Notmuch Test Suite <test_suite@notmuchmail.org>
163 --text follows this line--
165 test_expect_equal_file OUTPUT EXPECTED
167 # Make another FCC maildir specific for the next test
168 mkdir -p mail/sent-string/cur
169 mkdir -p mail/sent-string/new
170 mkdir -p mail/sent-string/tmp
172 test_begin_subtest "notmuch-fcc-dirs set to a string"
173 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
177 From: Notmuch Test Suite <test_suite@notmuchmail.org>
180 Fcc: ${MAIL_DIR}/sent-string
181 --text follows this line--
183 test_expect_equal_file OUTPUT EXPECTED
185 # Make more FCC maildirs specific for the next test
186 mkdir -p mail/sent-list-match/cur
187 mkdir -p mail/sent-list-match/new
188 mkdir -p mail/sent-list-match/tmp
189 mkdir -p mail/failure/cur
190 mkdir -p mail/failure/new
191 mkdir -p mail/failure/tmp
193 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
194 test_emacs "(let ((notmuch-fcc-dirs
195 '((\"notmuchmail.org\" . \"sent-list-match\")
196 (\".*\" . \"failure\"))))
200 From: Notmuch Test Suite <test_suite@notmuchmail.org>
203 Fcc: ${MAIL_DIR}/sent-list-match
204 --text follows this line--
206 test_expect_equal_file OUTPUT EXPECTED
208 # Make another FCC maildir specific for the next test
209 mkdir -p mail/sent-list-catch-all/cur
210 mkdir -p mail/sent-list-catch-all/new
211 mkdir -p mail/sent-list-catch-all/tmp
213 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
214 test_emacs "(let ((notmuch-fcc-dirs
215 '((\"example.com\" . \"failure\")
216 (\".*\" . \"sent-list-catch-all\"))))
220 From: Notmuch Test Suite <test_suite@notmuchmail.org>
223 Fcc: ${MAIL_DIR}/sent-list-catch-all
224 --text follows this line--
226 test_expect_equal_file OUTPUT EXPECTED
228 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
229 test_emacs "(let ((notmuch-fcc-dirs
230 '((\"example.com\" . \"failure\")
231 (\"nomatchhere.net\" . \"failure\"))))
235 From: Notmuch Test Suite <test_suite@notmuchmail.org>
238 --text follows this line--
240 test_expect_equal_file OUTPUT EXPECTED
242 test_begin_subtest "Reply within emacs"
243 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
245 (notmuch-search-reply-to-thread)
247 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
249 From: Notmuch Test Suite <test_suite@notmuchmail.org>
251 Subject: Re: Testing message sent via SMTP
253 Fcc: $(pwd)/mail/sent
254 --text follows this line--
255 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
256 > This is a test that messages are sent via SMTP
258 test_expect_equal_file OUTPUT EXPECTED
260 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
261 # save as archive to test that Emacs does not re-compress .gz
262 test_emacs '(let ((standard-input "\"attachment1.gz\""))
263 (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
264 (notmuch-show-save-attachments))' > /dev/null 2>&1
265 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
267 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
268 # save as archive to test that Emacs does not re-compress .gz
269 test_emacs '(let ((standard-input "\"attachment2.gz\""))
270 (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))' > /dev/null 2>&1
271 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
273 test_begin_subtest "View raw message within emacs"
274 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
275 (notmuch-show-view-raw-message)
277 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
279 test_begin_subtest "Hiding/showing signature in notmuch-show view"
280 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
281 test_emacs "(notmuch-show \"$maildir_storage_thread\")
282 (search-forward \"Click/Enter to show.\")
283 (button-activate (button-at (point)))
284 (search-backward \"Click/Enter to hide.\")
285 (button-activate (button-at (point)))
287 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
289 test_begin_subtest "Detection and hiding of top-post quoting of message"
290 add_message '[subject]="The problem with top-posting"' \
291 [id]=top-post-target \
292 '[body]="A: Because it messes up the order in which people normally read text.
293 Q: Why is top-posting such a bad thing?
295 Q: What is the most annoying thing in e-mail?"'
296 add_message '[from]="Top Poster <top@poster.com>"' \
297 [in-reply-to]=top-post-target \
298 [references]=top-post-target \
299 '[subject]="Re: The problem with top-posting"' \
300 '[body]="Thanks for the advice! I will be sure to put it to good use.
304 ----- Original Message -----
305 From: Notmuch Test Suite <test_suite@notmuchmail.org>
306 To: Notmuch Test Suite <test_suite@notmuchmai.org>
307 Sent: Tue, 05 Jan 2001 15:43:57 -0000
308 Subject: The problem with top-posting
310 Q: Why is top-posting such a bad thing?
312 Q: What is the most annoying thing in e-mail?"'
313 test_emacs "(notmuch-show \"top-posting\")
314 (test-visible-output)"
315 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
316 Subject: The problem with top-posting
317 To: Notmuch Test Suite <test_suite@notmuchmail.org>
318 Date: Tue, 05 Jan 2001 15:43:57 -0000
320 A: Because it messes up the order in which people normally read text.
321 Q: Why is top-posting such a bad thing?
323 Q: What is the most annoying thing in e-mail?
324 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
325 Subject: Re: 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 Thanks for the advice! I will be sure to put it to good use.
333 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
334 test_expect_equal_file OUTPUT EXPECTED
336 test_begin_subtest "Hiding message in notmuch-show view"
337 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
338 (notmuch-show-toggle-message)
339 (test-visible-output)'
340 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
342 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
343 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
344 (search-forward "Click/Enter to show.")
345 (button-activate (button-at (point)))
346 (notmuch-show-toggle-message)
347 (test-visible-output)'
348 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages