3 # Copyright (c) 2013 Aaron Ecay
6 test_description='test of proper handling of in-reply-to and references headers'
8 # This test makes sure that the thread structure in the notmuch
9 # database is constructed properly, even in the presence of
10 # non-RFC-compliant headers'
12 . $(dirname "$0")/test-lib.sh || exit 1
14 test_begin_subtest "Use References when In-Reply-To is broken"
15 add_message '[id]="foo@one.com"' \
17 add_message '[in-reply-to]="mumble"' \
18 '[references]="<foo@one.com>"' \
20 output=$(notmuch show --format=json 'subject:one' | notmuch_json_show_sanitize)
21 expected='[[[{"id": "foo@one.com",
24 "filename": ["YYYYY"],
25 "timestamp": 978709437,
26 "date_relative": "2001-01-05",
27 "tags": ["inbox", "unread"],
28 "headers": {"Subject": "one",
29 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
30 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
31 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
33 "content-type": "text/plain",
34 "content": "This is just a test message (#1)\n"}]},
35 [[{"id": "msg-002@notmuch-test-suite",
36 "match": true, "excluded": false,
37 "filename": ["YYYYY"],
38 "timestamp": 978709437, "date_relative": "2001-01-05",
39 "tags": ["inbox", "unread"], "headers": {"Subject": "Re: one",
40 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
41 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
42 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
43 "body": [{"id": 1, "content-type": "text/plain",
44 "content": "This is just a test message (#2)\n"}]}, []]]]]]'
45 expected=`echo "$expected" | notmuch_json_show_sanitize`
46 test_expect_equal_json "$output" "$expected"
48 test_begin_subtest "Prefer References to In-Reply-To"
49 add_message '[id]="foo@two.com"' \
51 add_message '[in-reply-to]="<bar@baz.com>"' \
52 '[references]="<foo@two.com>"' \
54 output=$(notmuch show --format=json 'subject:two' | notmuch_json_show_sanitize)
55 expected='[[[{"id": "foo@two.com",
56 "match": true, "excluded": false,
57 "filename": ["YYYYY"],
58 "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],
59 "headers": {"Subject": "two",
60 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
61 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
62 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
63 "body": [{"id": 1, "content-type": "text/plain",
64 "content": "This is just a test message (#3)\n"}]},
65 [[{"id": "msg-004@notmuch-test-suite", "match": true, "excluded": false,
66 "filename": ["YYYYY"],
67 "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],
68 "headers": {"Subject": "Re: two",
69 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
70 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
71 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
73 "content-type": "text/plain", "content": "This is just a test message (#4)\n"}]},
75 expected=`echo "$expected" | notmuch_json_show_sanitize`
76 test_expect_equal_json "$output" "$expected"
78 test_begin_subtest "Use In-Reply-To when no References"
79 add_message '[id]="foo@three.com"' \
81 add_message '[in-reply-to]="<foo@three.com>"' \
82 '[subject]="Re: three"'
83 output=$(notmuch show --format=json 'subject:three' | notmuch_json_show_sanitize)
84 expected='[[[{"id": "foo@three.com", "match": true, "excluded": false,
85 "filename": ["YYYYY"],
86 "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],
87 "headers": {"Subject": "three",
88 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
89 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
90 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,
91 "content-type": "text/plain", "content": "This is just a test message (#5)\n"}]},
92 [[{"id": "msg-006@notmuch-test-suite", "match": true, "excluded": false,
93 "filename": ["YYYYY"],
94 "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],
95 "headers": {"Subject": "Re: three",
96 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
97 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
98 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,
99 "content-type": "text/plain", "content": "This is just a test message (#6)\n"}]},
101 expected=`echo "$expected" | notmuch_json_show_sanitize`
102 test_expect_equal_json "$output" "$expected"
104 test_begin_subtest "Use last Reference"
105 add_message '[id]="foo@four.com"' \
107 add_message '[id]="bar@four.com"' \
108 '[subject]="not-four"'
109 add_message '[in-reply-to]="<baz@four.com>"' \
110 '[references]="<baz@four.com> <foo@four.com>"' \
111 '[subject]="neither"'
112 output=$(notmuch show --format=json 'subject:four' | notmuch_json_show_sanitize)
113 expected='[[[{"id": "foo@four.com", "match": true, "excluded": false,
114 "filename": ["YYYYY"],
115 "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],
116 "headers": {"Subject": "four",
117 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
118 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
119 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,
120 "content-type": "text/plain", "content": "This is just a test message (#7)\n"}]},
121 [[{"id": "msg-009@notmuch-test-suite", "match": false, "excluded": false,
122 "filename": ["YYYYY"],
123 "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],
124 "headers": {"Subject": "neither",
125 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
126 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
127 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,
128 "content-type": "text/plain", "content": "This is just a test message (#9)\n"}]},
129 []]]]], [[{"id": "bar@four.com", "match": true, "excluded": false,
130 "filename": ["YYYYY"],
131 "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],
132 "headers": {"Subject": "not-four",
133 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
134 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
135 "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,
136 "content-type": "text/plain", "content": "This is just a test message (#8)\n"}]}, []]]]'
137 expected=`echo "$expected" | notmuch_json_show_sanitize`
138 test_expect_equal_json "$output" "$expected"
140 test_begin_subtest "Ignore garbage at the end of References"
141 add_message '[id]="foo@five.com"' \
143 add_message '[id]="bar@five.com"' \
144 '[references]="<foo@five.com> (garbage)"' \
145 '[subject]="not-five"'
146 output=$(notmuch show --format=json 'subject:five' | notmuch_json_show_sanitize)
147 expected='[[[{"id": "XXXXX", "match": true, "excluded": false,
148 "filename": ["YYYYY"], "timestamp": 42, "date_relative": "2001-01-05",
149 "tags": ["inbox", "unread"], "headers": {"Subject": "five",
150 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
151 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
152 "Date": "GENERATED_DATE"}, "body": [{"id": 1,
153 "content-type": "text/plain",
154 "content": "This is just a test message (#10)\n"}]},
155 [[{"id": "XXXXX", "match": true, "excluded": false,
156 "filename": ["YYYYY"], "timestamp": 42, "date_relative": "2001-01-05",
157 "tags": ["inbox", "unread"],
158 "headers": {"Subject": "not-five",
159 "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
160 "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
161 "Date": "GENERATED_DATE"},
162 "body": [{"id": 1, "content-type": "text/plain",
163 "content": "This is just a test message (#11)\n"}]}, []]]]]]'
164 expected=`echo "$expected" | notmuch_json_show_sanitize`
165 test_expect_equal_json "$output" "$expected"
167 add_email_corpus threading
169 test_begin_subtest "reply to ghost"
170 test_subtest_known_broken
171 notmuch show --entire-thread=true id:000-real-root@example.org | grep ^Subject: | head -1 > OUTPUT
173 Subject: root message
175 test_expect_equal_file EXPECTED OUTPUT
177 test_begin_subtest "reply to ghost (tree view)"
178 test_subtest_known_broken
179 test_emacs '(notmuch-tree "id:000-real-root@example.org")
182 (delete-other-windows)'
184 2016-06-17 Alice ┬►root message (inbox unread)
185 2016-06-18 Alice ╰┬►child message (inbox unread)
186 2016-06-17 Mallory ├─►fake root message (inbox unread)
187 2016-06-18 Alice ├┬►grand-child message (inbox unread)
188 2016-06-18 Alice │╰─►great grand-child message (inbox unread)
189 2016-06-18 Daniel ╰─►grand-child message 2 (inbox unread)
190 End of search results.
192 test_expect_equal_file EXPECTED OUTPUT
194 test_begin_subtest "reply to ghost (RT)"
195 notmuch show --entire-thread=true id:87bmc6lp3h.fsf@len.workgroup | grep ^Subject: | head -1 > OUTPUT
197 Subject: FYI: xxxx xxxxxxx xxxxxxxxxxxx xxx
199 test_expect_equal_file EXPECTED OUTPUT
201 test_begin_subtest "reply to ghost (RT/tree view)"
202 test_emacs '(notmuch-tree "id:87bmc6lp3h.fsf@len.workgroup")
205 (delete-other-windows)'
207 2016-06-19 Gregor Zattler ┬┬►FYI: xxxx xxxxxxx xxxxxxxxxxxx xxx (inbox unread)
208 2016-06-19 via RT │╰─►[support.xxxxxxxxxxx-xxxxxxxxx-xxxxxxxxx.de #33575] AutoReply: FYI: xxxx xxxxxxx xxxxxxxxxxxx xxx (inbox unread)
209 2016-06-26 via RT ╰─►[support.xxxxxxxxxxx-xxxxxxxxx-xxxxxxxxx.de #33575] Resolved: FYI: xxxx xxxxxxx xxxxxxxxxxxx xxx (inbox unread)
210 End of search results.
212 test_expect_equal_file EXPECTED OUTPUT