unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 748d947091fedd325a315ef63057e9bcac89f66d 11190 bytes (raw)
name: test/tagging 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
 
#!/usr/bin/env bash
test_description='"notmuch tag"'
. ./test-lib.sh

add_message '[subject]=One'
add_message '[subject]=Two'

test_begin_subtest "Adding tags"
notmuch tag +tag1 +tag2 +tag3 \*
output=$(notmuch search \* | notmuch_search_sanitize)
test_expect_equal "$output" "\
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 tag2 tag3 unread)
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 tag3 unread)"

test_begin_subtest "Removing tags"
notmuch tag -tag1 -tag2 \*
output=$(notmuch search \* | notmuch_search_sanitize)
test_expect_equal "$output" "\
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag3 unread)
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag3 unread)"

test_expect_code 1 "No tag operations" 'notmuch tag One'
test_expect_code 1 "No query" 'notmuch tag +tag2'

test_begin_subtest "Redundant tagging"
notmuch tag +tag1 -tag3 One
notmuch tag +tag1 -tag3 \*
output=$(notmuch search \* | notmuch_search_sanitize)
test_expect_equal "$output" "\
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"

test_begin_subtest "Special characters in tags"
notmuch tag +':" ' \*
notmuch tag -':" ' Two
output=$(notmuch search \* | notmuch_search_sanitize)
test_expect_equal "$output" "\
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\"  inbox tag1 unread)
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 unread)"

test_begin_subtest "Tagging order"
notmuch tag +tag4 -tag4 One
notmuch tag -tag4 +tag4 Two
output=$(notmuch search \* | notmuch_search_sanitize)
test_expect_equal "$output" "\
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (:\"  inbox tag1 unread)
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag4 unread)"

test_begin_subtest "--batch"
notmuch tag --batch <<EOF
# %20 is a space in tag
-:"%20 -tag1 +tag5 +tag6 -- O%6Ee
+tag1 -tag1 -tag4 +tag4 -- Two
-tag6 One
+tag5 Tw%6F
EOF
output=$(notmuch search \* | notmuch_search_sanitize)
test_expect_equal "$output" "\
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag5 unread)
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag5 unread)"

# generate a common input file for the next several tests.
cat > batch.in  <<EOF
# %40 is an @ in tag
+%40 -tag5 +tag6 -- One
+tag1 -tag1 -tag4 +tag4 -- Two
-tag5 +tag6 Two
EOF

cat > batch.expected <<EOF
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; One (@ inbox tag6 unread)
thread:XXX   2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag4 tag6 unread)
EOF

test_begin_subtest "--input"
notmuch dump --format=batch-tag > backup.tags
notmuch tag --input=batch.in
notmuch search \* | notmuch_search_sanitize > OUTPUT
notmuch restore --format=batch-tag < backup.tags
test_expect_equal_file batch.expected OUTPUT

test_begin_subtest "--batch --input"
notmuch dump --format=batch-tag > backup.tags
notmuch tag --batch --input=batch.in
notmuch search \* | notmuch_search_sanitize > OUTPUT
notmuch restore --format=batch-tag < backup.tags
test_expect_equal_file batch.expected OUTPUT

test_begin_subtest "--batch, blank lines and comments"
notmuch dump | sort > EXPECTED
notmuch tag --batch <<EOF
# this line is a comment; the next has only white space
 	 

# the previous line is empty
EOF
notmuch dump | sort > OUTPUT
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest '--batch: checking error messages'
notmuch dump --format=batch-tag > BACKUP
notmuch tag --batch <<EOF 2>OUTPUT
# the next line has a space
 
# this line has no tag operations, but this is permitted in batch format.
a
+0
+a +b
# trailing whitespace
+a +b 
+c +d --
# this is a harmless comment, do not yell about it.

# the previous line was blank; also no yelling please
+%zz -- id:whatever
+e +f id:%yy
# the next non-comment line should report an an empty tag error for
# batch tagging, but not for restore
+ +e -- id:foo
+- -- id:foo
EOF

cat <<EOF > EXPECTED
Warning: no query string [+0]
Warning: no query string [+a +b]
Warning: missing query string [+a +b ]
Warning: no query string after -- [+c +d --]
Warning: hex decoding of tag %zz failed [+%zz -- id:whatever]
Warning: hex decoding of token '%yy' failed [+e +f id:%yy]
Warning: empty tag forbidden [+ +e -- id:foo]
Warning: tag starting with '-' forbidden [+- -- id:foo]
EOF

notmuch restore --format=batch-tag < BACKUP
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest '--batch: tags with quotes'
notmuch dump --format=batch-tag > BACKUP

notmuch tag --batch <<EOF
+%22%27%22%27%22%22%27%27 -- One
-%22%27%22%27%22%22%27%27 -- One
+%22%27%22%22%22%27 -- One
+%22%27%22%27%22%22%27%27 -- Two
EOF

cat <<EOF > EXPECTED
+%22%27%22%22%22%27 +inbox +tag5 +unread -- id:msg-001@notmuch-test-suite
+%22%27%22%27%22%22%27%27 +inbox +tag4 +tag5 +unread -- id:msg-002@notmuch-test-suite
EOF

notmuch dump --format=batch-tag | sort > OUTPUT
notmuch restore --format=batch-tag < BACKUP
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest '--batch: tags with punctuation and space'
notmuch dump --format=batch-tag > BACKUP

notmuch tag --batch <<EOF
+%21@%23%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%60%7e -- One
-%21@%23%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%60%7e -- One
+%21@%23%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%20%60%7e -- Two
-%21@%23%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%20%60%7e -- Two
+%21@%23%20%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%60%7e -- One
+%21@%23%20%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%60%7e -- Two
EOF

cat <<EOF > EXPECTED
+%21@%23%20%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%60%7e +inbox +tag4 +tag5 +unread -- id:msg-002@notmuch-test-suite
+%21@%23%20%24%25%5e%26%2a%29-_=+%5b%7b%5c%20%7c%3b%3a%27%20%22,.%3c%60%7e +inbox +tag5 +unread -- id:msg-001@notmuch-test-suite
EOF

notmuch dump --format=batch-tag | sort > OUTPUT
notmuch restore --format=batch-tag < BACKUP
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest '--batch: compound queries'
notmuch dump --format=batch-tag > BACKUP

notmuch tag --batch <<EOF
# match nothing
+compound1 -- One and Two
# match everything
+compound2 -- One or Two
+tag%20with%20spaces -- *
# redundant compound query
+compound3 -- id:msg-002@notmuch-test-suite and Two
# check for prefix in second token
+compound4 -- Two and id:msg-002@notmuch-test-suite
# both have prefixes
-unread -- tag:tag%20with%20spaces and id:msg-002@notmuch-test-suite
# remove from only msg-001
-tag%20with%20spaces -- tag:unread and tag:compound2
EOF

cat <<EOF > EXPECTED
+compound2 +compound3 +compound4 +inbox +tag%20with%20spaces +tag4 +tag5 -- id:msg-002@notmuch-test-suite
+compound2 +inbox +tag5 +unread -- id:msg-001@notmuch-test-suite
EOF

notmuch dump --format=batch-tag | sort > OUTPUT
notmuch restore --format=batch-tag < BACKUP
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest '--batch: unicode tags'
notmuch dump --format=batch-tag > BACKUP

notmuch tag --batch <<EOF
+%2a@%7d%cf%b5%f4%85%80%adO3%da%a7 -- One
+=%e0%ac%95%c8%b3+%ef%aa%95%c8%a64w%c7%9d%c9%a2%cf%b3%d6%82%24B%c4%a9%c5%a1UX%ee%99%b0%27E7%ca%a4%d0%8b%5d -- One
+A%e1%a0%bc%de%8b%d5%b2V%d9%9b%f3%b5%a2%a3M%d8%a1u@%f0%a0%ac%948%7e%f0%ab%86%af%27 -- One
+R -- One
+%da%88=f%cc%b9I%ce%af%7b%c9%97%e3%b9%8bH%cb%92X%d2%8c6 -- One
+%dc%9crh%d2%86B%e5%97%a2%22t%ed%99%82d -- One
+L%df%85%ef%a1%a5m@%d3%96%c2%ab%d4%9f%ca%b8%f3%b3%a2%bf%c7%b1_u%d7%b4%c7%b1 -- One
+P%c4%98%2f -- One
+%7e%d1%8b%25%ec%a0%ae%d1%a0M%3b%e3%b6%b7%e9%a4%87%3c%db%9a%cc%a8%e1%96%9d -- One
+%c4%bf7%c7%ab9H%c4%99k%ea%91%bd%c3%8ck%e2%b3%8dk%c5%952V%e4%99%b2%d9%b3%e4%8b%bda%5b%24%c7%9b -- One
+%2a@%7d%cf%b5%f4%85%80%adO3%da%a7  +=%e0%ac%95%c8%b3+%ef%aa%95%c8%a64w%c7%9d%c9%a2%cf%b3%d6%82%24B%c4%a9%c5%a1UX%ee%99%b0%27E7%ca%a4%d0%8b%5d  +A%e1%a0%bc%de%8b%d5%b2V%d9%9b%f3%b5%a2%a3M%d8%a1u@%f0%a0%ac%948%7e%f0%ab%86%af%27  +R  +%da%88=f%cc%b9I%ce%af%7b%c9%97%e3%b9%8bH%cb%92X%d2%8c6  +%dc%9crh%d2%86B%e5%97%a2%22t%ed%99%82d  +L%df%85%ef%a1%a5m@%d3%96%c2%ab%d4%9f%ca%b8%f3%b3%a2%bf%c7%b1_u%d7%b4%c7%b1  +P%c4%98%2f  +%7e%d1%8b%25%ec%a0%ae%d1%a0M%3b%e3%b6%b7%e9%a4%87%3c%db%9a%cc%a8%e1%96%9d  +%c4%bf7%c7%ab9H%c4%99k%ea%91%bd%c3%8ck%e2%b3%8dk%c5%952V%e4%99%b2%d9%b3%e4%8b%bda%5b%24%c7%9b -- Two
EOF

cat <<EOF > EXPECTED
+%2a@%7d%cf%b5%f4%85%80%adO3%da%a7 +=%e0%ac%95%c8%b3+%ef%aa%95%c8%a64w%c7%9d%c9%a2%cf%b3%d6%82%24B%c4%a9%c5%a1UX%ee%99%b0%27E7%ca%a4%d0%8b%5d +A%e1%a0%bc%de%8b%d5%b2V%d9%9b%f3%b5%a2%a3M%d8%a1u@%f0%a0%ac%948%7e%f0%ab%86%af%27 +L%df%85%ef%a1%a5m@%d3%96%c2%ab%d4%9f%ca%b8%f3%b3%a2%bf%c7%b1_u%d7%b4%c7%b1 +P%c4%98%2f +R +inbox +tag4 +tag5 +unread +%7e%d1%8b%25%ec%a0%ae%d1%a0M%3b%e3%b6%b7%e9%a4%87%3c%db%9a%cc%a8%e1%96%9d +%c4%bf7%c7%ab9H%c4%99k%ea%91%bd%c3%8ck%e2%b3%8dk%c5%952V%e4%99%b2%d9%b3%e4%8b%bda%5b%24%c7%9b +%da%88=f%cc%b9I%ce%af%7b%c9%97%e3%b9%8bH%cb%92X%d2%8c6 +%dc%9crh%d2%86B%e5%97%a2%22t%ed%99%82d -- id:msg-002@notmuch-test-suite
+%2a@%7d%cf%b5%f4%85%80%adO3%da%a7 +=%e0%ac%95%c8%b3+%ef%aa%95%c8%a64w%c7%9d%c9%a2%cf%b3%d6%82%24B%c4%a9%c5%a1UX%ee%99%b0%27E7%ca%a4%d0%8b%5d +A%e1%a0%bc%de%8b%d5%b2V%d9%9b%f3%b5%a2%a3M%d8%a1u@%f0%a0%ac%948%7e%f0%ab%86%af%27 +L%df%85%ef%a1%a5m@%d3%96%c2%ab%d4%9f%ca%b8%f3%b3%a2%bf%c7%b1_u%d7%b4%c7%b1 +P%c4%98%2f +R +inbox +tag5 +unread +%7e%d1%8b%25%ec%a0%ae%d1%a0M%3b%e3%b6%b7%e9%a4%87%3c%db%9a%cc%a8%e1%96%9d +%c4%bf7%c7%ab9H%c4%99k%ea%91%bd%c3%8ck%e2%b3%8dk%c5%952V%e4%99%b2%d9%b3%e4%8b%bda%5b%24%c7%9b +%da%88=f%cc%b9I%ce%af%7b%c9%97%e3%b9%8bH%cb%92X%d2%8c6 +%dc%9crh%d2%86B%e5%97%a2%22t%ed%99%82d -- id:msg-001@notmuch-test-suite
EOF

notmuch dump --format=batch-tag | sort > OUTPUT
notmuch restore --format=batch-tag < BACKUP
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "--batch: only space and parens need to be quoted"
notmuch dump --format=batch-tag > BACKUP

notmuch tag --batch <<EOF
+winner *
+foo::bar -- (One and Two) or (One and tag:winner)
+found::it -- tag:foo::bar
# ignore this line and the next

+space%20in%20tags -- Two
# hex encode tag '(tags)', among other stunts.
+crazy{ +%28tags%29 +&are +#possible\ -- tag:space%20in%20tags
+match*crazy -- tag:crazy{
EOF

cat <<EOF > EXPECTED
+%23possible%5c +%26are +%28tags%29 +crazy%7b +inbox +match%2acrazy +space%20in%20tags +tag4 +tag5 +unread +winner -- id:msg-002@notmuch-test-suite
+foo%3a%3abar +found%3a%3ait +inbox +tag5 +unread +winner -- id:msg-001@notmuch-test-suite
EOF

notmuch dump --format=batch-tag | sort > OUTPUT
notmuch restore --format=batch-tag < BACKUP
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest '--batch: unicode message-ids'

${TEST_DIRECTORY}/random-corpus --config-path=${NOTMUCH_CONFIG} \
     --num-messages=100

notmuch dump --format=batch-tag | sed 's/^.* -- /+common_tag -- /' | \
    sort > EXPECTED

notmuch dump --format=batch-tag | sed 's/^.* -- /  -- /' | \
    notmuch restore --format=batch-tag

notmuch tag --batch < EXPECTED

notmuch dump --format=batch-tag| \
    sort > OUTPUT

test_expect_equal_file EXPECTED OUTPUT

test_expect_code 1 "Empty tag names" 'notmuch tag + One'

test_expect_code 1 "Tag name beginning with -" 'notmuch tag +- One'

test_done

debug log:

solving 748d947 ...
found 748d947 in https://yhetil.org/notmuch/1356313183-9266-17-git-send-email-david@tethera.net/
found 5b48cb7 in https://yhetil.org/notmuch/1356313183-9266-14-git-send-email-david@tethera.net/
found 9f66f4f in https://yhetil.org/notmuch/1356313183-9266-13-git-send-email-david@tethera.net/
found fc210d6 in https://yhetil.org/notmuch/1356313183-9266-12-git-send-email-david@tethera.net/
found 643f604 in https://yhetil.org/notmuch/1356313183-9266-11-git-send-email-david@tethera.net/
found 30cec48 in https://yhetil.org/notmuch/1356313183-9266-10-git-send-email-david@tethera.net/ ||
	https://yhetil.org/notmuch/1356095307-22895-10-git-send-email-david@tethera.net/ ||
	https://yhetil.org/notmuch/1355492062-7546-9-git-send-email-david@tethera.net/
found 980ff92 in https://yhetil.org/notmuch.git/
preparing index
index prepared:
100755 980ff9274b8228bd2c2559a756cafe1ec1fefaac	test/tagging

applying [1/6] https://yhetil.org/notmuch/1356313183-9266-10-git-send-email-david@tethera.net/
diff --git a/test/tagging b/test/tagging
index 980ff92..30cec48 100755

6:13: trailing whitespace.
 
6:19: trailing whitespace.
+a +b 
Checking patch test/tagging...
Applied patch test/tagging cleanly.
warning: 2 lines add whitespace errors.

skipping https://yhetil.org/notmuch/1356095307-22895-10-git-send-email-david@tethera.net/ for 30cec48
skipping https://yhetil.org/notmuch/1355492062-7546-9-git-send-email-david@tethera.net/ for 30cec48
index at:
100755 30cec489cc1c36a96c6919c1176aee78d1af4431	test/tagging

applying [2/6] https://yhetil.org/notmuch/1356313183-9266-11-git-send-email-david@tethera.net/
diff --git a/test/tagging b/test/tagging
index 30cec48..643f604 100755


applying [3/6] https://yhetil.org/notmuch/1356313183-9266-12-git-send-email-david@tethera.net/
diff --git a/test/tagging b/test/tagging
index 643f604..fc210d6 100755


applying [4/6] https://yhetil.org/notmuch/1356313183-9266-13-git-send-email-david@tethera.net/
diff --git a/test/tagging b/test/tagging
index fc210d6..9f66f4f 100755


applying [5/6] https://yhetil.org/notmuch/1356313183-9266-14-git-send-email-david@tethera.net/
diff --git a/test/tagging b/test/tagging
index 9f66f4f..5b48cb7 100755


applying [6/6] https://yhetil.org/notmuch/1356313183-9266-17-git-send-email-david@tethera.net/
diff --git a/test/tagging b/test/tagging
index 5b48cb7..748d947 100755

5:53: trailing whitespace.
 	 
Checking patch test/tagging...
Applied patch test/tagging cleanly.
Checking patch test/tagging...
Applied patch test/tagging cleanly.
Checking patch test/tagging...
Applied patch test/tagging cleanly.
Checking patch test/tagging...
Applied patch test/tagging cleanly.
Checking patch test/tagging...
Applied patch test/tagging cleanly.
warning: 1 line adds whitespace errors.

index at:
100755 748d947091fedd325a315ef63057e9bcac89f66d	test/tagging

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).