2 test_description="emacs interface"
5 EXPECTED=../emacs.expected-output
9 test_begin_subtest "Basic notmuch-hello view in emacs"
10 test_emacs '(notmuch-hello)
12 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
14 test_begin_subtest "Saved search with 0 results"
15 test_emacs '(setq notmuch-show-empty-saved-searches t)
16 (setq notmuch-saved-searches
17 '\''(("inbox" . "tag:inbox")
18 ("unread" . "tag:unread")
19 ("empty" . "tag:doesnotexist")))
22 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
24 test_begin_subtest "No saved searches displayed (all with 0 results)"
25 test_emacs '(setq notmuch-saved-searches
26 '\''(("empty" . "tag:doesnotexist")))
29 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
31 test_begin_subtest "Basic notmuch-search view in emacs"
32 test_emacs '(notmuch-search "tag:inbox")
35 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
37 test_begin_subtest "Navigation of notmuch-hello to search results"
38 test_emacs '(notmuch-hello)
39 (goto-char (point-min))
40 (re-search-forward "inbox")
41 (widget-button-press (point))
44 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
46 test_begin_subtest "Basic notmuch-show view in emacs"
47 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
48 test_emacs "(notmuch-show \"$maildir_storage_thread\")
50 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
52 test_begin_subtest "notmuch-show for message with invalid From"
53 add_message "[subject]=\"message-with-invalid-from\"" \
54 "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
55 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
56 test_emacs "(notmuch-show \"$thread\")
59 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
60 Subject: message-with-invalid-from
61 To: Notmuch Test Suite <test_suite@notmuchmail.org>
62 Date: Tue, 05 Jan 2001 15:43:57 -0000
64 This is just a test message (#1)
66 test_expect_equal_file OUTPUT EXPECTED
68 test_begin_subtest "Navigation of notmuch-search to thread view"
69 test_emacs '(notmuch-search "tag:inbox")
71 (goto-char (point-min))
72 (re-search-forward "Working with Maildir")
73 (notmuch-search-show-thread)
76 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
78 test_begin_subtest "Add tag from search view"
79 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
80 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
82 (notmuch-search-add-tag \"tag-from-search-view\")"
83 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
84 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)"
86 test_begin_subtest "Remove tag from search view"
87 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
89 (notmuch-search-remove-tag \"tag-from-search-view\")"
90 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
91 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)"
93 test_begin_subtest "Add tag from notmuch-show view"
94 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
95 (notmuch-show-add-tag \"tag-from-show-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 tag-from-show-view unread)"
99 test_begin_subtest "Remove tag from notmuch-show view"
100 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
101 (notmuch-show-remove-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 unread)"
105 test_begin_subtest "Message with .. in Message-Id:"
106 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
107 test_emacs '(notmuch-search "id:\"123..456@example\"")
109 (notmuch-search-add-tag "search-add")
110 (notmuch-search-add-tag "search-remove")
111 (notmuch-search-remove-tag "search-remove")
112 (notmuch-show "id:\"123..456@example\"")
114 (notmuch-show-add-tag "show-add")
115 (notmuch-show-add-tag "show-remove")
116 (notmuch-show-remove-tag "show-remove")'
117 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
118 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
120 test_begin_subtest "Sending a message via (fake) SMTP"
122 # Before we can send a message, we have to prepare the FCC maildir
123 mkdir -p mail/sent/cur
124 mkdir -p mail/sent/new
125 mkdir -p mail/sent/tmp
127 ../smtp-dummy sent_message &
129 test_emacs "(setq message-send-mail-function 'message-smtpmail-send-it)
130 (setq smtpmail-smtp-server \"localhost\")
131 (setq smtpmail-smtp-service \"25025\")
135 (insert \"user@example.com\nDate: Fri, 29 Mar 1974 10:00:00 -0000\")
136 (message-goto-subject)
137 (insert \"Testing message sent via SMTP\")
139 (insert \"This is a test that messages are sent via SMTP\")
140 (message-send-and-exit)" >/dev/null 2>&1
141 wait ${smtp_dummy_pid}
144 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
145 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
147 From: Notmuch Test Suite <test_suite@notmuchmail.org>
149 Subject: Testing message sent via SMTP
150 Date: Fri, 29 Mar 1974 10:00:00 -0000
151 User-Agent: Notmuch/XXX Emacs/XXX
154 Content-Type: text/plain; charset=us-ascii
156 This is a test that messages are sent via SMTP
158 test_expect_equal_file OUTPUT EXPECTED
160 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
161 notmuch new > /dev/null
162 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
163 test_expect_equal "$output" "thread:XXX 1974-03-29 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
165 test_begin_subtest "notmuch-fcc-dirs set to nil"
166 test_emacs "(setq notmuch-fcc-dirs nil)
170 From: Notmuch Test Suite <test_suite@notmuchmail.org>
173 --text follows this line--
175 test_expect_equal_file OUTPUT EXPECTED
177 # Make another FCC maildir specific for the next test
178 mkdir -p mail/sent-string/cur
179 mkdir -p mail/sent-string/new
180 mkdir -p mail/sent-string/tmp
182 test_begin_subtest "notmuch-fcc-dirs set to a string"
183 test_emacs "(setq notmuch-fcc-dirs \"sent-string\")
187 From: Notmuch Test Suite <test_suite@notmuchmail.org>
190 Fcc: ${MAIL_DIR}/sent-string
191 --text follows this line--
193 test_expect_equal_file OUTPUT EXPECTED
195 # Make more FCC maildirs specific for the next test
196 mkdir -p mail/sent-list-match/cur
197 mkdir -p mail/sent-list-match/new
198 mkdir -p mail/sent-list-match/tmp
199 mkdir -p mail/failure/cur
200 mkdir -p mail/failure/new
201 mkdir -p mail/failure/tmp
203 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
204 test_emacs "(setq notmuch-fcc-dirs
205 '((\"notmuchmail.org\" . \"sent-list-match\")
206 (\".*\" . \"failure\")))
210 From: Notmuch Test Suite <test_suite@notmuchmail.org>
213 Fcc: ${MAIL_DIR}/sent-list-match
214 --text follows this line--
216 test_expect_equal_file OUTPUT EXPECTED
218 # Make another FCC maildir specific for the next test
219 mkdir -p mail/sent-list-catch-all/cur
220 mkdir -p mail/sent-list-catch-all/new
221 mkdir -p mail/sent-list-catch-all/tmp
223 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
224 test_emacs "(setq notmuch-fcc-dirs
225 '((\"example.com\" . \"failure\")
226 (\".*\" . \"sent-list-catch-all\")))
230 From: Notmuch Test Suite <test_suite@notmuchmail.org>
233 Fcc: ${MAIL_DIR}/sent-list-catch-all
234 --text follows this line--
236 test_expect_equal_file OUTPUT EXPECTED
238 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
239 test_emacs "(setq notmuch-fcc-dirs
240 '((\"example.com\" . \"failure\")
241 (\"nomatchhere.net\" . \"failure\")))
245 From: Notmuch Test Suite <test_suite@notmuchmail.org>
248 --text follows this line--
250 test_expect_equal_file OUTPUT EXPECTED
252 test_begin_subtest "Reply within emacs"
253 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
255 (notmuch-search-reply-to-thread)
257 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
259 From: Notmuch Test Suite <test_suite@notmuchmail.org>
261 Subject: Re: Testing message sent via SMTP
263 Fcc: $(pwd)/mail/sent
264 --text follows this line--
265 On Fri, 29 Mar 1974 10:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
266 > This is a test that messages are sent via SMTP
268 test_expect_equal_file OUTPUT EXPECTED
270 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
271 # save as archive to test that Emacs does not re-compress .gz
272 echo ./attachment1.gz |
273 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
274 (notmuch-show-save-attachments)' > /dev/null 2>&1
275 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
277 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
278 # save as archive to test that Emacs does not re-compress .gz
279 echo ./attachment2.gz |
280 test_emacs '(notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5)' > /dev/null 2>&1
281 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
283 test_begin_subtest "View raw message within emacs"
284 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
285 (notmuch-show-view-raw-message)
287 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
289 test_begin_subtest "Hiding/showing signature in notmuch-show view"
290 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
291 test_emacs "(notmuch-show \"$maildir_storage_thread\")
292 (search-forward \"Click/Enter to show.\")
293 (button-activate (button-at (point)))
294 (search-backward \"Click/Enter to hide.\")
295 (button-activate (button-at (point)))
297 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
299 test_begin_subtest "Detection and hiding of top-post quoting of message"
300 add_message '[subject]="The problem with top-posting"' \
301 [id]=top-post-target \
302 '[body]="A: Because it messes up the order in which people normally read text.
303 Q: Why is top-posting such a bad thing?
305 Q: What is the most annoying thing in e-mail?"'
306 add_message '[from]="Top Poster <top@poster.com>"' \
307 [in-reply-to]=top-post-target \
308 [references]=top-post-target \
309 '[subject]="Re: The problem with top-posting"' \
310 '[body]="Thanks for the advice! I will be sure to put it to good use.
314 ----- Original Message -----
315 From: Notmuch Test Suite <test_suite@notmuchmail.org>
316 To: Notmuch Test Suite <test_suite@notmuchmai.org>
317 Sent: Tue, 05 Jan 2001 15:43:57 -0000
318 Subject: The problem with top-posting
320 Q: Why is top-posting such a bad thing?
322 Q: What is the most annoying thing in e-mail?"'
323 test_emacs "(notmuch-show \"top-posting\")
324 (test-visible-output)"
325 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
326 Subject: The problem with top-posting
327 To: Notmuch Test Suite <test_suite@notmuchmail.org>
328 Date: Tue, 05 Jan 2001 15:43:57 -0000
330 A: Because it messes up the order in which people normally read text.
331 Q: Why is top-posting such a bad thing?
333 Q: What is the most annoying thing in e-mail?
334 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
335 Subject: Re: The problem with top-posting
336 To: Notmuch Test Suite <test_suite@notmuchmail.org>
337 Date: Tue, 05 Jan 2001 15:43:57 -0000
339 Thanks for the advice! I will be sure to put it to good use.
343 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
344 test_expect_equal_file OUTPUT EXPECTED
346 test_begin_subtest "Hiding message in notmuch-show view"
347 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
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 "Hiding message with visible citation in notmuch-show view"
353 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
354 (search-forward "Click/Enter to show.")
355 (button-activate (button-at (point)))
356 (notmuch-show-toggle-message)
357 (test-visible-output)'
358 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages