unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 744567f2e2a26871831ddcf24e2b3930475ab7e9 3317 bytes (raw)
name: test/T760-as-text.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
 
#!/usr/bin/env bash
test_description='index attachments as text'
. $(dirname "$0")/test-lib.sh || exit 1

add_email_corpus indexing
test_begin_subtest "empty as_text; skip text/x-diff"
messages=$(notmuch count id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain)
count=$(notmuch count id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and ersatz)
test_expect_equal "$messages,$count" "1,0"

notmuch config set index.as_text "^text/"
add_email_corpus indexing

test_begin_subtest "as_index is text/; find text/x-diff"
notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain > EXPECTED
notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and ersatz > OUTPUT
test_expect_equal_file_nonempty EXPECTED OUTPUT

test_begin_subtest "reindex with empty as_text, skips text/x-diff"
notmuch config set index.as_text
notmuch reindex '*'
messages=$(notmuch count id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain)
count=$(notmuch count id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and ersatz)
test_expect_equal "$messages,$count" "1,0"

test_begin_subtest "reindex with empty as_text; skips application/pdf"
notmuch config set index.as_text
notmuch reindex '*'
gmessages=$(notmuch count id:871qo9p4tf.fsf@tethera.net)
count=$(notmuch count id:871qo9p4tf.fsf@tethera.net and body:not-really-PDF)
test_expect_equal "$messages,$count" "1,0"

test_begin_subtest "reindex with as_text as text/; finds text/x-diff"
notmuch config set index.as_text "^text/"
notmuch reindex '*'
notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain > EXPECTED
notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and ersatz > OUTPUT
test_expect_equal_file_nonempty EXPECTED OUTPUT

test_begin_subtest "reindex with as_text as text/; skips application/pdf"
notmuch config set index.as_text "^text/"
notmuch config set index.as_text
notmuch reindex '*'
messages=$(notmuch count id:871qo9p4tf.fsf@tethera.net)
count=$(notmuch count id:871qo9p4tf.fsf@tethera.net and body:not-really-PDF)
test_expect_equal "$messages,$count" "1,0"

test_begin_subtest "as_text has multiple regexes"
notmuch config set index.as_text "blahblah;^text/"
notmuch reindex '*'
notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain > EXPECTED
notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and ersatz > OUTPUT
test_expect_equal_file_nonempty EXPECTED OUTPUT

test_begin_subtest "as_text is non-anchored regex"
notmuch config set index.as_text "e.t/"
notmuch reindex '*'
notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain > EXPECTED
notmuch search id:20200930101213.2m2pt3jrspvcrxfx@localhost.localdomain and ersatz > OUTPUT
test_expect_equal_file_nonempty EXPECTED OUTPUT

test_begin_subtest "as_text is 'application/pdf'"
notmuch config set index.as_text "^application/pdf$"
notmuch reindex '*'
notmuch search id:871qo9p4tf.fsf@tethera.net > EXPECTED
notmuch search id:871qo9p4tf.fsf@tethera.net and '"not really PDF"' > OUTPUT
test_expect_equal_file_nonempty EXPECTED OUTPUT

test_begin_subtest "as_text is bad regex"
notmuch config set index.as_text '['
notmuch reindex '*' >& OUTPUT
cat<<EOF > EXPECTED
Error in index.as_text: Invalid regular expression: [
EOF
test_expect_equal_file EXPECTED OUTPUT

test_done

debug log:

solving 744567f2 ...
found 744567f2 in https://yhetil.org/notmuch.git/

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