3 test_description="emacs notmuch-show view"
4 . $(dirname "$0")/test-lib.sh || exit 1
5 . $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
7 EXPECTED=$NOTMUCH_SRCDIR/test/emacs-show.expected-output
12 test_begin_subtest "Hiding Original Message region at beginning of a message"
13 message_id='OriginalMessageHiding.1@notmuchmail.org'
16 '[subject]="Hiding Original Message region at beginning of a message"' \
17 '[body]="-----Original Message-----
21 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
22 Subject: Hiding Original Message region at beginning of a message
23 To: Notmuch Test Suite <test_suite@notmuchmail.org>
26 [ 2-line hidden original message. Click/Enter to show. ]
29 test_emacs "(notmuch-show \"id:$message_id\")
30 (test-visible-output \"OUTPUT.raw\")"
31 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
32 test_expect_equal_file EXPECTED OUTPUT
34 test_begin_subtest "Bare subject #1"
35 output=$(test_emacs '(notmuch-show-strip-re "Re: subject")')
36 test_expect_equal "$output" '"subject"'
38 test_begin_subtest "Bare subject #2"
39 output=$(test_emacs '(notmuch-show-strip-re "re:Re: re: Re: re:subject")')
40 test_expect_equal "$output" '"subject"'
42 test_begin_subtest "Bare subject #3"
43 output=$(test_emacs '(notmuch-show-strip-re "the cure: fix the regexp")')
44 test_expect_equal "$output" '"the cure: fix the regexp"'
46 test_begin_subtest "don't process cryptographic MIME parts"
47 test_emacs '(let ((notmuch-crypto-process-mime nil))
48 (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
49 (test-visible-output))'
50 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-off OUTPUT
52 test_begin_subtest "process cryptographic MIME parts"
53 test_emacs '(let ((notmuch-crypto-process-mime t))
54 (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
55 (test-visible-output))'
56 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-on OUTPUT
58 test_begin_subtest "process cryptographic MIME parts (w/ notmuch-show-toggle-process-crypto)"
59 test_emacs '(let ((notmuch-crypto-process-mime nil))
60 (notmuch-show "id:20091117203301.GV3165@dottiness.seas.harvard.edu")
61 (notmuch-show-toggle-process-crypto)
62 (test-visible-output))'
63 test_expect_equal_file $EXPECTED/notmuch-show-process-crypto-mime-parts-on OUTPUT
65 test_begin_subtest "notmuch-show: don't elide non-matching messages"
66 test_emacs '(let ((notmuch-show-only-matching-messages nil))
67 (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
69 (notmuch-search-show-thread)
71 (test-visible-output))'
72 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-off OUTPUT
74 test_begin_subtest "notmuch-show: elide non-matching messages"
75 test_emacs '(let ((notmuch-show-only-matching-messages t))
76 (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
78 (notmuch-search-show-thread)
80 (test-visible-output))'
81 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
83 test_begin_subtest "notmuch-show: elide non-matching messages (w/ notmuch-show-toggle-elide-non-matching)"
84 test_emacs '(let ((notmuch-show-only-matching-messages nil))
85 (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
87 (notmuch-search-show-thread)
89 (notmuch-show-toggle-elide-non-matching)
90 (test-visible-output))'
91 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
93 test_begin_subtest "notmuch-show: elide non-matching messages (w/ prefix arg to notmuch-show)"
94 test_emacs '(let ((notmuch-show-only-matching-messages nil))
95 (notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
97 (notmuch-search-show-thread t)
99 (test-visible-output))'
100 test_expect_equal_file $EXPECTED/notmuch-show-elide-non-matching-messages-on OUTPUT
102 test_begin_subtest "notmuch-show: disable indentation of thread content (w/ notmuch-show-toggle-thread-indentation)"
103 test_emacs '(notmuch-search "from:lars@seas.harvard.edu and subject:\"Maildir storage\"")
105 (notmuch-search-show-thread)
107 (notmuch-show-toggle-thread-indentation)
108 (test-visible-output)'
109 test_expect_equal_file $EXPECTED/notmuch-show-indent-thread-content-off OUTPUT
111 test_begin_subtest "id buttonization"
112 add_message '[body]="
114 id:abc.def. id:abc,def, id:abc;def; id:abc:def:
115 id:foo@bar.?baz? id:foo@bar!.baz!
116 (id:foo@bar.baz) [id:foo@bar.baz]
133 mid:abc. mid:abc, mid:abc;"'
134 test_emacs '(notmuch-show "id:'$gen_msg_id'")
135 (notmuch-test-mark-links)
136 (test-visible-output "OUTPUT.raw")'
138 Notmuch Test Suite <test_suite@notmuchmail.org> (2001-01-05) (inbox)
139 Subject: id buttonization
140 To: Notmuch Test Suite <test_suite@notmuchmail.org>
144 <<id:abc.def>>. <<id:abc,def>>, <<id:abc;def>>; <<id:abc:def>>:
145 <<id:foo@bar.?baz>>? <<id:foo@bar!.baz>>!
146 (<<id:foo@bar.baz>>) [<<id:foo@bar.baz>>]
147 <<id:foo@bar.baz>>...
161 <<mid:abc>> <<mid:abc/def>>
163 <<mid:abc>>. <<mid:abc>>, <<mid:abc>>;
165 notmuch_date_sanitize < OUTPUT.raw > OUTPUT
166 test_expect_equal_file EXPECTED OUTPUT
169 test_begin_subtest "Show handles subprocess errors"
170 cat > notmuch_fail <<EOF
173 echo This is an error >&2
176 chmod a+x notmuch_fail
177 test_emacs "(let ((notmuch-command \"$PWD/notmuch_fail\"))
178 (with-current-buffer \"*Messages*\"
179 (let ((inhibit-read-only t)) (erase-buffer)))
182 (error (message \"%s\" (cadr err))))
184 (with-current-buffer \"*Messages*\"
185 (test-output \"MESSAGES\"))
186 (with-current-buffer \"*Notmuch errors*\"
187 (test-output \"ERROR\"))
189 test_expect_equal "$(notmuch_emacs_error_sanitize notmuch_fail OUTPUT MESSAGES ERROR)" "\
192 This is an error (see *Notmuch errors* for more details)
195 command: YYY/notmuch_fail show --format\\=sexp --format-version\\=5 --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 encrypted rfc822 message"
223 if ${TEST_EMACS} --quick --batch --eval '(kill-emacs (if (version< emacs-version "28") 0 1))'; then
224 test_subtest_known_broken
226 test_emacs '(notmuch-show "id:encrypted-rfc822-attachment@crypto.notmuchmail.org")
227 (test-visible-output)'
228 test_expect_code 1 'fgrep "!!!" OUTPUT'
230 test_begin_subtest "show undecryptable message"
231 test_emacs '(notmuch-show "id:simple-encrypted@crypto.notmuchmail.org")
232 (test-visible-output)'
233 test_expect_equal_file $EXPECTED/notmuch-show-undecryptable-message OUTPUT
235 test_begin_subtest "show encrypted message when not processing crypto"
236 test_emacs '(let ((notmuch-crypto-process-mime nil))
237 (notmuch-show "id:basic-encrypted@crypto.notmuchmail.org")
238 (test-visible-output))'
239 test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message-no-crypto OUTPUT
241 test_begin_subtest "notmuch-show with nonexistent CWD"
242 tid=$(notmuch search --limit=1 --output=threads '*' | sed s/thread://)
243 test_emacs "(test-log-error
244 (let ((default-directory \"/nonexistent\"))
245 (notmuch-show \"$tid\")))"
246 test_expect_equal "$(cat MESSAGES)" "COMPLETE"