3 test_description="emacs notmuch-show view"
4 . $(dirname "$0")/test-lib.sh || exit 1
6 EXPECTED=$NOTMUCH_SRCDIR/test/emacs-show.expected-output
11 test_begin_subtest "Hiding Original Message region at beginning of a message"
12 message_id='OriginalMessageHiding.1@notmuchmail.org'
15 '[subject]="Hiding Original Message region at beginning of a message"' \
16 '[body]="-----Original Message-----
20 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
21 Subject: Hiding Original Message region at beginning of a message
22 To: Notmuch Test Suite <test_suite@notmuchmail.org>
25 [ 2-line hidden original message. Click/Enter to show. ]
28 test_emacs "(notmuch-show \"id:$message_id\")
29 (test-visible-output \"OUTPUT.raw\")"
30 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
31 test_expect_equal_file EXPECTED OUTPUT
33 test_begin_subtest "Bare subject #1"
34 output=$(test_emacs '(notmuch-show-strip-re "Re: subject")')
35 test_expect_equal "$output" '"subject"'
37 test_begin_subtest "Bare subject #2"
38 output=$(test_emacs '(notmuch-show-strip-re "re:Re: re: Re: re:subject")')
39 test_expect_equal "$output" '"subject"'
41 test_begin_subtest "Bare subject #3"
42 output=$(test_emacs '(notmuch-show-strip-re "the cure: fix the regexp")')
43 test_expect_equal "$output" '"the cure: fix the regexp"'
45 test_begin_subtest "don't process cryptographic MIME parts"
46 test_emacs '(let ((notmuch-crypto-process-mime nil))
47 (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
48 (test-visible-output))'
49 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-off OUTPUT
51 test_begin_subtest "process cryptographic MIME parts"
52 test_emacs '(let ((notmuch-crypto-process-mime t))
53 (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
54 (test-visible-output))'
55 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-on OUTPUT
57 test_begin_subtest "process cryptographic MIME parts (w/ notmuch-show-toggle-process-crypto)"
58 test_emacs '(let ((notmuch-crypto-process-mime nil))
59 (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
60 (notmuch-show-toggle-process-crypto)
61 (test-visible-output))'
62 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-on OUTPUT
64 test_begin_subtest "notmuch-show: don't elide non-matching messages"
65 test_emacs '(let ((notmuch-show-only-matching-messages nil))
66 (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
68 (notmuch-search-show-thread)
70 (test-visible-output))'
71 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-off OUTPUT
73 test_begin_subtest "notmuch-show: elide non-matching messages"
74 test_emacs '(let ((notmuch-show-only-matching-messages t))
75 (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
77 (notmuch-search-show-thread)
79 (test-visible-output))'
80 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
82 test_begin_subtest "notmuch-show: elide non-matching messages (w/ notmuch-show-toggle-elide-non-matching)"
83 test_emacs '(let ((notmuch-show-only-matching-messages nil))
84 (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
86 (notmuch-search-show-thread)
88 (notmuch-show-toggle-elide-non-matching)
89 (test-visible-output))'
90 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
92 test_begin_subtest "notmuch-show: elide non-matching messages (w/ prefix arg to notmuch-show)"
93 test_emacs '(let ((notmuch-show-only-matching-messages nil))
94 (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
96 (notmuch-search-show-thread t)
98 (test-visible-output))'
99 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
101 test_begin_subtest "notmuch-show: disable indentation of thread content (w/ notmuch-show-toggle-thread-indentation)"
102 test_emacs '(notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
104 (notmuch-search-show-thread)
106 (notmuch-show-toggle-thread-indentation)
107 (test-visible-output)'
108 test_expect_equal_file $EXPECTED/notmuch-show-indent-thread-content-off OUTPUT
110 test_begin_subtest "id buttonization"
111 add_message '[body]="
113 id:abc.def. id:abc,def, id:abc;def; id:abc:def:
114 id:foo@bar.?baz? id:foo@bar!.baz!
115 (id:foo@bar.baz) [id:foo@bar.baz]
132 mid:abc. mid:abc, mid:abc;"'
133 test_emacs '(notmuch-show "id:'$gen_msg_id'")
134 (notmuch-test-mark-links)
135 (test-visible-output "OUTPUT.raw")'
137 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
138 Subject: id buttonization
139 To: Notmuch Test Suite <test_suite@notmuchmail.org>
143 <<id:abc.def>>. <<id:abc,def>>, <<id:abc;def>>; <<id:abc:def>>:
144 <<id:foo@bar.?baz>>? <<id:foo@bar!.baz>>!
145 (<<id:foo@bar.baz>>) [<<id:foo@bar.baz>>]
146 <<id:foo@bar.baz>>...
160 <<mid:abc>> <<mid:abc/def>>
162 <<mid:abc>>. <<mid:abc>>, <<mid:abc>>;
164 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
165 test_expect_equal_file EXPECTED OUTPUT
168 test_begin_subtest "Show handles subprocess errors"
169 cat > notmuch_fail <<EOF
172 echo This is an error >&2
175 chmod a+x notmuch_fail
176 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
177 (with-current-buffer \"*Messages*\"
178 (let ((inhibit-read-only t)) (erase-buffer)))
181 (error (message \"%s\" (cadr err))))
183 (with-current-buffer \"*Messages*\"
184 (test-output \"MESSAGES\"))
185 (with-current-buffer \"*Notmuch errors*\"
186 (test-output \"ERROR\"))
188 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
191 This is an error (see *Notmuch errors* for more details)
195 command: YYY/notmuch_fail show --format\\=sexp --format-version\\=4 --decrypt\\=true --exclude\\=false \\' \\* \\'
202 test_begin_subtest "text/enriched exploit mitigation"
203 add_message '[content-type]="text/enriched"
205 <x-display><param>(when (progn (read-only-mode -1) (insert ?p ?0 ?w ?n ?e ?d)) nil)</param>test</x-display>
207 test_emacs '(notmuch-show "id:'$gen_msg_id'")
208 (test-visible-output "OUTPUT.raw")'
209 output=$(head -1 OUTPUT.raw|cut -f1-4 -d' ')
210 test_expect_equal "$output" "Notmuch Test Suite <test_suite@notmuchmail.org>"
213 # switching to the crypto corpus, using gpg from here on:
215 add_email_corpus crypto
217 test_begin_subtest "show decrypted message"
218 test_emacs '(notmuch-show "id:basic-encrypted@crypto.notmuchmail.org")
219 (test-visible-output)'
220 test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message OUTPUT
222 test_begin_subtest "show undecryptable message"
223 test_emacs '(notmuch-show "id:simple-encrypted@crypto.notmuchmail.org")
224 (test-visible-output)'
225 test_expect_equal_file $EXPECTED/notmuch-show-undecryptable-message OUTPUT
227 test_begin_subtest "show encrypted message when not processing crypto"
228 test_emacs '(let ((notmuch-crypto-process-mime nil))
229 (notmuch-show "id:basic-encrypted@crypto.notmuchmail.org")
230 (test-visible-output))'
231 test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message-no-crypto OUTPUT