]> git.cworth.org Git - notmuch-old/blob - test/T460-emacs-tree.sh
doc/emacs: add docstring and example for n-search-result-format
[notmuch-old] / test / T460-emacs-tree.sh
1 #!/usr/bin/env bash
2
3 test_description="emacs tree view interface"
4 . $(dirname "$0")/test-lib.sh || exit 1
5 . $NOTMUCH_SRCDIR/test/test-lib-emacs.sh || exit 1
6
7 EXPECTED=$NOTMUCH_SRCDIR/test/emacs-tree.expected-output
8
9 test_require_emacs
10 add_email_corpus
11
12 test_begin_subtest "Basic notmuch-tree view in emacs"
13 test_emacs '(notmuch-tree "tag:inbox")
14             (notmuch-test-wait)
15             (test-output)
16             (delete-other-windows)'
17 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
18
19 test_begin_subtest "Refreshed notmuch-tree view in emacs"
20 test_emacs '(notmuch-tree "tag:inbox")
21             (notmuch-test-wait)
22             (notmuch-tree-refresh-view)
23             (notmuch-test-wait)
24             (test-output)
25             (delete-other-windows)'
26 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
27
28 # In the following tag tests we make sure the display is updated
29 # correctly and, in a separate test, that the database is updated
30 # correctly.
31
32 test_begin_subtest "Tag message in notmuch tree view (display)"
33 test_emacs '(notmuch-tree "tag:inbox")
34             (notmuch-test-wait)
35             (forward-line)
36             (notmuch-tree-tag (list "+test_tag"))
37             (test-output)
38             (delete-other-windows)'
39 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-tagged OUTPUT
40
41 test_begin_subtest "Tag message in notmuch tree view (database)"
42 output=$(notmuch search --output=messages 'tag:test_tag')
43 test_expect_equal "$output" "id:877h1wv7mg.fsf@inf-8657.int-evry.fr"
44
45 test_begin_subtest "Untag message in notmuch tree view"
46 test_emacs '(notmuch-tree "tag:inbox")
47             (notmuch-test-wait)
48             (forward-line)
49             (notmuch-tree-tag (list "-test_tag"))
50             (test-output)
51             (delete-other-windows)'
52 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
53
54 test_begin_subtest "Untag message in notmuch tree view (database)"
55 output=$(notmuch search --output=messages 'tag:test_tag')
56 test_expect_equal "$output" ""
57
58 test_begin_subtest "Tag thread in notmuch tree view"
59 test_emacs '(notmuch-tree "tag:inbox")
60             (notmuch-test-wait)
61             ;; move to a sizable thread
62             (forward-line 26)
63             (notmuch-tree-tag-thread (list "+test_thread_tag"))
64             (test-output)
65             (delete-other-windows)'
66 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-thread-tagged OUTPUT
67
68 test_begin_subtest "Tag message in notmuch tree view (database)"
69 output=$(notmuch search --output=messages 'tag:test_thread_tag')
70 test_expect_equal "$output" \
71 "id:87ocn0qh6d.fsf@yoom.home.cworth.org
72 id:20091118005040.GA25380@dottiness.seas.harvard.edu
73 id:yunaayketfm.fsf@aiko.keithp.com
74 id:87fx8can9z.fsf@vertex.dottedmag
75 id:20091117203301.GV3165@dottiness.seas.harvard.edu
76 id:87iqd9rn3l.fsf@vertex.dottedmag
77 id:20091117190054.GU3165@dottiness.seas.harvard.edu"
78
79 test_begin_subtest "Untag thread in notmuch tree view"
80 test_emacs '(notmuch-tree "tag:inbox")
81             (notmuch-test-wait)
82             ;; move to the same sizable thread as above
83             (forward-line 26)
84             (notmuch-tree-tag-thread (list "-test_thread_tag"))
85             (test-output)
86             (delete-other-windows)'
87 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
88
89 test_begin_subtest "Untag message in notmuch tree view (database)"
90 output=$(notmuch search --output=messages 'tag:test_thread_tag')
91 test_expect_equal "$output" ""
92
93 test_begin_subtest "Navigation of notmuch-hello to search results"
94 test_emacs '(notmuch-hello)
95             (goto-char (point-min))
96             (re-search-forward "inbox")
97             (widget-button-press (1- (point)))
98             (notmuch-test-wait)
99             (notmuch-tree-from-search-current-query)
100             (notmuch-test-wait)
101             (test-output)
102             (delete-other-windows)'
103 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
104
105 test_begin_subtest "Tree view of a single thread (from search)"
106 test_emacs '(notmuch-hello)
107             (goto-char (point-min))
108             (re-search-forward "inbox")
109             (widget-button-press (1- (point)))
110             (notmuch-test-wait)
111             (notmuch-tree-from-search-thread)
112             (notmuch-test-wait)
113             (test-output)
114             (delete-other-windows)'
115 test_expect_equal_file $EXPECTED/notmuch-tree-single-thread OUTPUT
116
117 test_begin_subtest "Tree view of a single thread (from show)"
118 test_emacs '(notmuch-hello)
119             (goto-char (point-min))
120             (re-search-forward "inbox")
121             (widget-button-press (1- (point)))
122             (notmuch-test-wait)
123             (notmuch-search-show-thread)
124             (notmuch-tree-from-show-current-query)
125             (notmuch-test-wait)
126             (test-output)
127             (delete-other-windows)'
128 test_expect_equal_file $EXPECTED/notmuch-tree-single-thread OUTPUT
129
130 test_begin_subtest "Message window of tree view"
131 test_emacs '(notmuch-hello)
132             (goto-char (point-min))
133             (re-search-forward "inbox")
134             (widget-button-press (1- (point)))
135             (notmuch-test-wait)
136             (notmuch-search-next-thread)
137             (notmuch-tree-from-search-thread)
138             (notmuch-test-wait)
139             (select-window notmuch-tree-message-window)
140             (test-output)
141             (delete-other-windows)'
142 test_expect_equal_file $EXPECTED/notmuch-tree-show-window OUTPUT
143
144 test_begin_subtest "Stash id"
145 output=$(test_emacs '(notmuch-tree "id:1258498485-sup-142@elly")
146                      (notmuch-test-wait)
147                      (notmuch-show-stash-message-id)')
148 test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142@elly\""
149
150 test_begin_subtest "Move to next matching message"
151 output=$(test_emacs '(notmuch-tree "from:cworth")
152                      (notmuch-test-wait)
153                      (notmuch-tree-next-matching-message)
154                      (notmuch-show-stash-message-id)')
155 test_expect_equal "$output" "\"Stashed: id:878we4qdqf.fsf@yoom.home.cworth.org\""
156
157 test_begin_subtest "Move to next thread"
158 output=$(test_emacs '(notmuch-tree "tag:inbox")
159                      (notmuch-test-wait)
160                      (forward-line 26)
161                      (notmuch-tree-next-thread)
162                      (notmuch-show-stash-message-id)')
163 test_expect_equal "$output" "\"Stashed: id:1258471718-6781-1-git-send-email-dottedmag@dottedmag.net\""
164
165 test_begin_subtest "Move to previous thread"
166 output=$(test_emacs '(notmuch-tree "tag:inbox")
167                      (notmuch-test-wait)
168                      (forward-line 26)
169                      (notmuch-tree-prev-thread)
170                      (notmuch-show-stash-message-id)')
171 test_expect_equal "$output" "\"Stashed: id:20091117190054.GU3165@dottiness.seas.harvard.edu\""
172
173 test_begin_subtest "Move to previous previous thread"
174 output=$(test_emacs '(notmuch-tree "tag:inbox")
175                      (notmuch-test-wait)
176                      (forward-line 26)
177                      (notmuch-tree-prev-thread)
178                      (notmuch-tree-prev-thread)
179                      (notmuch-show-stash-message-id)')
180 test_expect_equal "$output" "\"Stashed: id:1258493565-13508-1-git-send-email-keithp@keithp.com\""
181
182 test_begin_subtest "Functions in tree-result-format"
183 test_emacs '
184 (let
185     ((notmuch-tree-result-format
186      (quote (("date" . "%12s  ")
187              ("authors" . "%-20s")
188              ((("tree" . "%s")
189                ("subject" . "%s")) . " %-54s ")
190              (notmuch-test-result-flags . "(%s)")))))
191   (notmuch-tree "tag:inbox")
192   (notmuch-test-wait)
193   (test-output))
194 '
195 test_expect_equal_file $EXPECTED/result-format-function OUTPUT
196
197 test_begin_subtest "notmuch-tree with nonexistent CWD"
198 test_emacs '(test-log-error
199               (let ((default-directory "/nonexistent"))
200                 (notmuch-tree "*")))'
201 test_expect_equal "$(cat MESSAGES)" "COMPLETE"
202
203 add_email_corpus duplicate
204
205 ID3=87r2ecrr6x.fsf@zephyr.silentflame.com
206 test_begin_subtest "duplicate=3, subject"
207 test_emacs "(notmuch-tree \"id:${ID3}\")
208            (notmuch-test-wait)
209            (notmuch-tree-show-message t)
210            (notmuch-show-choose-duplicate 3)
211            (test-visible-output \"OUTPUT\")"
212 output=$(grep "Subject:" OUTPUT)
213 file=$(notmuch search --output=files id:${ID3} | head -n 3 | tail -n 1)
214 subject=$(grep '^Subject:' $file)
215 test_expect_equal "$output" "$subject"
216
217 test_begin_subtest "duplicate=4"
218 test_emacs "(notmuch-show \"id:${ID3}\")
219            (notmuch-test-wait)
220            (notmuch-tree-show-message t)
221            (notmuch-show-choose-duplicate 4)
222            (test-visible-output \"OUTPUT\")"
223 test_expect_equal_file_nonempty $NOTMUCH_SRCDIR/test/emacs-show.expected-output/notmuch-show-duplicate-4 OUTPUT
224
225 test_done