unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 643f604e14e67b1f12750216c719e38d24586c3a 4599 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
 
#!/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_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 643f604 ...
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/2] 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

2:13: trailing whitespace.
 
2: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/2] 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

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

index at:
100755 643f604e14e67b1f12750216c719e38d24586c3a	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).