2 test_description='regular expression searches'
3 . $(dirname "$0")/test-lib.sh || exit 1
5 add_message '[dir]=bad' '[subject]="To the bone"'
6 add_message '[dir]=.' '[subject]="Top level"'
7 add_message '[dir]=bad/news' '[subject]="Bears"'
8 mkdir -p "${MAIL_DIR}/duplicate/bad/news"
9 cp "$gen_msg_filename" "${MAIL_DIR}/duplicate/bad/news"
11 add_message '[dir]=things' '[subject]="These are a few"'
12 add_message '[dir]=things/favorite' '[subject]="Raindrops, whiskers, kettles"'
13 add_message '[dir]=things/bad' '[subject]="Bites, stings, sad feelings"'
15 test_begin_subtest "empty path:// search"
16 notmuch search 'path:""' > EXPECTED
17 notmuch search 'path:/^$/' > OUTPUT
18 test_expect_equal_file EXPECTED OUTPUT
20 test_begin_subtest "empty folder:// search"
21 notmuch search 'folder:""' > EXPECTED
22 notmuch search 'folder:/^$/' > OUTPUT
23 test_expect_equal_file EXPECTED OUTPUT
25 test_begin_subtest "unanchored folder:// specification"
26 output=$(notmuch search folder:/bad/ | notmuch_search_sanitize)
27 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; To the bone (inbox unread)
28 thread:XXX 2001-01-05 [1/1(2)] Notmuch Test Suite; Bears (inbox unread)
29 thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bites, stings, sad feelings (inbox unread)"
31 test_begin_subtest "anchored folder:// search"
32 output=$(notmuch search 'folder:/^bad$/' | notmuch_search_sanitize)
33 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; To the bone (inbox unread)"
35 test_begin_subtest "unanchored path:// specification"
36 output=$(notmuch search path:/bad/ | notmuch_search_sanitize)
37 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; To the bone (inbox unread)
38 thread:XXX 2001-01-05 [1/1(2)] Notmuch Test Suite; Bears (inbox unread)
39 thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Bites, stings, sad feelings (inbox unread)"
41 test_begin_subtest "anchored path:// search"
42 output=$(notmuch search 'path:/^bad$/' | notmuch_search_sanitize)
43 test_expect_equal "$output" "thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; To the bone (inbox unread)"
45 # Use "standard" corpus from here on.
48 notmuch search --output=messages from:cworth > cworth.msg-ids
50 # these headers will generate no document terms
51 add_message '[from]="-" [subject]="empty from"'
52 add_message '[subject]="-"'
54 test_begin_subtest "null from: search"
55 notmuch search 'from:""' | notmuch_search_sanitize > OUTPUT
57 thread:XXX 2001-01-05 [1/1] -; empty from (inbox unread)
59 test_expect_equal_file EXPECTED OUTPUT
61 test_begin_subtest "null subject: search"
62 notmuch search 'subject:""' | notmuch_search_sanitize > OUTPUT
64 thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; - (inbox unread)
66 test_expect_equal_file EXPECTED OUTPUT
68 test_begin_subtest "bracketed subject search (with dquotes)"
69 notmuch search subject:notmuch and subject:show > EXPECTED
70 notmuch search 'subject:"(show notmuch)"' > OUTPUT
71 test_expect_equal_file_nonempty EXPECTED OUTPUT
73 test_begin_subtest "bracketed subject search (with dquotes and operator 'or')"
74 notmuch search subject:notmuch or subject:show > EXPECTED
75 notmuch search 'subject:"(notmuch or show)"' > OUTPUT
76 test_expect_equal_file_nonempty EXPECTED OUTPUT
78 test_begin_subtest "bracketed subject search (with dquotes and operator 'and')"
79 notmuch search subject:notmuch and subject:show > EXPECTED
80 notmuch search 'subject:"(notmuch and show)"' > OUTPUT
81 test_expect_equal_file_nonempty EXPECTED OUTPUT
83 test_begin_subtest "bracketed subject search (with phrase, operator 'or')"
84 notmuch search 'subject:"mailing list"' or subject:FreeBSD > EXPECTED
85 notmuch search 'subject:"(""mailing list"" or FreeBSD)"' > OUTPUT
86 test_expect_equal_file_nonempty EXPECTED OUTPUT
88 test_begin_subtest "bracketed subject search (with phrase, operator 'and')"
89 notmuch search search 'subject:"notmuch show"' and subject:commands > EXPECTED
90 notmuch search 'subject:"(""notmuch show"" and commands)"' > OUTPUT
91 test_expect_equal_file_nonempty EXPECTED OUTPUT
93 test_begin_subtest "xapian wildcard search for from:"
94 notmuch search --output=messages 'from:cwo*' > OUTPUT
95 test_expect_equal_file cworth.msg-ids OUTPUT
97 test_begin_subtest "xapian wildcard search for subject:"
98 test_expect_equal $(notmuch count 'subject:count*') 1
100 add_message '[from]="and"' '[subject]="and-and-and"'
101 printf "id:$gen_msg_id\n" > EXPECTED
103 test_begin_subtest "quoted xapian keyword search for from:"
104 notmuch search --output=messages 'from:"and"' > OUTPUT
105 test_expect_equal_file EXPECTED OUTPUT
107 test_begin_subtest "quoted xapian keyword search for subject:"
108 notmuch search --output=messages 'subject:"and-and-and"' > OUTPUT
109 test_expect_equal_file EXPECTED OUTPUT
111 test_begin_subtest "regexp from search, case sensitive"
112 notmuch search --output=messages from:/carl/ > OUTPUT
113 test_expect_equal_file /dev/null OUTPUT
115 test_begin_subtest "empty regexp or query"
116 notmuch search --output=messages from:/carl/ or from:/cworth/ > OUTPUT
117 test_expect_equal_file cworth.msg-ids OUTPUT
119 test_begin_subtest "non-empty regexp and query"
120 notmuch search from:/cworth@cworth.org/ and subject:patch | notmuch_search_sanitize > OUTPUT
122 thread:XXX 2009-11-18 [1/2] Carl Worth| Alex Botero-Lowry; [notmuch] [PATCH] Error out if no query is supplied to search instead of going into an infinite loop (attachment inbox unread)
123 thread:XXX 2009-11-18 [1/2] Carl Worth| Ingmar Vanhassel; [notmuch] [PATCH] Typsos (inbox unread)
124 thread:XXX 2009-11-18 [1/2] Carl Worth| Jan Janak; [notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
125 thread:XXX 2009-11-18 [1/2] Carl Worth| Keith Packard; [notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox unread)
126 thread:XXX 2009-11-18 [2/5] Carl Worth| Mikhail Gusarov, Keith Packard; [notmuch] [PATCH 1/2] Close message file after parsing message headers (inbox unread)
128 test_expect_equal_file EXPECTED OUTPUT
130 test_begin_subtest "regexp from search, duplicate term search"
131 notmuch search --output=messages from:/cworth/ > OUTPUT
132 test_expect_equal_file cworth.msg-ids OUTPUT
134 test_begin_subtest "long enough regexp matches only desired senders"
135 notmuch search --output=messages 'from:"/C.* Wo/"' > OUTPUT
136 test_expect_equal_file cworth.msg-ids OUTPUT
138 test_begin_subtest "shorter regexp matches one more sender"
139 notmuch search --output=messages 'from:"/C.* W/"' > OUTPUT
140 { echo id:1258544095-16616-1-git-send-email-chris@chris-wilson.co.uk; cat cworth.msg-ids; } > EXPECTED
141 test_expect_equal_file EXPECTED OUTPUT
143 test_begin_subtest "regexp subject search, non-ASCII"
144 notmuch search --output=messages subject:/accentué/ > OUTPUT
145 echo id:877h1wv7mg.fsf@inf-8657.int-evry.fr > EXPECTED
146 test_expect_equal_file EXPECTED OUTPUT
148 test_begin_subtest "regexp subject search, punctuation"
149 notmuch search subject:/\'X\'/ | notmuch_search_sanitize > OUTPUT
151 thread:XXX 2009-11-18 [2/2] Keith Packard, Carl Worth; [notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox unread)
153 test_expect_equal_file EXPECTED OUTPUT
155 test_begin_subtest "regexp subject search, no punctuation"
156 notmuch search subject:/X/ | notmuch_search_sanitize > OUTPUT
158 thread:XXX 2009-11-18 [2/2] Keith Packard, Carl Worth; [notmuch] [PATCH] Make notmuch-show 'X' (and 'x') commands remove inbox (and unread) tags (inbox unread)
159 thread:XXX 2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)
161 test_expect_equal_file EXPECTED OUTPUT
163 test_begin_subtest "combine regexp from and subject"
164 notmuch search subject:/-C/ and from:/.an.k/ | notmuch_search_sanitize > OUTPUT
166 thread:XXX 2009-11-17 [1/2] Jan Janak| Carl Worth; [notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
168 test_expect_equal_file EXPECTED OUTPUT
170 test_begin_subtest "regexp error reporting"
171 notmuch search 'from:/unbalanced[/' 2>&1 | sed -e '/^A Xapian/ s/[^:]*$//' > OUTPUT
173 notmuch search: A Xapian exception occurred
174 A Xapian exception occurred parsing query: Regexp error:
175 Query string was: from:/unbalanced[/
177 test_expect_equal_file EXPECTED OUTPUT
179 test_begin_subtest "empty mid search"
180 notmuch search --output=messages mid:yoom > OUTPUT
181 cp /dev/null EXPECTED
182 test_expect_equal_file EXPECTED OUTPUT
184 test_begin_subtest "non-empty mid regex search"
185 notmuch search --output=messages mid:/yoom/ > OUTPUT
186 test_expect_equal_file cworth.msg-ids OUTPUT
188 test_begin_subtest "combine regexp mid and subject"
189 notmuch search subject:/-C/ and mid:/y..m/ | notmuch_search_sanitize > OUTPUT
191 thread:XXX 2009-11-18 [1/2] Carl Worth| Jan Janak; [notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
193 test_expect_equal_file EXPECTED OUTPUT
195 test_begin_subtest "unanchored tag search"
196 notmuch search tag:signed or tag:inbox > EXPECTED
197 notmuch search tag:/i/ > OUTPUT
198 test_expect_equal_file EXPECTED OUTPUT
200 notmuch tag +testsi '*'
201 test_begin_subtest "anchored tag search"
202 notmuch search tag:signed > EXPECTED
203 notmuch search tag:/^si/ > OUTPUT
204 test_expect_equal_file EXPECTED OUTPUT