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
7 EXPECTED=$NOTMUCH_SRCDIR/test/emacs-tree.expected-output
12 test_begin_subtest "Basic notmuch-tree view in emacs"
13 test_emacs '(notmuch-tree "tag:inbox")
16 (delete-other-windows)'
17 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
19 test_begin_subtest "Refreshed notmuch-tree view in emacs"
20 test_emacs '(notmuch-tree "tag:inbox")
22 (notmuch-tree-refresh-view)
25 (delete-other-windows)'
26 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
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
32 test_begin_subtest "Tag message in notmuch tree view (display)"
33 test_emacs '(notmuch-tree "tag:inbox")
36 (notmuch-tree-tag (list "+test_tag"))
38 (delete-other-windows)'
39 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-tagged OUTPUT
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"
45 test_begin_subtest "Untag message in notmuch tree view"
46 test_emacs '(notmuch-tree "tag:inbox")
49 (notmuch-tree-tag (list "-test_tag"))
51 (delete-other-windows)'
52 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
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" ""
58 test_begin_subtest "Tag thread in notmuch tree view"
59 test_emacs '(notmuch-tree "tag:inbox")
61 ;; move to a sizable thread
63 (notmuch-tree-tag-thread (list "+test_thread_tag"))
65 (delete-other-windows)'
66 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox-thread-tagged OUTPUT
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"
79 test_begin_subtest "Untag thread in notmuch tree view"
80 test_emacs '(notmuch-tree "tag:inbox")
82 ;; move to the same sizable thread as above
84 (notmuch-tree-tag-thread (list "-test_thread_tag"))
86 (delete-other-windows)'
87 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
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" ""
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)))
99 (notmuch-tree-from-search-current-query)
102 (delete-other-windows)'
103 test_expect_equal_file $EXPECTED/notmuch-tree-tag-inbox OUTPUT
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)))
111 (notmuch-tree-from-search-thread)
114 (delete-other-windows)'
115 test_expect_equal_file $EXPECTED/notmuch-tree-single-thread OUTPUT
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)))
123 (notmuch-search-show-thread)
124 (notmuch-tree-from-show-current-query)
127 (delete-other-windows)'
128 test_expect_equal_file $EXPECTED/notmuch-tree-single-thread OUTPUT
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)))
136 (notmuch-search-next-thread)
137 (notmuch-tree-from-search-thread)
139 (select-window notmuch-tree-message-window)
141 (delete-other-windows)'
142 test_expect_equal_file $EXPECTED/notmuch-tree-show-window OUTPUT
144 test_begin_subtest "Stash id"
145 output=$(test_emacs '(notmuch-tree "id:1258498485-sup-142@elly")
147 (notmuch-show-stash-message-id)')
148 test_expect_equal "$output" "\"Stashed: id:1258498485-sup-142@elly\""
150 test_begin_subtest "Move to next matching message"
151 output=$(test_emacs '(notmuch-tree "from:cworth")
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\""
157 test_begin_subtest "Move to next thread"
158 output=$(test_emacs '(notmuch-tree "tag:inbox")
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\""
165 test_begin_subtest "Move to previous thread"
166 output=$(test_emacs '(notmuch-tree "tag:inbox")
169 (notmuch-tree-prev-thread)
170 (notmuch-show-stash-message-id)')
171 test_expect_equal "$output" "\"Stashed: id:20091117190054.GU3165@dottiness.seas.harvard.edu\""
173 test_begin_subtest "Move to previous previous thread"
174 output=$(test_emacs '(notmuch-tree "tag:inbox")
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\""
182 test_begin_subtest "Functions in tree-result-format"
185 ((notmuch-tree-result-format
186 (quote (("date" . "%12s ")
187 ("authors" . "%-20s")
189 ("subject" . "%s")) . " %-54s ")
190 (notmuch-test-result-flags . "(%s)")))))
191 (notmuch-tree "tag:inbox")
195 test_expect_equal_file $EXPECTED/result-format-function OUTPUT
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"
203 add_email_corpus duplicate
205 ID3=87r2ecrr6x.fsf@zephyr.silentflame.com
206 test_begin_subtest "duplicate=3, subject"
207 test_emacs "(notmuch-tree \"id:${ID3}\")
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"
217 test_begin_subtest "duplicate=4"
218 test_emacs "(notmuch-show \"id:${ID3}\")
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