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)
11 (princ (buffer-string))' >OUTPUT
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")))
21 (princ (buffer-string))' >OUTPUT
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")))
28 (princ (buffer-string))' >OUTPUT
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")
34 (princ (buffer-string))' >OUTPUT
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))
43 (princ (buffer-string))' >OUTPUT
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\")
49 (princ (buffer-string))" >OUTPUT
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 output=$(test_emacs "(notmuch-show \"$thread\") (princ (buffer-string))")
57 test_expect_equal "$output" \
58 '"Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
59 Subject: message-with-invalid-from
60 To: Notmuch Test Suite <test_suite@notmuchmail.org>
61 Date: Tue, 05 Jan 2001 15:43:57 -0000
63 This is just a test message (#1)'
65 test_begin_subtest "Navigation of notmuch-search to thread view"
66 test_emacs '(notmuch-search "tag:inbox")
68 (goto-char (point-min))
69 (re-search-forward "Working with Maildir")
70 (notmuch-search-show-thread)
72 (princ (buffer-string))' >OUTPUT
73 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
75 test_begin_subtest "Add tag from search view"
76 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
77 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
79 (notmuch-search-add-tag \"tag-from-search-view\")"
80 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
81 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)"
83 test_begin_subtest "Remove tag from search view"
84 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
86 (notmuch-search-remove-tag \"tag-from-search-view\")"
87 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
88 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)"
90 test_begin_subtest "Add tag from notmuch-show view"
91 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
92 (notmuch-show-add-tag \"tag-from-show-view\")"
93 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
94 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)"
96 test_begin_subtest "Remove tag from notmuch-show view"
97 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
98 (notmuch-show-remove-tag \"tag-from-show-view\")"
99 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
100 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)"
102 test_begin_subtest "Message with .. in Message-Id:"
103 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
104 test_emacs '(notmuch-search "id:\"123..456@example\"")
106 (notmuch-search-add-tag "search-add")
107 (notmuch-search-add-tag "search-remove")
108 (notmuch-search-remove-tag "search-remove")
109 (notmuch-show "id:\"123..456@example\"")
111 (notmuch-show-add-tag "show-add")
112 (notmuch-show-add-tag "show-remove")
113 (notmuch-show-remove-tag "show-remove")'
114 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
115 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
117 test_begin_subtest "Sending a message via (fake) SMTP"
119 # Before we can send a message, we have to prepare the FCC maildir
120 mkdir -p mail/sent/cur
121 mkdir -p mail/sent/new
122 mkdir -p mail/sent/tmp
124 ../smtp-dummy sent_message &
126 test_emacs "(setq message-send-mail-function 'message-smtpmail-send-it)
127 (setq smtpmail-smtp-server \"localhost\")
128 (setq smtpmail-smtp-service \"25025\")
132 (insert \"user@example.com\nDate: Fri, 29 Mar 1974 10:00:00 -0000\")
133 (message-goto-subject)
134 (insert \"Testing message sent via SMTP\")
136 (insert \"This is a test that messages are sent via SMTP\")
137 (message-send-and-exit)" >/dev/null 2>&1
138 wait ${smtp_dummy_pid}
141 -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
142 -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
144 From: Notmuch Test Suite <test_suite@notmuchmail.org>
146 Subject: Testing message sent via SMTP
147 Date: Fri, 29 Mar 1974 10:00:00 -0000
148 User-Agent: Notmuch/XXX Emacs/XXX
151 Content-Type: text/plain; charset=us-ascii
153 This is a test that messages are sent via SMTP
155 test_expect_equal_file OUTPUT EXPECTED
157 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
158 notmuch new > /dev/null
159 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
160 test_expect_equal "$output" "thread:XXX 1974-03-29 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
162 test_begin_subtest "notmuch-fcc-dirs set to nil"
163 test_emacs "(setq notmuch-fcc-dirs nil)
165 (princ (buffer-string))" > OUTPUT
167 From: Notmuch Test Suite <test_suite@notmuchmail.org>
170 --text follows this line--
172 test_expect_equal_file OUTPUT EXPECTED
174 # Make another FCC maildir specific for the next test
175 mkdir -p mail/sent-string/cur
176 mkdir -p mail/sent-string/new
177 mkdir -p mail/sent-string/tmp
179 test_begin_subtest "notmuch-fcc-dirs set to a string"
180 test_emacs "(setq notmuch-fcc-dirs \"sent-string\")
182 (princ (buffer-string))" > OUTPUT
184 From: Notmuch Test Suite <test_suite@notmuchmail.org>
187 Fcc: ${MAIL_DIR}/sent-string
188 --text follows this line--
190 test_expect_equal_file OUTPUT EXPECTED
192 # Make more FCC maildirs specific for the next test
193 mkdir -p mail/sent-list-match/cur
194 mkdir -p mail/sent-list-match/new
195 mkdir -p mail/sent-list-match/tmp
196 mkdir -p mail/failure/cur
197 mkdir -p mail/failure/new
198 mkdir -p mail/failure/tmp
200 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
201 test_emacs "(setq notmuch-fcc-dirs
202 '((\"notmuchmail.org\" . \"sent-list-match\")
203 (\".*\" . \"failure\")))
205 (princ (buffer-string))" > OUTPUT
207 From: Notmuch Test Suite <test_suite@notmuchmail.org>
210 Fcc: ${MAIL_DIR}/sent-list-match
211 --text follows this line--
213 test_expect_equal_file OUTPUT EXPECTED
215 # Make another FCC maildir specific for the next test
216 mkdir -p mail/sent-list-catch-all/cur
217 mkdir -p mail/sent-list-catch-all/new
218 mkdir -p mail/sent-list-catch-all/tmp
220 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
221 test_emacs "(setq notmuch-fcc-dirs
222 '((\"example.com\" . \"failure\")
223 (\".*\" . \"sent-list-catch-all\")))
225 (princ (buffer-string))" > OUTPUT
227 From: Notmuch Test Suite <test_suite@notmuchmail.org>
230 Fcc: ${MAIL_DIR}/sent-list-catch-all
231 --text follows this line--
233 test_expect_equal_file OUTPUT EXPECTED
235 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
236 test_emacs "(setq notmuch-fcc-dirs
237 '((\"example.com\" . \"failure\")
238 (\"nomatchhere.net\" . \"failure\")))
240 (princ (buffer-string))" > OUTPUT
242 From: Notmuch Test Suite <test_suite@notmuchmail.org>
245 --text follows this line--
247 test_expect_equal_file OUTPUT EXPECTED
249 test_begin_subtest "Reply within emacs"
250 # We sed away everything before the ^From in the output to avoid getting
251 # confused by messages such as "Parsing /home/cworth/.mailrc... done"
252 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
254 (notmuch-search-reply-to-thread)
255 (princ (buffer-string))' |
256 sed -ne '/^From/,$ p' |
257 sed -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 first_line=$(head -n1 $EXPECTED/raw-message-cf0c4d-52ad0a)
285 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
286 (notmuch-show-view-raw-message)
287 (princ (buffer-string))' |
288 sed -ne "/$first_line/,\$ p" >OUTPUT
289 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
291 test_begin_subtest "Hiding/showing signature in notmuch-show view"
292 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
293 test_emacs "(notmuch-show \"$maildir_storage_thread\")
294 (search-forward \"Click/Enter to show.\")
295 (button-activate (button-at (point)))
296 (search-backward \"Click/Enter to hide.\")
297 (button-activate (button-at (point)))
298 (princ (buffer-string))" >OUTPUT
299 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
301 test_begin_subtest "Detection and hiding of top-post quoting of message"
302 add_message '[subject]="The problem with top-posting"' \
303 [id]=top-post-target \
304 '[body]="A: Because it messes up the order in which people normally read text.
305 Q: Why is top-posting such a bad thing?
307 Q: What is the most annoying thing in e-mail?"'
308 add_message '[from]="Top Poster <top@poster.com>"' \
309 [in-reply-to]=top-post-target \
310 [references]=top-post-target \
311 '[subject]="Re: The problem with top-posting"' \
312 '[body]="Thanks for the advice! I will be sure to put it to good use.
316 ----- Original Message -----
317 From: Notmuch Test Suite <test_suite@notmuchmail.org>
318 To: Notmuch Test Suite <test_suite@notmuchmai.org>
319 Sent: Tue, 05 Jan 2001 15:43:57 -0000
320 Subject: The problem with top-posting
322 Q: Why is top-posting such a bad thing?
324 Q: What is the most annoying thing in e-mail?"'
325 test_emacs "(notmuch-show \"top-posting\")
326 (princ (visible-buffer-string))" >OUTPUT
327 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
328 Subject: The problem with top-posting
329 To: Notmuch Test Suite <test_suite@notmuchmail.org>
330 Date: Tue, 05 Jan 2001 15:43:57 -0000
332 A: Because it messes up the order in which people normally read text.
333 Q: Why is top-posting such a bad thing?
335 Q: What is the most annoying thing in e-mail?
336 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
337 Subject: Re: The problem with top-posting
338 To: Notmuch Test Suite <test_suite@notmuchmail.org>
339 Date: Tue, 05 Jan 2001 15:43:57 -0000
341 Thanks for the advice! I will be sure to put it to good use.
345 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
346 test_expect_equal_file OUTPUT EXPECTED
348 test_begin_subtest "Hiding message in notmuch-show view"
349 output=$(test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
350 (notmuch-show-toggle-message)
351 (princ (visible-buffer-string))')
352 expected=$(cat $EXPECTED/notmuch-show-thread-with-hidden-messages)
353 test_expect_equal "$output" "$expected"
355 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
356 output=$(test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
357 (search-forward "Click/Enter to show.")
358 (button-activate (button-at (point)))
359 (notmuch-show-toggle-message)
360 (princ (visible-buffer-string))')
361 expected=$(cat $EXPECTED/notmuch-show-thread-with-hidden-messages)
362 test_expect_equal "$output" "$expected"