3 test_description="emacs 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.expected-output
12 test_begin_subtest "Add tag from search view"
13 os_x_darwin_thread=$(notmuch search --output=threads id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com)
14 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
16 (execute-kbd-macro \"+tag-from-search-view\")"
17 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
18 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)"
20 test_begin_subtest "Remove tag from search view"
21 test_emacs "(notmuch-search \"$os_x_darwin_thread\")
23 (execute-kbd-macro \"-tag-from-search-view\")"
24 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
25 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)"
27 test_begin_subtest "Add tag (large query)"
28 # We use a long query to force us into batch mode and use a funny tag
29 # that requires escaping for batch tagging.
30 test_emacs "(notmuch-tag (concat \"$os_x_darwin_thread\" \" or \" (mapconcat #'identity (make-list notmuch-tag-argument-limit \"x\") \"-\")) (list \"+tag-from-%-large-query\"))"
31 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
32 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-%-large-query unread)"
33 notmuch tag -tag-from-%-large-query $os_x_darwin_thread
35 test_begin_subtest "notmuch-show: add single tag to single message"
36 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
37 (execute-kbd-macro \"+tag-from-show-view\")"
38 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
39 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)"
41 test_begin_subtest "notmuch-show: remove single tag from single message"
42 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
43 (execute-kbd-macro \"-tag-from-show-view\")"
44 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
45 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)"
47 test_begin_subtest "notmuch-show: add multiple tags to single message"
48 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
49 (execute-kbd-macro \"+tag1-from-show-view +tag2-from-show-view\")"
50 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
51 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox tag1-from-show-view tag2-from-show-view unread)"
53 test_begin_subtest "notmuch-show: remove multiple tags from single message"
54 test_emacs "(notmuch-show \"$os_x_darwin_thread\")
55 (execute-kbd-macro \"-tag1-from-show-view -tag2-from-show-view\")"
56 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
57 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)"
59 test_begin_subtest "notmuch-show: before-tag-hook is run, variables are defined"
60 output=$(test_emacs '(let ((notmuch-test-tag-hook-output nil)
61 (notmuch-before-tag-hook (function notmuch-test-tag-hook)))
62 (notmuch-show "id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com")
63 (execute-kbd-macro "+activate-hook\n")
64 (execute-kbd-macro "-activate-hook\n")
65 notmuch-test-tag-hook-output)')
66 test_expect_equal "$output" \
67 '(("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "-activate-hook")
68 ("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "+activate-hook"))'
70 test_begin_subtest "notmuch-show: after-tag-hook is run, variables are defined"
71 output=$(test_emacs '(let ((notmuch-test-tag-hook-output nil)
72 (notmuch-after-tag-hook (function notmuch-test-tag-hook)))
73 (notmuch-show "id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com")
74 (execute-kbd-macro "+activate-hook\n")
75 (execute-kbd-macro "-activate-hook\n")
76 notmuch-test-tag-hook-output)')
77 test_expect_equal "$output" \
78 '(("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "-activate-hook")
79 ("id:ddd65cda0911171950o4eea4389v86de9525e46052d3@mail.gmail.com" "+activate-hook"))'
82 test_begin_subtest "Search thread tag operations are race-free"
83 add_message '[subject]="Search race test"'
84 gen_msg_id_1=$gen_msg_id
85 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
86 '[references]="<'$gen_msg_id_1'>"' \
87 '[subject]="Search race test two"'
88 test_emacs '(notmuch-search "subject:\"search race test\"")
91 (execute-kbd-macro "+search-thread-race-tag")'
92 output=$(notmuch search --output=messages 'tag:search-thread-race-tag')
93 test_expect_equal "$output" "id:$gen_msg_id_1"
95 test_begin_subtest "Search global tag operations are race-free"
96 generate_message '[in-reply-to]="<'$gen_msg_id_1'>"' \
97 '[references]="<'$gen_msg_id_1'>"' \
98 '[subject]="Re: Search race test"'
99 test_emacs '(notmuch-search "subject:\"search race test\" -subject:two")
102 (execute-kbd-macro "*+search-global-race-tag")'
103 output=$(notmuch search --output=messages 'tag:search-global-race-tag')
104 test_expect_equal "$output" "id:$gen_msg_id_1"
106 test_begin_subtest "undo with empty history is an error"
107 test_emacs "(let ((notmuch-tag-history nil))
112 (error no further notmuch undo information)
114 test_expect_equal_file EXPECTED MESSAGES
116 for mode in search show tree unthreaded; do
117 test_begin_subtest "undo tagging in $mode mode"
118 test_emacs "(let ((notmuch-tag-history nil))
119 (notmuch-$mode \"$os_x_darwin_thread\")
121 (execute-kbd-macro \"+tag-to-be-undone-$mode\")
123 (notmuch-test-wait))"
124 count=$(notmuch count "tag:tag-to-be-undone-$mode")
125 test_expect_equal "$count" "0"
127 test_begin_subtest "undo tagging in $mode mode (multiple operations)"
128 test_emacs "(let ((notmuch-tag-history nil))
129 (notmuch-$mode \"$os_x_darwin_thread\")
131 (execute-kbd-macro \"+one-$mode\")
132 (execute-kbd-macro \"+two-$mode\")
135 (execute-kbd-macro \"+three-$mode\"))"
136 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
137 notmuch tag "-one-$mode" "-three-$mode" $os_x_darwin_thread
138 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox one-$mode three-$mode unread)"
140 test_begin_subtest "undo tagging in $mode mode (multiple undo)"
141 test_emacs "(let ((notmuch-tag-history nil))
142 (notmuch-$mode \"$os_x_darwin_thread\")
144 (execute-kbd-macro \"+one-$mode\")
145 (execute-kbd-macro \"+two-$mode\")
150 (execute-kbd-macro \"+three-$mode\"))"
151 output=$(notmuch search $os_x_darwin_thread | notmuch_search_sanitize)
152 notmuch tag "-one-$mode" "-three-$mode" $os_x_darwin_thread
153 test_expect_equal "$output" "thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox three-$mode unread)"
155 test_begin_subtest "undo tagging in $mode mode (via binding)"
156 test_emacs "(let ((notmuch-tag-history nil))
157 (notmuch-$mode \"$os_x_darwin_thread\")
159 (execute-kbd-macro \"+tag-to-be-undone-$mode\")
160 (execute-kbd-macro (kbd \"C-x u\"))
161 (notmuch-test-wait))"
162 count=$(notmuch count "tag:tag-to-be-undone-$mode")
163 test_expect_equal "$count" "0"