[PATCH 1/2] test: add have-man and have-compact in test/.gitignore
[notmuch-archives.git] / f5 / 13c93102f1b96a4fd1d5519bcc6c314049c6d4
1 Return-Path: <m.walters@qmul.ac.uk>\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 6435D431FBC\r
6         for <notmuch@notmuchmail.org>; Tue,  7 Aug 2012 15:44:04 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 Kbw41tkgR2V8 for <notmuch@notmuchmail.org>;\r
17         Tue,  7 Aug 2012 15:44:03 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 3E891431FAE\r
22         for <notmuch@notmuchmail.org>; Tue,  7 Aug 2012 15:44:03 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1SysVK-00047h-Hx; Tue, 07 Aug 2012 23:44:01 +0100\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1SysVK-0002rq-18; Tue, 07 Aug 2012 23:43:58 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
34 Subject: Re: [PATCH] test: Add test for messages with missing headers\r
35 In-Reply-To: <1344374501-28185-1-git-send-email-amdragon@mit.edu>\r
36 References: <1344374501-28185-1-git-send-email-amdragon@mit.edu>\r
37 User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1\r
38         (x86_64-pc-linux-gnu)\r
39 Date: Tue, 07 Aug 2012 23:43:51 +0100\r
40 Message-ID: <87ipcumifs.fsf@qmul.ac.uk>\r
41 MIME-Version: 1.0\r
42 Content-Type: text/plain; charset=us-ascii\r
43 X-Sender-Host-Address: 94.192.233.223\r
44 X-QM-SPAM-Info: Sender has good ham record.  :)\r
45 X-QM-Body-MD5: 164e43691eeaacaf685370cbfa71e8f3 (of first 20000 bytes)\r
46 X-SpamAssassin-Score: -1.8\r
47 X-SpamAssassin-SpamBar: -\r
48 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
49         determine if it is\r
50         spam. We require at least 5.0 points to mark a message as spam.\r
51         This message scored -1.8 points.\r
52         Summary of the scoring: \r
53         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
54         *      medium trust\r
55         *      [138.37.6.40 listed in list.dnswl.org]\r
56         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
57         provider *      (markwalters1009[at]gmail.com)\r
58         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
59         *      domain\r
60         *  0.5 AWL AWL: From: address is in the auto white-list\r
61 X-QM-Scan-Virus: ClamAV says the message is clean\r
62 X-BeenThere: notmuch@notmuchmail.org\r
63 X-Mailman-Version: 2.1.13\r
64 Precedence: list\r
65 List-Id: "Use and development of the notmuch mail system."\r
66         <notmuch.notmuchmail.org>\r
67 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
68         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
69 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
70 List-Post: <mailto:notmuch@notmuchmail.org>\r
71 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
72 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
73         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
74 X-List-Received-Date: Tue, 07 Aug 2012 22:44:04 -0000\r
75 \r
76 \r
77 Hi \r
78 \r
79 This generally looks good but there is a bug in the test from a\r
80 hardcoded /tmp/ path (see below). And as confirmation with the patch in\r
81 id:"874noe1o0r.fsf@qmul.ac.uk" the tests (modulo the test bug) pass.\r
82 \r
83 On Tue, 07 Aug 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
84 > Currently the JSON tests for search and show are broken because\r
85 > notmuch attempts to dereference a NULL pointer.\r
86 > ---\r
87 > Things to bikeshed:\r
88 >\r
89 > * Should we include From and Subject in the headers object when there\r
90 >   are no from or subject headers?  Currently the schema says that\r
91 >   everything but those two and "Date" is optional (indeed, "To" is\r
92 >   missing from the second message) but that was just post facto\r
93 >   standardization.\r
94 \r
95 I think Date and From are compulsory in an email but the others are not\r
96 (but I am unsure which Date and which From so that may be unhelpful).\r
97 If I am correct it might be sensible to always include those two.\r
98 \r
99 > * How should we format expected JSON in the test suite, now that we\r
100 >   can format it however we want?  Here I've just pasted in the result\r
101 >   of python -mjson.tool.  While that was very easy and the result is\r
102 >   quite readable, it's the antithesis of compact and the keys have\r
103 >   been alphabetized.\r
104 \r
105 I like this: making the tests readable is a big plus.\r
106 \r
107 >  test/missing-headers |  162 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
108 >  test/notmuch-test    |    1 +\r
109 >  2 files changed, 163 insertions(+)\r
110 >  create mode 100755 test/missing-headers\r
111 >\r
112 > diff --git a/test/missing-headers b/test/missing-headers\r
113 > new file mode 100755\r
114 > index 0000000..744c04e\r
115 > --- /dev/null\r
116 > +++ b/test/missing-headers\r
117 > @@ -0,0 +1,162 @@\r
118 > +#!/usr/bin/env bash\r
119 > +test_description='messages with missing headers'\r
120 > +. ./test-lib.sh\r
121 > +\r
122 > +# Notmuch requires at least one of from, subject, or to or it will\r
123 > +# ignore the file.  Generate two messages so that together they cover\r
124 > +# all possible missing headers.  We also give one of the messages a\r
125 > +# date to ensure stable result ordering.\r
126 > +\r
127 > +cat <<EOF > "${MAIL_DIR}/msg-2"\r
128 > +To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
129 > +Date: Fri, 05 Jan 2001 15:43:57 +0000\r
130 > +\r
131 > +Body\r
132 > +EOF\r
133 > +\r
134 > +cat <<EOF > "${MAIL_DIR}/msg-1"\r
135 > +From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
136 > +\r
137 > +Body\r
138 > +EOF\r
139 > +\r
140 > +NOTMUCH_NEW\r
141 > +\r
142 > +test_begin_subtest "Search: text"\r
143 > +output=$(notmuch search '*' | notmuch_search_sanitize)\r
144 > +test_expect_equal "$output" "\\r
145 > +thread:XXX   2001-01-05 [1/1] (null);  (inbox unread)\r
146 > +thread:XXX   1970-01-01 [1/1] Notmuch Test Suite;  (inbox unread)"\r
147 > +\r
148 > +test_begin_subtest "Search: json"\r
149 > +test_subtest_known_broken\r
150 > +output=$(notmuch search --format=json '*' | notmuch_search_sanitize)\r
151 > +test_expect_equal_json "$output" '\r
152 > +[\r
153 > +    {\r
154 > +        "authors": "",\r
155 > +        "date_relative": "2001-01-05",\r
156 > +        "matched": 1,\r
157 > +        "subject": "",\r
158 > +        "tags": [\r
159 > +            "inbox",\r
160 > +            "unread"\r
161 > +        ],\r
162 > +        "thread": "XXX",\r
163 > +        "timestamp": 978709437,\r
164 > +        "total": 1\r
165 > +    },\r
166 > +    {\r
167 > +        "authors": "Notmuch Test Suite",\r
168 > +        "date_relative": "1970-01-01",\r
169 > +        "matched": 1,\r
170 > +        "subject": "",\r
171 > +        "tags": [\r
172 > +            "inbox",\r
173 > +            "unread"\r
174 > +        ],\r
175 > +        "thread": "XXX",\r
176 > +        "timestamp": 0,\r
177 > +        "total": 1\r
178 > +    }\r
179 > +]'\r
180 > +\r
181 > +test_begin_subtest "Show: text"\r
182 > +output=$(notmuch show '*')\r
183 > +test_expect_equal "$output" "\\r
184 > +\f\r
185 message{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/tmp/nmtest/tmp.missing-headers/mail/msg-2\r
186 \r
187 The filename above has not been sanitised so contains your tmp path.\r
188 \r
189 Best wishes\r
190 \r
191 Mark\r
192 \r
193 > +\f\r
194 header{\r
195 > + (2001-01-05) (inbox unread)\r
196 > +Subject: (null)\r
197 > +From: (null)\r
198 > +To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
199 > +Date: Fri, 05 Jan 2001 15:43:57 +0000\r
200 > +\f\r
201 header}\r
202 > +\f\r
203 body{\r
204 > +\f\r
205 part{ ID: 1, Content-type: text/plain\r
206 > +Body\r
207 > +\f\r
208 part}\r
209 > +\f\r
210 body}\r
211 > +\f\r
212 message}\r
213 > +\f\r
214 message{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/tmp/nmtest/tmp.missing-headers/mail/msg-1\r
215 > +\f\r
216 header{\r
217 > +Notmuch Test Suite <test_suite@notmuchmail.org> (1970-01-01) (inbox unread)\r
218 > +Subject: (null)\r
219 > +From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
220 > +Date: Thu, 01 Jan 1970 00:00:00 +0000\r
221 > +\f\r
222 header}\r
223 > +\f\r
224 body{\r
225 > +\f\r
226 part{ ID: 1, Content-type: text/plain\r
227 > +Body\r
228 > +\f\r
229 part}\r
230 > +\f\r
231 body}\r
232 > +\f\r
233 message}"\r
234 > +\r
235 > +test_begin_subtest "Show: json"\r
236 > +test_subtest_known_broken\r
237 > +output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize)\r
238 > +test_expect_equal_json "$output" '\r
239 > +[\r
240 > +    [\r
241 > +        [\r
242 > +            {\r
243 > +                "body": [\r
244 > +                    {\r
245 > +                        "content": "Body\n",\r
246 > +                        "content-type": "text/plain",\r
247 > +                        "id": 1\r
248 > +                    }\r
249 > +                ],\r
250 > +                "date_relative": "2001-01-05",\r
251 > +                "excluded": false,\r
252 > +                "filename": "YYYYY",\r
253 > +                "headers": {\r
254 > +                    "Date": "Fri, 05 Jan 2001 15:43:57 +0000",\r
255 > +                    "From": "",\r
256 > +                    "Subject": "",\r
257 > +                    "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"\r
258 > +                },\r
259 > +                "id": "XXXXX",\r
260 > +                "match": true,\r
261 > +                "tags": [\r
262 > +                    "inbox",\r
263 > +                    "unread"\r
264 > +                ],\r
265 > +                "timestamp": 978709437\r
266 > +            },\r
267 > +            []\r
268 > +        ]\r
269 > +    ],\r
270 > +    [\r
271 > +        [\r
272 > +            {\r
273 > +                "body": [\r
274 > +                    {\r
275 > +                        "content": "Body\n",\r
276 > +                        "content-type": "text/plain",\r
277 > +                        "id": 1\r
278 > +                    }\r
279 > +                ],\r
280 > +                "date_relative": "1970-01-01",\r
281 > +                "excluded": false,\r
282 > +                "filename": "YYYYY",\r
283 > +                "headers": {\r
284 > +                    "Date": "Thu, 01 Jan 1970 00:00:00 +0000",\r
285 > +                    "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
286 > +                    "Subject": ""\r
287 > +                },\r
288 > +                "id": "XXXXX",\r
289 > +                "match": true,\r
290 > +                "tags": [\r
291 > +                    "inbox",\r
292 > +                    "unread"\r
293 > +                ],\r
294 > +                "timestamp": 0\r
295 > +            },\r
296 > +            []\r
297 > +        ]\r
298 > +    ]\r
299 > +]'\r
300 > +\r
301 > +\r
302 > +test_done\r
303 > diff --git a/test/notmuch-test b/test/notmuch-test\r
304 > index ea39dfc..cc732c3 100755\r
305 > --- a/test/notmuch-test\r
306 > +++ b/test/notmuch-test\r
307 > @@ -59,6 +59,7 @@ TESTS="\r
308 >    emacs-address-cleaning\r
309 >    emacs-hello\r
310 >    emacs-show\r
311 > +  missing-headers\r
312 >  "\r
313 >  TESTS=${NOTMUCH_TESTS:=$TESTS}\r
314 >  \r
315 > -- \r
316 > 1.7.10\r
317 >\r
318 > _______________________________________________\r
319 > notmuch mailing list\r
320 > notmuch@notmuchmail.org\r
321 > http://notmuchmail.org/mailman/listinfo/notmuch\r