1 Return-Path: <tomi.ollila@iki.fi>
\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 1877F431FBD
\r
6 for <notmuch@notmuchmail.org>; Wed, 8 Aug 2012 11:47:43 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id RJlYXhFsvrvo for <notmuch@notmuchmail.org>;
\r
16 Wed, 8 Aug 2012 11:47:41 -0700 (PDT)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 6B127431FAE
\r
19 for <notmuch@notmuchmail.org>; Wed, 8 Aug 2012 11:47:41 -0700 (PDT)
\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)
\r
21 id E59CD1002A4; Wed, 8 Aug 2012 21:47:49 +0300 (EEST)
\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
23 To: Austin Clements <amdragon@MIT.EDU>
\r
24 Subject: Re: [PATCH v2] test: Add test for messages with missing headers
\r
25 In-Reply-To: <20120808154608.GD11179@mit.edu>
\r
26 References: <1344374501-28185-1-git-send-email-amdragon@mit.edu>
\r
27 <1344389313-7886-1-git-send-email-amdragon@mit.edu>
\r
28 <m2k3x9olfl.fsf@guru.guru-group.fi>
\r
29 <20120808154608.GD11179@mit.edu>
\r
30 User-Agent: Notmuch/0.13.2+128~g07453d8 (http://notmuchmail.org) Emacs/23.1.1
\r
31 (x86_64-redhat-linux-gnu)
\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
33 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
34 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
35 Date: Wed, 08 Aug 2012 21:47:49 +0300
\r
36 Message-ID: <m2ehnhfcfe.fsf@guru.guru-group.fi>
\r
38 Content-Type: text/plain; charset=us-ascii
\r
39 Cc: notmuch@notmuchmail.org
\r
40 X-BeenThere: notmuch@notmuchmail.org
\r
41 X-Mailman-Version: 2.1.13
\r
43 List-Id: "Use and development of the notmuch mail system."
\r
44 <notmuch.notmuchmail.org>
\r
45 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
46 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
47 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
48 List-Post: <mailto:notmuch@notmuchmail.org>
\r
49 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
50 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
51 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
52 X-List-Received-Date: Wed, 08 Aug 2012 18:47:43 -0000
\r
54 On Wed, Aug 08 2012, Austin Clements <amdragon@MIT.EDU> wrote:
\r
56 > Quoth Tomi Ollila on Aug 08 at 11:08 am:
\r
57 >> On Wed, Aug 08 2012, Austin Clements <amdragon@MIT.EDU> wrote:
\r
59 >> > Currently the JSON tests for search and show are broken because
\r
60 >> > notmuch attempts to dereference a NULL pointer.
\r
62 >> > This version fixes the "Show: text" test so that it sanitize its
\r
63 >> > output and doesn't hard-code my test paths.
\r
69 >> w/ python json(.tool) the original order cannot be preserved as the parser
\r
70 >> stores content into dictionary -- without sorting those came in some
\r
71 >> internal python order... the following code could be used to use less
\r
73 > To be fair, it can output them in original order, but doing so
\r
74 > requires Python 2.7:
\r
76 > python -c 'import sys,json,collections; json.dump(json.load(sys.stdin,
\r
77 > object_pairs_hook=collections.OrderedDict), sys.stdout, indent=4)'
\r
82 >> indentation, though:
\r
84 >> python -c 'import sys,json; j = json.load(sys.stdin);
\r
85 >> json.dump(j, sys.stdout, sort_keys=True, indent=2)' < input_file
\r
87 >> The other "problem" with json.tool is that it converts non-ascii chars
\r
88 >> to \uNNNN values :/.
\r
90 > This one doesn't require 2.7.
\r
92 > python -c 'import sys,json,codecs; json.dump(json.load(sys.stdin),
\r
93 > codecs.getwriter("utf8")(sys.stdout), indent=4, ensure_ascii=False)'
\r
98 > Though I think that, for test canonicalization, \uNNNN is probably
\r
99 > less error/locale prone.
\r
104 >> What we could do is to dig a simple c json formatter -- someday in the
\r
105 >> future, maybe -- but for *now* this is the best we can have :D
\r
107 > Not another JSON parser/printer!
\r
109 Why not, one from scratch, without looking any source there is already >;)
\r
111 Well, you're right; the json.tool version python 2.6 provides is good --
\r
112 -- ordering and those \uNNNN:s doesn't really matter.
\r
113 Probably thinking (or planning!) anything else at this time is waste of time.
\r
115 At least these 2 questions remain:
\r
117 Is the test requirement of python 2.6 suitable/acceptable ?
\r
119 How do we pretty-print S-expression syntax ;) ?
\r
127 >> > test/missing-headers | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++
\r
128 >> > test/notmuch-test | 1 +
\r
129 >> > 2 files changed, 163 insertions(+)
\r
130 >> > create mode 100755 test/missing-headers
\r
132 >> > diff --git a/test/missing-headers b/test/missing-headers
\r
133 >> > new file mode 100755
\r
134 >> > index 0000000..e79f922
\r
136 >> > +++ b/test/missing-headers
\r
137 >> > @@ -0,0 +1,162 @@
\r
138 >> > +#!/usr/bin/env bash
\r
139 >> > +test_description='messages with missing headers'
\r
140 >> > +. ./test-lib.sh
\r
142 >> > +# Notmuch requires at least one of from, subject, or to or it will
\r
143 >> > +# ignore the file. Generate two messages so that together they cover
\r
144 >> > +# all possible missing headers. We also give one of the messages a
\r
145 >> > +# date to ensure stable result ordering.
\r
147 >> > +cat <<EOF > "${MAIL_DIR}/msg-2"
\r
148 >> > +To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
149 >> > +Date: Fri, 05 Jan 2001 15:43:57 +0000
\r
154 >> > +cat <<EOF > "${MAIL_DIR}/msg-1"
\r
155 >> > +From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
162 >> > +test_begin_subtest "Search: text"
\r
163 >> > +output=$(notmuch search '*' | notmuch_search_sanitize)
\r
164 >> > +test_expect_equal "$output" "\
\r
165 >> > +thread:XXX 2001-01-05 [1/1] (null); (inbox unread)
\r
166 >> > +thread:XXX 1970-01-01 [1/1] Notmuch Test Suite; (inbox unread)"
\r
168 >> > +test_begin_subtest "Search: json"
\r
169 >> > +test_subtest_known_broken
\r
170 >> > +output=$(notmuch search --format=json '*' | notmuch_search_sanitize)
\r
171 >> > +test_expect_equal_json "$output" '
\r
174 >> > + "authors": "",
\r
175 >> > + "date_relative": "2001-01-05",
\r
176 >> > + "matched": 1,
\r
177 >> > + "subject": "",
\r
182 >> > + "thread": "XXX",
\r
183 >> > + "timestamp": 978709437,
\r
187 >> > + "authors": "Notmuch Test Suite",
\r
188 >> > + "date_relative": "1970-01-01",
\r
189 >> > + "matched": 1,
\r
190 >> > + "subject": "",
\r
195 >> > + "thread": "XXX",
\r
196 >> > + "timestamp": 0,
\r
201 >> > +test_begin_subtest "Show: text"
\r
202 >> > +output=$(notmuch show '*' | notmuch_show_sanitize)
\r
203 >> > +test_expect_equal "$output" "\
\r
205 message{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-2
\r
208 >> > + (2001-01-05) (inbox unread)
\r
209 >> > +Subject: (null)
\r
211 >> > +To: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
212 >> > +Date: Fri, 05 Jan 2001 15:43:57 +0000
\r
218 part{ ID: 1, Content-type: text/plain
\r
227 message{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-1
\r
230 >> > +Notmuch Test Suite <test_suite@notmuchmail.org> (1970-01-01) (inbox unread)
\r
231 >> > +Subject: (null)
\r
232 >> > +From: Notmuch Test Suite <test_suite@notmuchmail.org>
\r
233 >> > +Date: Thu, 01 Jan 1970 00:00:00 +0000
\r
239 part{ ID: 1, Content-type: text/plain
\r
248 >> > +test_begin_subtest "Show: json"
\r
249 >> > +test_subtest_known_broken
\r
250 >> > +output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize)
\r
251 >> > +test_expect_equal_json "$output" '
\r
258 >> > + "content": "Body\n",
\r
259 >> > + "content-type": "text/plain",
\r
263 >> > + "date_relative": "2001-01-05",
\r
264 >> > + "excluded": false,
\r
265 >> > + "filename": "YYYYY",
\r
266 >> > + "headers": {
\r
267 >> > + "Date": "Fri, 05 Jan 2001 15:43:57 +0000",
\r
269 >> > + "Subject": "",
\r
270 >> > + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"
\r
272 >> > + "id": "XXXXX",
\r
273 >> > + "match": true,
\r
278 >> > + "timestamp": 978709437
\r
288 >> > + "content": "Body\n",
\r
289 >> > + "content-type": "text/plain",
\r
293 >> > + "date_relative": "1970-01-01",
\r
294 >> > + "excluded": false,
\r
295 >> > + "filename": "YYYYY",
\r
296 >> > + "headers": {
\r
297 >> > + "Date": "Thu, 01 Jan 1970 00:00:00 +0000",
\r
298 >> > + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
299 >> > + "Subject": ""
\r
301 >> > + "id": "XXXXX",
\r
302 >> > + "match": true,
\r
307 >> > + "timestamp": 0
\r
316 >> > diff --git a/test/notmuch-test b/test/notmuch-test
\r
317 >> > index ea39dfc..cc732c3 100755
\r
318 >> > --- a/test/notmuch-test
\r
319 >> > +++ b/test/notmuch-test
\r
320 >> > @@ -59,6 +59,7 @@ TESTS="
\r
321 >> > emacs-address-cleaning
\r
324 >> > + missing-headers
\r
326 >> > TESTS=${NOTMUCH_TESTS:=$TESTS}
\r
329 >> > _______________________________________________
\r
330 >> > notmuch mailing list
\r
331 >> > notmuch@notmuchmail.org
\r
332 >> > http://notmuchmail.org/mailman/listinfo/notmuch
\r
333 > _______________________________________________
\r
334 > notmuch mailing list
\r
335 > notmuch@notmuchmail.org
\r
336 > http://notmuchmail.org/mailman/listinfo/notmuch
\r