Re: Hi all
[notmuch-archives.git] / 4e / aa216229c65d3b45d4b81e1771f928d5571bde
1 Return-Path: <aaronecay@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 40539431FBC\r
6         for <notmuch@notmuchmail.org>; Tue,  5 Mar 2013 19:32:01 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id tXGYDyFlBrz9 for <notmuch@notmuchmail.org>;\r
17         Tue,  5 Mar 2013 19:31:59 -0800 (PST)\r
18 Received: from mail-qa0-f43.google.com (mail-qa0-f43.google.com\r
19         [209.85.216.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 9774E431FAE\r
22         for <notmuch@notmuchmail.org>; Tue,  5 Mar 2013 19:31:59 -0800 (PST)\r
23 Received: by mail-qa0-f43.google.com with SMTP id dx4so2300278qab.2\r
24         for <notmuch@notmuchmail.org>; Tue, 05 Mar 2013 19:31:58 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to\r
27         :references; bh=7Fjy/phaQvApWnaMV/LrIDhOl0qhFLxzPkDvb4m0qQo=;\r
28         b=YfcugJB4GC4VOlcsZsFXh6HgWpr0uiz2U3g6jn2OCyC8AqmQvKfVtqEPykCWN1mSTr\r
29         LuUo4WObXoD+TCsrClST7l2zqAZuL35wEwVcFfL3HwjW7QUTv2g+qQoDa0ySJC4RuqJl\r
30         Ui6GDYWypt72g6DKm6Nln91dM/wqDoDtR69mnmHzkr0C1jf+FKFqn18OqXkZY4ZpHyd2\r
31         Qh5zh4iSrTAD/o2/6LuF+zo4Mza6H6RbNkzUX8Emn38CkN9z6d7lAOTZCtSyZ8ihD2iy\r
32         cdL5kHOERhLDtJMsFa22bXMyCC+GtUdikroKZljwGdYZqg9G0oPGHdkBxl8x+bWu+zAA\r
33         NbLQ==\r
34 X-Received: by 10.224.31.203 with SMTP id z11mr43213942qac.56.1362540717929;\r
35         Tue, 05 Mar 2013 19:31:57 -0800 (PST)\r
36 Received: from haize.hsd1.pa.comcast.net (c-68-80-94-73.hsd1.pa.comcast.net.\r
37         [68.80.94.73])\r
38         by mx.google.com with ESMTPS id q5sm46570133qaz.2.2013.03.05.19.31.57\r
39         (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128);\r
40         Tue, 05 Mar 2013 19:31:57 -0800 (PST)\r
41 From: Aaron Ecay <aaronecay@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH 1/2] test: add tests for the handling of References and\r
44         In-Reply-To headers\r
45 Date: Tue,  5 Mar 2013 22:31:48 -0500\r
46 Message-Id: <1362540709-28765-1-git-send-email-aaronecay@gmail.com>\r
47 X-Mailer: git-send-email 1.8.1.5\r
48 In-Reply-To: <87ppzfzxuk.fsf@zancas.localnet>\r
49 References: <87ppzfzxuk.fsf@zancas.localnet>\r
50 X-BeenThere: notmuch@notmuchmail.org\r
51 X-Mailman-Version: 2.1.13\r
52 Precedence: list\r
53 List-Id: "Use and development of the notmuch mail system."\r
54         <notmuch.notmuchmail.org>\r
55 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
56         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
57 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
58 List-Post: <mailto:notmuch@notmuchmail.org>\r
59 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
60 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
61         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
62 X-List-Received-Date: Wed, 06 Mar 2013 03:32:01 -0000\r
63 \r
64 These tests are known_broken, the following commit fixes them.\r
65 ---\r
66 \r
67 Thanks to David and Tomi for pointing out test_expect_equal_json.  In\r
68 the process of implementing that, I discovered\r
69 notmuch_json_show_sanitize, which I had also not been using.  This\r
70 patch fixes the test to use both these conveniences.  The second patch\r
71 is not changed substantively, but I am resending it for tidiness.\r
72 \r
73  test/thread-replies | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
74  1 file changed, 144 insertions(+)\r
75  create mode 100755 test/thread-replies\r
76 \r
77 diff --git a/test/thread-replies b/test/thread-replies\r
78 new file mode 100755\r
79 index 0000000..a902691\r
80 --- /dev/null\r
81 +++ b/test/thread-replies\r
82 @@ -0,0 +1,144 @@\r
83 +#!/usr/bin/env bash\r
84 +#\r
85 +# Copyright (c) 2013 Aaron Ecay\r
86 +#\r
87 +\r
88 +test_description='test of proper handling of in-reply-to and references headers\r
89 +\r
90 +This test makes sure that the thread structure in the notmuch database is\r
91 +constructed properly, even in the presence of non-RFC-compliant headers'\r
92 +\r
93 +. ./test-lib.sh\r
94 +\r
95 +test_begin_subtest "Use References when In-Reply-To is broken"\r
96 +test_subtest_known_broken\r
97 +add_message '[id]="foo@one.com"' \\r
98 +    '[subject]=one'\r
99 +add_message '[in-reply-to]="mumble"' \\r
100 +    '[references]="<foo@one.com>"' \\r
101 +    '[subject]="Re: one"'\r
102 +output=$(notmuch show --format=json 'subject:one' | notmuch_json_show_sanitize)\r
103 +expected='[[[{"id": "foo@one.com",\r
104 + "match": true,\r
105 + "excluded": false,\r
106 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-001",\r
107 + "timestamp": 978709437,\r
108 + "date_relative": "2001-01-05",\r
109 + "tags": ["inbox", "unread"],\r
110 + "headers": {"Subject": "one",\r
111 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
112 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
113 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
114 + "body": [{"id": 1,\r
115 + "content-type": "text/plain",\r
116 + "content": "This is just a test message (#1)\n"}]},\r
117 + [[{"id": "msg-002@notmuch-test-suite",\r
118 + "match": true, "excluded": false,\r
119 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-002",\r
120 + "timestamp": 978709437, "date_relative": "2001-01-05",\r
121 + "tags": ["inbox", "unread"], "headers": {"Subject": "Re: one",\r
122 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
123 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
124 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
125 + "body": [{"id": 1, "content-type": "text/plain",\r
126 + "content": "This is just a test message (#2)\n"}]}, []]]]]]'\r
127 +expected=`echo "$expected" | notmuch_json_show_sanitize`\r
128 +test_expect_equal_json "$output" "$expected"\r
129 +\r
130 +test_begin_subtest "Prefer References to In-Reply-To"\r
131 +test_subtest_known_broken\r
132 +add_message '[id]="foo@two.com"' \\r
133 +    '[subject]=two'\r
134 +add_message '[in-reply-to]="<bar@baz.com>"' \\r
135 +    '[references]="<foo@two.com>"' \\r
136 +    '[subject]="Re: two"'\r
137 +output=$(notmuch show --format=json 'subject:two' | notmuch_json_show_sanitize)\r
138 +expected='[[[{"id": "foo@two.com",\r
139 + "match": true, "excluded": false,\r
140 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-003",\r
141 + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
142 + "headers": {"Subject": "two",\r
143 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
144 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
145 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
146 + "body": [{"id": 1, "content-type": "text/plain",\r
147 + "content": "This is just a test message (#3)\n"}]},\r
148 + [[{"id": "msg-004@notmuch-test-suite", "match": true, "excluded": false,\r
149 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-004",\r
150 + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
151 + "headers": {"Subject": "Re: two",\r
152 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
153 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
154 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
155 + "body": [{"id": 1,\r
156 + "content-type": "text/plain", "content": "This is just a test message (#4)\n"}]},\r
157 + []]]]]]'\r
158 +expected=`echo "$expected" | notmuch_json_show_sanitize`\r
159 +test_expect_equal_json "$output" "$expected"\r
160 +\r
161 +test_begin_subtest "Use In-Reply-To when no References"\r
162 +test_subtest_known_broken\r
163 +add_message '[id]="foo@three.com"' \\r
164 +    '[subject]="three"'\r
165 +add_message '[in-reply-to]="<foo@three.com>"' \\r
166 +    '[subject]="Re: three"'\r
167 +output=$(notmuch show --format=json 'subject:three' | notmuch_json_show_sanitize)\r
168 +expected='[[[{"id": "foo@three.com", "match": true, "excluded": false,\r
169 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-005",\r
170 + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
171 + "headers": {"Subject": "three",\r
172 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
173 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
174 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
175 + "content-type": "text/plain", "content": "This is just a test message (#5)\n"}]},\r
176 + [[{"id": "msg-006@notmuch-test-suite", "match": true, "excluded": false,\r
177 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-006",\r
178 + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
179 + "headers": {"Subject": "Re: three",\r
180 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
181 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
182 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
183 + "content-type": "text/plain", "content": "This is just a test message (#6)\n"}]},\r
184 + []]]]]]'\r
185 +expected=`echo "$expected" | notmuch_json_show_sanitize`\r
186 +test_expect_equal_json "$output" "$expected"\r
187 +\r
188 +test_begin_subtest "Use last Reference"\r
189 +test_subtest_known_broken\r
190 +add_message '[id]="foo@four.com"' \\r
191 +    '[subject]="four"'\r
192 +add_message '[id]="bar@four.com"' \\r
193 +    '[subject]="not-four"'\r
194 +add_message '[in-reply-to]="<baz@four.com>"' \\r
195 +    '[references]="<baz@four.com> <foo@four.com>"' \\r
196 +    '[subject]="neither"'\r
197 +output=$(notmuch show --format=json 'subject:four' | notmuch_json_show_sanitize)\r
198 +expected='[[[{"id": "foo@four.com", "match": true, "excluded": false,\r
199 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-007",\r
200 + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
201 + "headers": {"Subject": "four",\r
202 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
203 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
204 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
205 + "content-type": "text/plain", "content": "This is just a test message (#7)\n"}]},\r
206 + [[{"id": "msg-009@notmuch-test-suite", "match": false, "excluded": false,\r
207 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-009",\r
208 + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
209 + "headers": {"Subject": "neither",\r
210 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
211 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
212 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
213 + "content-type": "text/plain", "content": "This is just a test message (#9)\n"}]},\r
214 + []]]]], [[{"id": "bar@four.com", "match": true, "excluded": false,\r
215 + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-008",\r
216 + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
217 + "headers": {"Subject": "not-four",\r
218 + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
219 + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
220 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
221 + "content-type": "text/plain", "content": "This is just a test message (#8)\n"}]}, []]]]'\r
222 +expected=`echo "$expected" | notmuch_json_show_sanitize`\r
223 +test_expect_equal_json "$output" "$expected"\r
224 +\r
225 +\r
226 +test_done\r
227 -- \r
228 1.8.1.5\r
229 \r