]> git.notmuchmail.org Git - notmuch/blob - test/emacs
emacs: test: notmuch show without indentation
[notmuch] / test / emacs
1 #!/usr/bin/env bash
2
3 test_description="emacs interface"
4 . test-lib.sh
5
6 EXPECTED=$TEST_DIRECTORY/emacs.expected-output
7
8 add_email_corpus
9
10 test_begin_subtest "Basic notmuch-hello view in emacs"
11 test_emacs '(notmuch-hello)
12             (test-output)'
13 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello
14
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"))))
21               (notmuch-hello)
22               (test-output))'
23 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-with-empty
24
25 test_begin_subtest "No saved searches displayed (all with 0 results)"
26 test_emacs '(let ((notmuch-saved-searches
27                    '\''(("empty" . "tag:doesnotexist"))))
28               (notmuch-hello)
29               (test-output))'
30 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-no-saved-searches
31
32 test_begin_subtest "Basic notmuch-search view in emacs"
33 test_emacs '(notmuch-search "tag:inbox")
34             (notmuch-test-wait)
35             (test-output)'
36 test_expect_equal_file OUTPUT $EXPECTED/notmuch-search-tag-inbox
37
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))
43             (notmuch-test-wait)
44             (test-output)'
45 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
46
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\")
50             (test-output)"
51 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
52
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\")
57               (test-output))"
58 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
59
60 test_begin_subtest "Basic notmuch-show view in emacs without indentation"
61 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
62 test_emacs "(let ((notmuch-indent-messages-width 0))
63               (notmuch-show \"$maildir_storage_thread\")
64               (test-output))"
65 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage-without-indentation
66
67 test_begin_subtest "notmuch-show for message with invalid From"
68 add_message "[subject]=\"message-with-invalid-from\"" \
69             "[from]=\"\\\"Invalid \\\" From\\\" <test_suite@notmuchmail.org>\""
70 thread=$(notmuch search --output=threads subject:message-with-invalid-from)
71 test_emacs "(notmuch-show \"$thread\")
72             (test-output)"
73 cat <<EOF >EXPECTED
74 "Invalid " From" <test_suite@notmuchmail.org> (2001-01-05) (inbox)
75 Subject: message-with-invalid-from
76 To: Notmuch Test Suite <test_suite@notmuchmail.org>
77 Date: Tue, 05 Jan 2001 15:43:57 -0000
78
79 This is just a test message (#1)
80 EOF
81 test_expect_equal_file OUTPUT EXPECTED
82
83 test_begin_subtest "Navigation of notmuch-search to thread view"
84 test_emacs '(notmuch-search "tag:inbox")
85             (notmuch-test-wait)
86             (goto-char (point-min))
87             (re-search-forward "Working with Maildir")
88             (notmuch-search-show-thread)
89             (notmuch-test-wait)
90             (test-output)'
91 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
92
93 test_begin_subtest "Add tag from search view"
94 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
95 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
96             (notmuch-test-wait)
97             (notmuch-search-add-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 tag-from-search-view unread)"
100
101 test_begin_subtest "Remove tag from search view"
102 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
103             (notmuch-test-wait)
104             (notmuch-search-remove-tag \"tag-from-search-view\")"
105 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
106 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)"
107
108 test_begin_subtest "Add tag from notmuch-show view"
109 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
110             (notmuch-show-add-tag \"tag-from-show-view\")"
111 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
112 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)"
113
114 test_begin_subtest "Remove tag from notmuch-show view"
115 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
116             (notmuch-show-remove-tag \"tag-from-show-view\")"
117 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
118 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)"
119
120 test_begin_subtest "Message with .. in Message-Id:"
121 add_message [id]=123..456@example '[subject]="Message with .. in Message-Id"'
122 test_emacs '(notmuch-search "id:\"123..456@example\"")
123             (notmuch-test-wait)
124             (notmuch-search-add-tag "search-add")
125             (notmuch-search-add-tag "search-remove")
126             (notmuch-search-remove-tag "search-remove")
127             (notmuch-show "id:\"123..456@example\"")
128             (notmuch-test-wait)
129             (notmuch-show-add-tag "show-add")
130             (notmuch-show-add-tag "show-remove")
131             (notmuch-show-remove-tag "show-remove")'
132 output=$(notmuch search 'id:"123..456@example"' | notmuch_search_sanitize)
133 test_expect_equal "$output" "thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Message with .. in Message-Id (inbox search-add show-add)"
134
135 test_begin_subtest "Sending a message via (fake) SMTP"
136 emacs_deliver_message \
137     'Testing message sent via SMTP' \
138     'This is a test that messages are sent via SMTP' \
139     '(message-goto-to)
140      (kill-whole-line)
141      (insert "To: user@example.com\n")'
142 sed \
143     -e s',^User-Agent: Notmuch/.* Emacs/.*,User-Agent: Notmuch/XXX Emacs/XXX,' \
144     -e s',^Message-ID: <.*>$,Message-ID: <XXX>,' < sent_message >OUTPUT
145 cat <<EOF >EXPECTED
146 From: Notmuch Test Suite <test_suite@notmuchmail.org>
147 To: user@example.com
148 Subject: Testing message sent via SMTP
149 Date: 01 Jan 2000 12:00:00 -0000
150 User-Agent: Notmuch/XXX Emacs/XXX
151 Message-ID: <XXX>
152 MIME-Version: 1.0
153 Content-Type: text/plain; charset=us-ascii
154
155 This is a test that messages are sent via SMTP
156 EOF
157 test_expect_equal_file OUTPUT EXPECTED
158
159 test_begin_subtest "Verify that sent messages are saved/searchable (via FCC)"
160 notmuch new > /dev/null
161 output=$(notmuch search 'subject:"testing message sent via SMTP"' | notmuch_search_sanitize)
162 test_expect_equal "$output" "thread:XXX   2000-01-01 [1/1] Notmuch Test Suite; Testing message sent via SMTP (inbox)"
163
164 test_begin_subtest "notmuch-fcc-dirs set to nil"
165 test_emacs "(let ((notmuch-fcc-dirs nil))
166               (notmuch-mua-mail)
167               (test-output))"
168 cat <<EOF >EXPECTED
169 From: Notmuch Test Suite <test_suite@notmuchmail.org>
170 To: 
171 Subject: 
172 --text follows this line--
173 EOF
174 test_expect_equal_file OUTPUT EXPECTED
175
176 # Make another FCC maildir specific for the next test
177 mkdir -p mail/sent-string/cur
178 mkdir -p mail/sent-string/new
179 mkdir -p mail/sent-string/tmp
180
181 test_begin_subtest "notmuch-fcc-dirs set to a string"
182 test_emacs "(let ((notmuch-fcc-dirs \"sent-string\"))
183               (notmuch-mua-mail)
184               (test-output))"
185 cat <<EOF >EXPECTED
186 From: Notmuch Test Suite <test_suite@notmuchmail.org>
187 To: 
188 Subject: 
189 Fcc: ${MAIL_DIR}/sent-string
190 --text follows this line--
191 EOF
192 test_expect_equal_file OUTPUT EXPECTED
193
194 # Make more FCC maildirs specific for the next test
195 mkdir -p mail/sent-list-match/cur
196 mkdir -p mail/sent-list-match/new
197 mkdir -p mail/sent-list-match/tmp
198 mkdir -p mail/failure/cur
199 mkdir -p mail/failure/new
200 mkdir -p mail/failure/tmp
201
202 test_begin_subtest "notmuch-fcc-dirs set to a list (with match)"
203 test_emacs "(let ((notmuch-fcc-dirs
204                    '((\"notmuchmail.org\" . \"sent-list-match\")
205                      (\".*\" . \"failure\"))))
206               (notmuch-mua-mail)
207               (test-output))"
208 cat <<EOF >EXPECTED
209 From: Notmuch Test Suite <test_suite@notmuchmail.org>
210 To: 
211 Subject: 
212 Fcc: ${MAIL_DIR}/sent-list-match
213 --text follows this line--
214 EOF
215 test_expect_equal_file OUTPUT EXPECTED
216
217 # Make another FCC maildir specific for the next test
218 mkdir -p mail/sent-list-catch-all/cur
219 mkdir -p mail/sent-list-catch-all/new
220 mkdir -p mail/sent-list-catch-all/tmp
221  
222 test_begin_subtest "notmuch-fcc-dirs set to a list (catch-all)"
223 test_emacs "(let ((notmuch-fcc-dirs
224                    '((\"example.com\" . \"failure\")
225                      (\".*\" . \"sent-list-catch-all\"))))
226               (notmuch-mua-mail)
227               (test-output))"
228 cat <<EOF >EXPECTED
229 From: Notmuch Test Suite <test_suite@notmuchmail.org>
230 To: 
231 Subject: 
232 Fcc: ${MAIL_DIR}/sent-list-catch-all
233 --text follows this line--
234 EOF
235 test_expect_equal_file OUTPUT EXPECTED
236
237 test_begin_subtest "notmuch-fcc-dirs set to a list (no match)"
238 test_emacs "(let ((notmuch-fcc-dirs
239                    '((\"example.com\" . \"failure\")
240                      (\"nomatchhere.net\" . \"failure\"))))
241               (notmuch-mua-mail)
242               (test-output))"
243 cat <<EOF >EXPECTED
244 From: Notmuch Test Suite <test_suite@notmuchmail.org>
245 To: 
246 Subject: 
247 --text follows this line--
248 EOF
249 test_expect_equal_file OUTPUT EXPECTED
250
251 test_begin_subtest "Reply within emacs"
252 test_emacs '(notmuch-search "subject:\"testing message sent via SMTP\"")
253             (notmuch-test-wait)
254             (notmuch-search-reply-to-thread)
255             (test-output)'
256 sed -i -e 's/^In-Reply-To: <.*>$/In-Reply-To: <XXX>/' OUTPUT
257 cat <<EOF >EXPECTED
258 From: Notmuch Test Suite <test_suite@notmuchmail.org>
259 To: user@example.com
260 Subject: Re: Testing message sent via SMTP
261 In-Reply-To: <XXX>
262 Fcc: $(pwd)/mail/sent
263 --text follows this line--
264 On 01 Jan 2000 12:00:00 -0000, Notmuch Test Suite <test_suite@notmuchmail.org> wrote:
265 > This is a test that messages are sent via SMTP
266 EOF
267 test_expect_equal_file OUTPUT EXPECTED
268
269 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-attachments"
270 # save as archive to test that Emacs does not re-compress .gz
271 test_emacs '(let ((standard-input "\"attachment1.gz\""))
272               (notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
273               (notmuch-show-save-attachments))'
274 test_expect_equal_file attachment1.gz "$EXPECTED/attachment"
275
276 test_begin_subtest "Save attachment from within emacs using notmuch-show-save-part"
277 # save as archive to test that Emacs does not re-compress .gz
278 test_emacs '(let ((standard-input "\"attachment2.gz\""))
279               (notmuch-show-save-part "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com" 5))'
280 test_expect_equal_file attachment2.gz "$EXPECTED/attachment"
281
282 test_begin_subtest "View raw message within emacs"
283 test_emacs '(notmuch-show "id:cf0c4d610911171136h1713aa59w9cf9aa31f052ad0a@mail.gmail.com")
284             (notmuch-show-view-raw-message)
285             (test-output)'
286 test_expect_equal_file OUTPUT $EXPECTED/raw-message-cf0c4d-52ad0a
287
288 test_begin_subtest "Hiding/showing signature in notmuch-show view"
289 maildir_storage_thread=$(notmuch search --output=threads id:20091117190054.GU3165@dottiness.seas.harvard.edu)
290 test_emacs "(notmuch-show \"$maildir_storage_thread\")
291             (search-forward \"Click/Enter to show.\")
292             (button-activate (button-at (point)))
293             (search-backward \"Click/Enter to hide.\")
294             (button-activate (button-at (point)))
295             (test-output)"
296 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-maildir-storage
297
298 test_begin_subtest "Detection and hiding of top-post quoting of message"
299 add_message '[subject]="The problem with top-posting"' \
300             [id]=top-post-target \
301             '[body]="A: Because it messes up the order in which people normally read text.
302 Q: Why is top-posting such a bad thing?
303 A: Top-posting.
304 Q: What is the most annoying thing in e-mail?"'
305 add_message '[from]="Top Poster <top@poster.com>"' \
306             [in-reply-to]=top-post-target \
307             [references]=top-post-target \
308             '[subject]="Re: The problem with top-posting"' \
309             '[body]="Thanks for the advice! I will be sure to put it to good use.
310
311 -Top Poster
312
313 ----- Original Message -----
314 From: Notmuch Test Suite <test_suite@notmuchmail.org>
315 To: Notmuch Test Suite <test_suite@notmuchmai.org>
316 Sent: Tue, 05 Jan 2001 15:43:57 -0000
317 Subject: The problem with top-posting
318
319 Q: Why is top-posting such a bad thing?
320 A: Top-posting.
321 Q: What is the most annoying thing in e-mail?"'
322 test_emacs "(notmuch-show \"top-posting\")
323             (test-visible-output)"
324 echo "Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
325 Subject: The problem with top-posting
326 To: Notmuch Test Suite <test_suite@notmuchmail.org>
327 Date: Tue, 05 Jan 2001 15:43:57 -0000
328
329 A: Because it messes up the order in which people normally read text.
330 Q: Why is top-posting such a bad thing?
331 A: Top-posting.
332 Q: What is the most annoying thing in e-mail?
333 Top Poster <top@poster.com> (2001-01-05) (inbox unread)
334 Subject: Re: The problem with top-posting
335 To: Notmuch Test Suite <test_suite@notmuchmail.org>
336 Date: Tue, 05 Jan 2001 15:43:57 -0000
337
338 Thanks for the advice! I will be sure to put it to good use.
339
340 -Top Poster
341
342 [ 9-line hidden original message. Click/Enter to show. ]" > EXPECTED
343 test_expect_equal_file OUTPUT EXPECTED
344
345 test_begin_subtest "Hiding message in notmuch-show view"
346 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
347             (notmuch-show-toggle-message)
348             (test-visible-output)'
349 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
350
351 test_begin_subtest "Hiding message with visible citation in notmuch-show view"
352 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
353             (search-forward "Click/Enter to show.")
354             (button-activate (button-at (point)))
355             (notmuch-show-toggle-message)
356             (test-visible-output)'
357 test_expect_equal_file OUTPUT $EXPECTED/notmuch-show-thread-with-hidden-messages
358
359 test_begin_subtest "Stashing in notmuch-show"
360 add_message '[date]="Sat, 01 Jan 2000 12:00:00 -0000"' \
361     '[from]="Some One <someone@somewhere.org>"' \
362     '[to]="Some One Else <notsomeone@somewhere.org>"' \
363     '[cc]="Notmuch <notmuch@notmuchmail.org>"' \
364     '[subject]="Stash my stashables"' \
365     '[id]="bought"' \
366     '[body]="Unable to stash body. Where did you get it in the first place?!?"'
367 notmuch tag +stashtest id:${gen_msg_id}
368 test_emacs '(notmuch-show "id:\"bought\"")
369         (notmuch-show-stash-date)
370         (notmuch-show-stash-from)
371         (notmuch-show-stash-to)
372         (notmuch-show-stash-cc)
373         (notmuch-show-stash-subject)
374         (notmuch-show-stash-message-id)
375         (notmuch-show-stash-message-id-stripped)
376         (notmuch-show-stash-tags)
377         (notmuch-show-stash-filename)
378         (switch-to-buffer
379           (generate-new-buffer "*test-stashing*"))
380         (dotimes (i 9)
381           (yank)
382           (insert "\n")
383           (rotate-yank-pointer 1))
384         (reverse-region (point-min) (point-max))
385             (test-output)'
386 cat <<EOF >EXPECTED
387 Sat, 01 Jan 2000 12:00:00 -0000
388 Some One <someone@somewhere.org>
389 Some One Else <notsomeone@somewhere.org>
390 Notmuch <notmuch@notmuchmail.org>
391 Stash my stashables
392 id:"bought"
393 bought
394 inbox,stashtest
395 ${gen_msg_filename}
396 EOF
397 test_expect_equal_file OUTPUT EXPECTED
398
399 test_begin_subtest "Stashing in notmuch-search"
400 test_emacs '(notmuch-search "id:\"bought\"")
401         (notmuch-test-wait)
402         (notmuch-search-stash-thread-id)
403         (switch-to-buffer
404           (generate-new-buffer "*test-stashing*"))
405         (yank)
406             (test-output)'
407 sed -i -e 's/^thread:.*$/thread:XXX/' OUTPUT
408 test_expect_equal $(cat OUTPUT) "thread:XXX"
409
410 test_begin_subtest 'Hiding message following HTML part'
411 test_subtest_known_broken
412 id='html-message@notmuchmail.org'
413 emacs_deliver_message \
414     'HTML message' \
415     '' \
416     "(message-goto-eoh)
417      (insert \"Message-ID: <$id>\n\")
418      (message-goto-body)
419      (mml-insert-part \"text/html\")
420      (insert \"<body>This is a test HTML message</body>\")"
421 emacs_deliver_message \
422     'Reply to HTML message' \
423     'This is a reply to the test HTML message' \
424     "(message-goto-eoh)
425      (insert \"In-Reply-To: <$id>\n\")"
426 test_emacs "(notmuch-show \"id:$id\") \
427             (notmuch-show-next-message) \
428             (command-execute (key-binding (kbd \"RET\"))) \
429             (test-visible-output)"
430 test_emacs "(notmuch-show \"id:$id\") \
431             (notmuch-show-next-message) \
432             (notmuch-show-toggle-message) \
433             (test-visible-output \"EXPECTED\")"
434 test_expect_equal_file OUTPUT EXPECTED
435
436 test_begin_subtest 'notmuch-show-advance-and-archive with invisible signature'
437 message1='id:20091118010116.GC25380@dottiness.seas.harvard.edu'
438 message2='id:1258491078-29658-1-git-send-email-dottedmag@dottedmag.net'
439 test_emacs "(notmuch-search \"$message1 or $message2\")
440             (notmuch-test-wait)
441             (notmuch-search-show-thread)
442             (goto-char (point-max))
443             (redisplay)
444             (notmuch-show-advance-and-archive)
445             (test-output)"
446 test_emacs "(notmuch-show \"$message2\")
447             (test-output \"EXPECTED\")"
448 test_expect_equal_file OUTPUT EXPECTED
449
450 test_begin_subtest "Refresh show buffer"
451 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
452             (test-visible-output "EXPECTED")
453             (notmuch-show-refresh-view)
454             (test-visible-output)'
455 test_expect_equal_file OUTPUT EXPECTED
456
457 test_begin_subtest "Refresh modified show buffer"
458 test_subtest_known_broken
459 test_emacs '(notmuch-show "id:f35dbb950911171438k5df6eb56k77b6c0944e2e79ae@mail.gmail.com")
460             (notmuch-show-toggle-message)
461             (notmuch-show-next-message)
462             (notmuch-show-toggle-message)
463             (test-visible-output "EXPECTED")
464             (notmuch-show-refresh-view)
465             (test-visible-output)'
466 test_expect_equal_file OUTPUT EXPECTED
467
468 test_done