2 test_description='indexing user specified headers'
3 . $(dirname "$0")/test-lib.sh || exit 1
7 notmuch search '*' 2>1 | notmuch_search_sanitize > initial-threads
8 notmuch search --output=messages '*' 2>/dev/null > initial-message-ids
9 notmuch dump > initial-dump
11 test_begin_subtest "adding illegal prefix name, bad utf8"
12 notmuch config set index.header.$'\xFF' "List-Id" 2>&1 | sed 's/:.*$//' >OUTPUT
16 test_expect_equal_file EXPECTED OUTPUT
18 test_begin_subtest "adding illegal prefix name, reserved for notmuch"
19 notmuch config set index.header.list "List-Id" 2>OUTPUT
21 Prefix names starting with lower case letters are reserved: list
23 test_expect_equal_file EXPECTED OUTPUT
25 test_begin_subtest "adding illegal prefix name, non-word character."
26 notmuch config set index.header.l:st "List-Id" 2>OUTPUT
28 Non-word character in prefix name: l:st
30 test_expect_equal_file EXPECTED OUTPUT
32 test_begin_subtest "adding empty prefix name."
33 notmuch config set index.header. "List-Id" 2>OUTPUT
34 Non-word character in prefix name: l:st
36 Empty prefix name: index.header.
38 test_expect_equal_file EXPECTED OUTPUT
41 test_begin_subtest "adding user header"
42 test_expect_code 0 "notmuch config set index.header.List \"List-Id\""
44 test_begin_subtest "adding existing user header"
45 test_expect_code 0 "notmuch config set index.header.List \"List-Id\""
48 test_begin_subtest "retrieve user header"
49 output=$(notmuch config get index.header.List)
50 test_expect_equal "List-Id" "$output"
52 test_begin_subtest 'reindex after adding header preserves threads'
54 notmuch search '*' | notmuch_search_sanitize > OUTPUT
55 test_expect_equal_file initial-threads OUTPUT
57 test_begin_subtest "List all user headers"
58 notmuch config set index.header.Spam "X-Spam"
59 notmuch config list | grep ^index.header | notmuch_config_sanitize > OUTPUT
61 index.header.List=List-Id
62 index.header.Spam=X-Spam
64 test_expect_equal_file EXPECTED OUTPUT
66 test_begin_subtest "parse user prefix"
67 NOTMUCH_DEBUG_QUERY=t notmuch count 'List:"notmuch"' 2>&1 | grep Tmail >OUTPUT
69 Query((Tmail AND XUList:notmuch@1))
71 test_expect_equal_file EXPECTED OUTPUT
73 test_begin_subtest "parse user prefix, stemmed"
74 NOTMUCH_DEBUG_QUERY=t notmuch count 'List:notmuch' 2>&1 | grep Tmail >OUTPUT
76 Query((Tmail AND ZXUList:notmuch@1))
78 test_expect_equal_file EXPECTED OUTPUT
80 test_begin_subtest "parse user prefix, phrase"
81 NOTMUCH_DEBUG_QUERY=t notmuch count 'List:notmuchmail.org' 2>&1 | grep Tmail >OUTPUT
83 Query((Tmail AND (XUList:notmuchmail@1 PHRASE 2 XUList:org@2)))
85 test_expect_equal_file EXPECTED OUTPUT
87 test_begin_subtest "index user header"
88 notmuch config set index.header.List "List-Id"
90 notmuch search --output=files List:notmuch | notmuch_search_files_sanitize | sort > OUTPUT
92 MAIL_DIR/bar/baz/05:2,
93 MAIL_DIR/bar/baz/23:2,
94 MAIL_DIR/bar/baz/24:2,
95 MAIL_DIR/bar/cur/20:2,
96 MAIL_DIR/bar/new/21:2,
97 MAIL_DIR/bar/new/22:2,
98 MAIL_DIR/foo/cur/08:2,
99 MAIL_DIR/foo/new/03:2,
102 test_expect_equal_file EXPECTED OUTPUT
104 test_begin_subtest "index user header, config from file"
106 printf "\n[index]\nheader.${field_name} = List-Id\n" >> notmuch-config
108 notmuch search --output=files ${field_name}:notmuch | notmuch_search_files_sanitize | sort > OUTPUT
110 MAIL_DIR/bar/baz/05:2,
111 MAIL_DIR/bar/baz/23:2,
112 MAIL_DIR/bar/baz/24:2,
113 MAIL_DIR/bar/cur/20:2,
114 MAIL_DIR/bar/new/21:2,
115 MAIL_DIR/bar/new/22:2,
116 MAIL_DIR/foo/cur/08:2,
117 MAIL_DIR/foo/new/03:2,
120 test_expect_equal_file EXPECTED OUTPUT