]> git.notmuchmail.org Git - notmuch/blob - test/T650-regexp-query.sh
test: known broken tests for bracketed terms in subject
[notmuch] / test / T650-regexp-query.sh
1 #!/usr/bin/env bash
2 test_description='regular expression searches'
3 . $(dirname "$0")/test-lib.sh || exit 1
4
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"
10
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"'
14
15 test_begin_subtest "empty path:// search"
16 notmuch search 'path:""' > EXPECTED
17 notmuch search 'path:/^$/' > OUTPUT
18 test_expect_equal_file EXPECTED OUTPUT
19
20 test_begin_subtest "empty folder:// search"
21 notmuch search 'folder:""' > EXPECTED
22 notmuch search 'folder:/^$/' > OUTPUT
23 test_expect_equal_file EXPECTED OUTPUT
24
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)"
30
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)"
34
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)"
40
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)"
44
45 # Use "standard" corpus from here on.
46 add_email_corpus
47
48 notmuch search --output=messages from:cworth > cworth.msg-ids
49
50 # these headers will generate no document terms
51 add_message '[from]="-" [subject]="empty from"'
52 add_message '[subject]="-"'
53
54 test_begin_subtest "null from: search"
55 notmuch search 'from:""' | notmuch_search_sanitize > OUTPUT
56 cat <<EOF > EXPECTED
57 thread:XXX   2001-01-05 [1/1] -; empty from (inbox unread)
58 EOF
59 test_expect_equal_file EXPECTED OUTPUT
60
61 test_begin_subtest "null subject: search"
62 notmuch search 'subject:""' | notmuch_search_sanitize > OUTPUT
63 cat <<EOF > EXPECTED
64 thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; - (inbox unread)
65 EOF
66 test_expect_equal_file EXPECTED OUTPUT
67
68 test_begin_subtest "bracketed subject search (with dquotes)"
69 test_subtest_known_broken
70 notmuch search subject:notmuch and subject:show > EXPECTED
71 notmuch search 'subject:"(show notmuch)"' > OUTPUT
72 test_expect_equal_file_nonempty EXPECTED OUTPUT
73
74 test_begin_subtest "bracketed subject search (with dquotes and operator 'or')"
75 test_subtest_known_broken
76 notmuch search subject:notmuch or subject:show > EXPECTED
77 notmuch search 'subject:"(notmuch or show)"' > OUTPUT
78 test_expect_equal_file_nonempty EXPECTED OUTPUT
79
80 test_begin_subtest "bracketed subject search (with dquotes and operator 'and')"
81 test_subtest_known_broken
82 notmuch search subject:notmuch and subject:show > EXPECTED
83 notmuch search 'subject:"(notmuch and show)"' > OUTPUT
84 test_expect_equal_file_nonempty EXPECTED OUTPUT
85
86 test_begin_subtest "xapian wildcard search for from:"
87 notmuch search --output=messages 'from:cwo*' > OUTPUT
88 test_expect_equal_file cworth.msg-ids OUTPUT
89
90 test_begin_subtest "xapian wildcard search for subject:"
91 test_expect_equal $(notmuch count 'subject:count*') 1
92
93 add_message '[from]="and"' '[subject]="and-and-and"'
94 printf "id:$gen_msg_id\n" > EXPECTED
95
96 test_begin_subtest "quoted xapian keyword search for from:"
97 notmuch search --output=messages 'from:"and"' > OUTPUT
98 test_expect_equal_file EXPECTED OUTPUT
99
100 test_begin_subtest "quoted xapian keyword search for subject:"
101 notmuch search --output=messages 'subject:"and-and-and"' > OUTPUT
102 test_expect_equal_file EXPECTED OUTPUT
103
104 test_begin_subtest "regexp from search, case sensitive"
105 notmuch search --output=messages from:/carl/ > OUTPUT
106 test_expect_equal_file /dev/null OUTPUT
107
108 test_begin_subtest "empty regexp or query"
109 notmuch search --output=messages from:/carl/ or from:/cworth/ > OUTPUT
110 test_expect_equal_file cworth.msg-ids OUTPUT
111
112 test_begin_subtest "non-empty regexp and query"
113 notmuch search  from:/cworth@cworth.org/ and subject:patch | notmuch_search_sanitize > OUTPUT
114 cat <<EOF > EXPECTED
115 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)
116 thread:XXX   2009-11-18 [1/2] Carl Worth| Ingmar Vanhassel; [notmuch] [PATCH] Typsos (inbox unread)
117 thread:XXX   2009-11-18 [1/2] Carl Worth| Jan Janak; [notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
118 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)
119 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)
120 EOF
121 test_expect_equal_file EXPECTED OUTPUT
122
123 test_begin_subtest "regexp from search, duplicate term search"
124 notmuch search --output=messages from:/cworth/ > OUTPUT
125 test_expect_equal_file cworth.msg-ids OUTPUT
126
127 test_begin_subtest "long enough regexp matches only desired senders"
128 notmuch search --output=messages 'from:"/C.* Wo/"' > OUTPUT
129 test_expect_equal_file cworth.msg-ids OUTPUT
130
131 test_begin_subtest "shorter regexp matches one more sender"
132 notmuch search --output=messages 'from:"/C.* W/"' > OUTPUT
133 { echo id:1258544095-16616-1-git-send-email-chris@chris-wilson.co.uk; cat cworth.msg-ids; } > EXPECTED
134 test_expect_equal_file EXPECTED OUTPUT
135
136 test_begin_subtest "regexp subject search, non-ASCII"
137 notmuch search --output=messages subject:/accentuĂ©/ > OUTPUT
138 echo id:877h1wv7mg.fsf@inf-8657.int-evry.fr > EXPECTED
139 test_expect_equal_file EXPECTED OUTPUT
140
141 test_begin_subtest "regexp subject search, punctuation"
142 notmuch search subject:/\'X\'/ | notmuch_search_sanitize > OUTPUT
143 cat <<EOF > EXPECTED
144 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)
145 EOF
146 test_expect_equal_file EXPECTED OUTPUT
147
148 test_begin_subtest "regexp subject search, no punctuation"
149 notmuch search  subject:/X/ | notmuch_search_sanitize > OUTPUT
150 cat <<EOF > EXPECTED
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)
152 thread:XXX   2009-11-18 [4/4] Jjgod Jiang, Alexander Botero-Lowry; [notmuch] Mac OS X/Darwin compatibility issues (inbox unread)
153 EOF
154 test_expect_equal_file EXPECTED OUTPUT
155
156 test_begin_subtest "combine regexp from and subject"
157 notmuch search  subject:/-C/ and from:/.an.k/ | notmuch_search_sanitize > OUTPUT
158 cat <<EOF > EXPECTED
159 thread:XXX   2009-11-17 [1/2] Jan Janak| Carl Worth; [notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
160 EOF
161 test_expect_equal_file EXPECTED OUTPUT
162
163 test_begin_subtest "regexp error reporting"
164 notmuch search 'from:/unbalanced[/' 2>&1 | sed -e '/^A Xapian/ s/[^:]*$//' > OUTPUT
165 cat <<EOF > EXPECTED
166 notmuch search: A Xapian exception occurred
167 A Xapian exception occurred parsing query: Regexp error:
168 Query string was: from:/unbalanced[/
169 EOF
170 test_expect_equal_file EXPECTED OUTPUT
171
172 test_begin_subtest "empty mid search"
173 notmuch search --output=messages mid:yoom > OUTPUT
174 cp /dev/null EXPECTED
175 test_expect_equal_file EXPECTED OUTPUT
176
177 test_begin_subtest "non-empty mid regex search"
178 notmuch search --output=messages mid:/yoom/ > OUTPUT
179 test_expect_equal_file cworth.msg-ids OUTPUT
180
181 test_begin_subtest "combine regexp mid and subject"
182 notmuch search  subject:/-C/ and mid:/y..m/ | notmuch_search_sanitize > OUTPUT
183 cat <<EOF > EXPECTED
184 thread:XXX   2009-11-18 [1/2] Carl Worth| Jan Janak; [notmuch] [PATCH] Older versions of install do not support -C. (inbox unread)
185 EOF
186 test_expect_equal_file EXPECTED OUTPUT
187
188 test_begin_subtest "unanchored tag search"
189 notmuch search tag:signed or tag:inbox > EXPECTED
190 notmuch search tag:/i/ > OUTPUT
191 test_expect_equal_file EXPECTED OUTPUT
192
193 notmuch tag +testsi '*'
194 test_begin_subtest "anchored tag search"
195 notmuch search tag:signed > EXPECTED
196 notmuch search tag:/^si/ > OUTPUT
197 test_expect_equal_file EXPECTED OUTPUT
198
199 test_done