unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 40f0bc222ecc7f1d023bcbb48360653d6a359e55 5747 bytes (raw)
name: test/T760-implicit-operators.sh 	 # 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
 
#!/usr/bin/env bash
test_description='implicit operators in query parser'
. $(dirname "$0")/test-lib.sh || exit 1

# test expected behaviour for probabilistic fields

test_prob() {
    add_message  "[id]=$1@one [$1]='Alice <agent@tla.galactic.over.lord>'"
    add_message  "[id]=$1@two [$1]='Bob <bungler@tla.galactic.over.lord>'"

    test_begin_subtest "phrase search for '$1': matches"
    notmuch search --output=messages id:$1@one > EXPECTED
    notmuch search --output=messages "$1:\"alice agent\"" > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT

    test_begin_subtest "out of order phrase '$1': does not match"
    notmuch search --output=messages "$1:\"agent alice\"" > OUTPUT
    test_expect_equal_file /dev/null OUTPUT

    test_begin_subtest "field '$1' is implicit AND"
    $2
    notmuch search $1:agent and $1:tla > EXPECTED
    notmuch search $1:agent $1:tla > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT
}

# test expected behaviour for probabilistic fields that also support
# regex search

test_prob_regex() {
    test_prob $1 $2

    test_begin_subtest "regex for '$1': matches"
    notmuch search --output=messages id:$1@one > EXPECTED
    notmuch search --output=messages "$1:/agent@tla/" > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT

    test_begin_subtest "regex wrong punctation for '$1': does not"
    notmuch search --output=messages "$1:/agent-tla/" > OUTPUT
    test_expect_equal_file /dev/null OUTPUT

    test_begin_subtest "regex for '$1' implicit AND"
    $2
    notmuch search --output=messages id:$1@one > EXPECTED
    notmuch search --output=messages $1:/agent/ $1:/tla/ > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT

    test_begin_subtest "subquery for '$1' implicit AND"
    $2
    notmuch search --output=messages id:$1@one > EXPECTED
    notmuch search --output=messages "$1:\"(agent alice)\"" > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT
}


# we have to test this separately because the quoting is sadly different
test_prob_not_regex() {
    test_prob $1

    test_begin_subtest "subquery for '$1' implicit AND"
    notmuch search --output=messages id:$1@one > EXPECTED
    notmuch search --output=messages "$1:(agent alice)" > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT
}

test_bool_exclusive () {
    add_message "[id]=$1@one [$2]=$1@one"
    add_message "[id]=$1@two [$2]=$1@two"

    test_begin_subtest "'$1' implicit OR"
    notmuch search --output=messages $1:$1@one OR $1:$1@two > EXPECTED
    notmuch search --output=messages $1:$1@one $1:$1@two > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT
}

test_bool_exclusive_regex () {
    test_bool_exclusive $1 $2

    test_begin_subtest "regex '$1' implicit OR"
    notmuch search --output=messages $1:$1@one OR $1:$1@two > EXPECTED
    notmuch search --output=messages $1:/^$1@one/ $1:/^$1@two/ > OUTPUT
    test_expect_equal_file EXPECTED OUTPUT
}

add_email_corpus

test_prob_not_regex to
test_prob_not_regex body
test_prob_regex from test_subtest_known_broken
test_prob_regex subject test_subtest_known_broken

test_bool_exclusive id id
test_bool_exclusive_regex mid id
test_bool_exclusive_regex path dir
test_bool_exclusive folder dir

add_message "[id]=aug@2019 [date]='Sat, 31 Aug 2019 01:14:40 -0400'"
add_message "[id]=may@2014 [date]='Thu, 22 May 2014 11:45:01 -0700'"
test_begin_subtest "'date' is implicit OR"
notmuch search --output=messages date:2019 OR date:2014 > EXPECTED
notmuch search --output=messages date:2019 date:2014 > OUTPUT
test_expect_equal_file EXPECTED OUTPUT

add_message "[id]=tag@one"
add_message "[id]=tag@two"
notmuch tag +one id:tag@one
notmuch tag +two id:tag@two

test_begin_subtest "'tag' is implicit AND"
test_subtest_known_broken
notmuch search --output=messages tag:one tag:two > OUTPUT
test_expect_equal_file /dev/null OUTPUT

test_begin_subtest "'thread:<thread-id>' is implicit OR"
notmuch search --output=messages thread:0000000000000001 OR thread:0000000000000002 > EXPECTED
notmuch search --output=messages thread:0000000000000001 thread:0000000000000002 > OUTPUT
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "sanity check for non-zero output"
test_expect_success "test -s OUTPUT"

test_begin_subtest "'mimetype' is implicit AND"
notmuch search --output=messages mimetype:application/pgp-signature AND \
        mimetype:multipart/signed > EXPECTED
notmuch search --output=messages mimetype:application/pgp-signature \
        mimetype:multipart/signed > OUTPUT
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "sanity check for non-zero output"
test_expect_success "test -s OUTPUT"

test_begin_subtest "'mimetype' is implicit AND (II)"
notmuch search --output=messages is:signed > EXPECTED
notmuch search --output=messages mimetype:application/pgp-signature  mimetype:multipart/signed > OUTPUT
test_expect_equal_file EXPECTED OUTPUT

test_begin_subtest "'attachment' with OR is non-empty"
notmuch search --output=messages attachment:notmuch-help.patch \
        OR attachment:signature.asc > OUTPUT
test_expect_success "test -s OUTPUT"

test_begin_subtest "'attachment' is implicit AND"
notmuch search --output=messages attachment:notmuch-help.patch AND \
        attachment:signature.asc > OUTPUT
test_expect_equal_file /dev/null OUTPUT

test_begin_subtest "'folder' with OR is non-empty"
notmuch search --output=messages folder:bar/baz \
        folder:foo/baz > OUTPUT
test_expect_success "test -s OUTPUT"

test_begin_subtest "'folder' is implicit AND"
notmuch search --output=messages folder:bar/baz \
        attachment:signature.asc > OUTPUT
test_expect_equal_file /dev/null OUTPUT

test_begin_subtest "'lastmod' is implicit OR"
notmuch search lastmod:0..1 lastmod:2..1000 > OUTPUT
test_expect_success "test -s OUTPUT"

test_done

debug log:

solving 40f0bc22 ...
found 40f0bc22 in https://yhetil.org/notmuch/20190901013748.7470-3-david@tethera.net/

applying [1/1] https://yhetil.org/notmuch/20190901013748.7470-3-david@tethera.net/
diff --git a/test/T760-implicit-operators.sh b/test/T760-implicit-operators.sh
new file mode 100755
index 00000000..40f0bc22

Checking patch test/T760-implicit-operators.sh...
Applied patch test/T760-implicit-operators.sh cleanly.

index at:
100755 40f0bc222ecc7f1d023bcbb48360653d6a359e55	test/T760-implicit-operators.sh

(*) 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).