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 1872F431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 28 Jul 2012 06:18:19 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 88qZYImQnD27 for <notmuch@notmuchmail.org>;
\r
17 Sat, 28 Jul 2012 06:18:17 -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 9E1D4431FAE
\r
22 for <notmuch@notmuchmail.org>; Sat, 28 Jul 2012 06:18:16 -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 1Sv6uJ-0000ko-Gi; Sat, 28 Jul 2012 14:18:14 +0100
\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]
\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 1Sv6uI-0001Qm-8U; Sat, 28 Jul 2012 14:18:11 +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 v2 01/13] test: Uniformly canonicalize actual and expected
\r
36 In-Reply-To: <1343449754-9010-2-git-send-email-amdragon@mit.edu>
\r
37 References: <1343449754-9010-1-git-send-email-amdragon@mit.edu>
\r
38 <1343449754-9010-2-git-send-email-amdragon@mit.edu>
\r
39 User-Agent: Notmuch/0.13.2+93~gf33b188 (http://notmuchmail.org) Emacs/23.4.1
\r
40 (x86_64-pc-linux-gnu)
\r
41 Date: Sat, 28 Jul 2012 14:18:09 +0100
\r
42 Message-ID: <87lii4uir2.fsf@qmul.ac.uk>
\r
44 Content-Type: text/plain; charset=utf-8
\r
45 Content-Transfer-Encoding: quoted-printable
\r
46 X-Sender-Host-Address: 94.192.233.223
\r
47 X-QM-SPAM-Info: Sender has good ham record. :)
\r
48 X-QM-Body-MD5: bee0de2a259038a02d453a38c150ea76 (of first 20000 bytes)
\r
49 X-SpamAssassin-Score: -1.8
\r
50 X-SpamAssassin-SpamBar: -
\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to
\r
53 spam. We require at least 5.0 points to mark a message as spam.
\r
54 This message scored -1.8 points.
\r
55 Summary of the scoring:
\r
56 * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,
\r
58 * [138.37.6.40 listed in list.dnswl.org]
\r
59 * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail
\r
60 provider * (markwalters1009[at]gmail.com)
\r
61 * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay
\r
63 * 0.5 AWL AWL: From: address is in the auto white-list
\r
64 X-QM-Scan-Virus: ClamAV says the message is clean
\r
65 Cc: tomi.ollila@iki.fi
\r
66 X-BeenThere: notmuch@notmuchmail.org
\r
67 X-Mailman-Version: 2.1.13
\r
69 List-Id: "Use and development of the notmuch mail system."
\r
70 <notmuch.notmuchmail.org>
\r
71 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
72 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
73 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
74 List-Post: <mailto:notmuch@notmuchmail.org>
\r
75 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
76 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
77 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
78 X-List-Received-Date: Sat, 28 Jul 2012 13:18:19 -0000
\r
81 This looks good to me. I have read the test patches too now and they
\r
82 look fine. I just have one possible thought (see below) which is
\r
83 definitely not worth holding up this series for.
\r
89 On Sat, 28 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:
\r
90 > Previously, we used a variety of ad-hoc canonicalizations for JSON
\r
91 > output in the test suite, but were ultimately very sensitive to JSON
\r
92 > irrelevancies such as whitespace. This introduces a new test
\r
93 > comparison function, test_expect_equal_json, that first pretty-prints
\r
94 > *both* the actual and expected JSON and the compares the result.
\r
96 > The current implementation of this simply uses Python's json.tool to
\r
97 > perform pretty-printing (with a fallback to the identity function if
\r
98 > parsing fails). However, since the interface it introduces is
\r
99 > semantically high-level, we could swap in other mechanisms in the
\r
100 > future, such as another pretty-printer or something that does not
\r
101 > re-order object keys (if we decide that we care about that).
\r
103 > In general, this patch does not remove the existing ad-hoc
\r
104 > canonicalization because it does no harm. We do have to remove the
\r
105 > newline-after-comma rule from notmuch_json_show_sanitize and
\r
106 > filter_show_json because it results in invalid JSON that cannot be
\r
109 > Most of this patch simply replaces test_expect_equal and
\r
110 > test_expect_equal_file with test_expect_equal_json. It changes the
\r
111 > expected JSON in a few places where sanitizers had placed newlines
\r
112 > after commas inside strings.
\r
114 > test/crypto | 37 +++++++++++++++----------------------
\r
115 > test/json | 14 +++++++-------
\r
116 > test/maildir-sync | 11 ++++-------
\r
117 > test/multipart | 34 +++++++++++++++-------------------
\r
118 > test/search-output | 2 +-
\r
119 > test/test-lib.sh | 17 +++++++++++++----
\r
120 > 6 files changed, 55 insertions(+), 60 deletions(-)
\r
122 > diff --git a/test/crypto b/test/crypto
\r
123 > index be752b1..5dd14c4 100755
\r
124 > --- a/test/crypto
\r
125 > +++ b/test/crypto
\r
126 > @@ -51,8 +51,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
127 > "headers": {"Subject": "test signed message 001",
\r
128 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
129 > "To": "test_suite@notmuchmail.org",
\r
131 > - 01 Jan 2000 12:00:00 +0000"},
\r
132 > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
133 > "body": [{"id": 1,
\r
134 > "sigstatus": [{"status": "good",
\r
135 > "fingerprint": "'$FINGERPRINT'",
\r
136 > @@ -64,7 +63,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
138 > "content-type": "application/pgp-signature"}]}]},
\r
140 > -test_expect_equal \
\r
141 > +test_expect_equal_json \
\r
145 > @@ -85,8 +84,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
146 > "headers": {"Subject": "test signed message 001",
\r
147 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
148 > "To": "test_suite@notmuchmail.org",
\r
150 > - 01 Jan 2000 12:00:00 +0000"},
\r
151 > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
152 > "body": [{"id": 1,
\r
153 > "sigstatus": [{"status": "good",
\r
154 > "fingerprint": "'$FINGERPRINT'",
\r
155 > @@ -99,7 +97,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
157 > "content-type": "application/pgp-signature"}]}]},
\r
159 > -test_expect_equal \
\r
160 > +test_expect_equal_json \
\r
164 > @@ -119,8 +117,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
165 > "headers": {"Subject": "test signed message 001",
\r
166 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
167 > "To": "test_suite@notmuchmail.org",
\r
169 > - 01 Jan 2000 12:00:00 +0000"},
\r
170 > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
171 > "body": [{"id": 1,
\r
172 > "sigstatus": [{"status": "error",
\r
173 > "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'",
\r
174 > @@ -132,7 +129,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
176 > "content-type": "application/pgp-signature"}]}]},
\r
178 > -test_expect_equal \
\r
179 > +test_expect_equal_json \
\r
182 > mv "${GNUPGHOME}"{.bak,}
\r
183 > @@ -193,8 +190,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
184 > "headers": {"Subject": "test encrypted message 001",
\r
185 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
186 > "To": "test_suite@notmuchmail.org",
\r
188 > - 01 Jan 2000 12:00:00 +0000"},
\r
189 > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
190 > "body": [{"id": 1,
\r
191 > "encstatus": [{"status": "good"}],
\r
193 > @@ -210,7 +206,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
194 > "content-type": "application/octet-stream",
\r
195 > "filename": "TESTATTACHMENT"}]}]}]},
\r
197 > -test_expect_equal \
\r
198 > +test_expect_equal_json \
\r
202 > @@ -221,7 +217,7 @@ output=3D$(notmuch show --format=3Djson --part=3D4 --=
\r
203 decrypt subject:"test encrypted m
\r
204 > expected=3D'{"id": 4,
\r
205 > "content-type": "text/plain",
\r
206 > "content": "This is a test encrypted message.\n"}'
\r
207 > -test_expect_equal \
\r
208 > +test_expect_equal_json \
\r
212 > @@ -248,8 +244,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
213 > "headers": {"Subject": "test encrypted message 001",
\r
214 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
215 > "To": "test_suite@notmuchmail.org",
\r
217 > - 01 Jan 2000 12:00:00 +0000"},
\r
218 > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
219 > "body": [{"id": 1,
\r
220 > "encstatus": [{"status": "bad"}],
\r
221 > "content-type": "multipart/encrypted",
\r
222 > @@ -258,7 +253,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
224 > "content-type": "application/octet-stream"}]}]},
\r
226 > -test_expect_equal \
\r
227 > +test_expect_equal_json \
\r
230 > mv "${GNUPGHOME}"{.bak,}
\r
231 > @@ -283,8 +278,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
232 > "headers": {"Subject": "test encrypted message 002",
\r
233 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
234 > "To": "test_suite@notmuchmail.org",
\r
236 > - 01 Jan 2000 12:00:00 +0000"},
\r
237 > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
238 > "body": [{"id": 1,
\r
239 > "encstatus": [{"status": "good"}],
\r
240 > "sigstatus": [{"status": "good",
\r
241 > @@ -298,7 +292,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
242 > "content-type": "text/plain",
\r
243 > "content": "This is another test encrypted message.\n"}]}]},
\r
245 > -test_expect_equal \
\r
246 > +test_expect_equal_json \
\r
250 > @@ -338,8 +332,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
251 > "headers": {"Subject": "test signed message 001",
\r
252 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
253 > "To": "test_suite@notmuchmail.org",
\r
255 > - 01 Jan 2000 12:00:00 +0000"},
\r
256 > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
257 > "body": [{"id": 1,
\r
258 > "sigstatus": [{"status": "error",
\r
259 > "keyid": "6D92612D94E46381",
\r
260 > @@ -351,7 +344,7 @@ expected=3D'[[[{"id": "XXXXX",
\r
262 > "content-type": "application/pgp-signature"}]}]},
\r
264 > -test_expect_equal \
\r
265 > +test_expect_equal_json \
\r
269 > diff --git a/test/json b/test/json
\r
270 > index 831e105..d86ee46 100755
\r
273 > @@ -5,21 +5,21 @@ test_description=3D"--format=3Djson output"
\r
274 > test_begin_subtest "Show message: json"
\r
275 > add_message "[subject]=3D\"json-show-subject\"" "[date]=3D\"Sat, 01 Jan =
\r
276 2000 12:00:00 -0000\"" "[body]=3D\"json-show-message\""
\r
277 > output=3D$(notmuch show --format=3Djson "json-show-message")
\r
278 > -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": t=
\r
279 rue, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestam=
\r
280 p\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"u=
\r
281 nread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Not=
\r
282 much Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suit=
\r
283 e <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +00=
\r
284 00\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\"=
\r
285 : \"json-show-message\n\"}]}, []]]]"
\r
286 > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match=
\r
287 \": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"tim=
\r
288 estamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\=
\r
289 ",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": =
\r
290 \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test=
\r
291 Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:0=
\r
292 0 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"cont=
\r
293 ent\": \"json-show-message\n\"}]}, []]]]"
\r
295 Since test_expect_equal_json does not care about whitespace (outside of
\r
296 strings) would it be worth splitting the expected output for each of
\r
297 these tests into multiple lines?
\r
299 > # This should be the same output as above.
\r
300 > test_begin_subtest "Show message: json --body=3Dtrue"
\r
301 > output=3D$(notmuch show --format=3Djson --body=3Dtrue "json-show-message=
\r
303 > -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": t=
\r
304 rue, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestam=
\r
305 p\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"u=
\r
306 nread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Not=
\r
307 much Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suit=
\r
308 e <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +00=
\r
309 00\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\"=
\r
310 : \"json-show-message\n\"}]}, []]]]"
\r
311 > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match=
\r
312 \": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"tim=
\r
313 estamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\=
\r
314 ",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": =
\r
315 \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test=
\r
316 Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:0=
\r
317 0 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"cont=
\r
318 ent\": \"json-show-message\n\"}]}, []]]]"
\r
320 > test_begin_subtest "Show message: json --body=3Dfalse"
\r
321 > output=3D$(notmuch show --format=3Djson --body=3Dfalse "json-show-messag=
\r
323 > -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": t=
\r
324 rue, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestam=
\r
325 p\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"u=
\r
326 nread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Not=
\r
327 much Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suit=
\r
328 e <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +00=
\r
330 > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match=
\r
331 \": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"tim=
\r
332 estamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\=
\r
333 ",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": =
\r
334 \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test=
\r
335 Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:0=
\r
336 0 +0000\"}}, []]]]"
\r
338 > test_begin_subtest "Search message: json"
\r
339 > add_message "[subject]=3D\"json-search-subject\"" "[date]=3D\"Sat, 01 Ja=
\r
340 n 2000 12:00:00 -0000\"" "[body]=3D\"json-search-message\""
\r
341 > output=3D$(notmuch search --format=3Djson "json-search-message" | notmuc=
\r
342 h_json_show_sanitize | notmuch_search_sanitize)
\r
343 > -test_expect_equal "$output" "[{\"thread\": \"XXX\",
\r
344 > +test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
\r
345 > \"timestamp\": 946728000,
\r
346 > \"date_relative\": \"2000-01-01\",
\r
348 > @@ -32,7 +32,7 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\",
\r
349 > test_begin_subtest "Show message: json, utf-8"
\r
350 > add_message "[subject]=3D\"json-show-utf8-body-s=C3=BCbj=C3=A9ct\"" "[da=
\r
351 te]=3D\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=3D\"js=C3=B6n-show-m=C3=
\r
353 > output=3D$(notmuch show --format=3Djson "js=C3=B6n-show-m=C3=A9ssage")
\r
354 > -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": t=
\r
355 rue, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestam=
\r
356 p\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"u=
\r
357 nread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-s=C3=BCbj=C3=A9c=
\r
358 t\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\":=
\r
359 \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 J=
\r
360 an 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/=
\r
361 plain\", \"content\": \"js=C3=B6n-show-m=C3=A9ssage\n\"}]}, []]]]"
\r
362 > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match=
\r
363 \": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"tim=
\r
364 estamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\=
\r
365 ",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-s=C3=BCbj=
\r
366 =C3=A9ct\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", =
\r
367 \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sa=
\r
368 t, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": =
\r
369 \"text/plain\", \"content\": \"js=C3=B6n-show-m=C3=A9ssage\n\"}]}, []]]]"
\r
371 > test_begin_subtest "Show message: json, inline attachment filename"
\r
372 > subject=3D'json-show-inline-attachment-filename'
\r
373 > @@ -45,12 +45,12 @@ emacs_deliver_message \
\r
374 > (insert \"Message-ID: <$id>\n\")"
\r
375 > output=3D$(notmuch show --format=3Djson "id:$id")
\r
376 > filename=3D$(notmuch search --output=3Dfiles "id:$id")
\r
377 > -test_expect_equal "$output" "[[[{\"id\": \"$id\", \"match\": true, \"exc=
\r
378 luded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"da=
\r
379 te_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subje=
\r
380 ct\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.=
\r
381 org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 200=
\r
382 0 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/m=
\r
383 ixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"conte=
\r
384 nt\": \"This is a test message with inline attachment with a filename\"}, {=
\r
385 \"id\": 3, \"content-type\": \"application/octet-stream\", \"filename\": \"=
\r
386 README\"}]}]}, []]]]"
\r
387 > +test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, =
\r
388 \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000,=
\r
389 \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"=
\r
390 Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuch=
\r
391 mail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Ja=
\r
392 n 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multip=
\r
393 art/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"=
\r
394 content\": \"This is a test message with inline attachment with a filename\=
\r
395 "}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"filename\=
\r
396 ": \"README\"}]}]}, []]]]"
\r
398 > test_begin_subtest "Search message: json, utf-8"
\r
399 > add_message "[subject]=3D\"json-search-utf8-body-s=C3=BCbj=C3=A9ct\"" "[=
\r
400 date]=3D\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=3D\"js=C3=B6n-search-m=
\r
402 > output=3D$(notmuch search --format=3Djson "js=C3=B6n-search-m=C3=A9ssage=
\r
403 " | notmuch_json_show_sanitize | notmuch_search_sanitize)
\r
404 > -test_expect_equal "$output" "[{\"thread\": \"XXX\",
\r
405 > +test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
\r
406 > \"timestamp\": 946728000,
\r
407 > \"date_relative\": \"2000-01-01\",
\r
409 > diff --git a/test/maildir-sync b/test/maildir-sync
\r
410 > index 01348d3..b748d04 100755
\r
411 > --- a/test/maildir-sync
\r
412 > +++ b/test/maildir-sync
\r
413 > @@ -4,11 +4,9 @@ test_description=3D"maildir synchronization"
\r
417 > -# Much easier to examine differences if the "notmuch show
\r
418 > -# --format=3Djson" output includes some newlines. Also, need to avoid
\r
419 > -# including the local value of MAIL_DIR in the result.
\r
420 > +# Avoid including the local value of MAIL_DIR in the result.
\r
421 > filter_show_json() {
\r
422 > - sed -e 's/, /,\n/g' | sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"
\r
423 > + sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"
\r
427 > @@ -44,7 +42,7 @@ test_expect_equal "$output" "adding-replied-tag:2,RS"
\r
429 > test_begin_subtest "notmuch show works with renamed file (without notmuc=
\r
431 > output=3D$(notmuch show --format=3Djson id:${gen_msg_id} | filter_show_j=
\r
433 > -test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-=
\r
435 > +test_expect_equal_json "$output" '[[[{"id": "adding-replied-tag@notmuch-=
\r
438 > "excluded": false,
\r
439 > "filename": "MAIL_DIR/cur/adding-replied-tag:2,RS",
\r
440 > @@ -54,8 +52,7 @@ test_expect_equal "$output" '[[[{"id": "adding-replied-=
\r
441 tag@notmuch-test-suite",
\r
442 > "headers": {"Subject": "Adding replied tag",
\r
443 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
444 > "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
446 > -05 Jan 2001 15:43:57 +0000"},
\r
447 > +"Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
\r
448 > "body": [{"id": 1,
\r
449 > "content-type": "text/plain",
\r
450 > "content": "This is just a test message (#3)\n"}]},
\r
451 > diff --git a/test/multipart b/test/multipart
\r
452 > index 72d3927..3ccf27f 100755
\r
453 > --- a/test/multipart
\r
454 > +++ b/test/multipart
\r
455 > @@ -334,7 +334,7 @@ cat <<EOF >EXPECTED
\r
456 > {"id": 8, "content-type": "text/plain", "content": "And this message is =
\r
457 signed.\n\n-Carl\n"}]},=20
\r
458 > {"id": 9, "content-type": "application/pgp-signature"}]}]}
\r
460 > -test_expect_equal_file OUTPUT EXPECTED
\r
461 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
463 > test_begin_subtest "--format=3Djson --part=3D1, message body"
\r
464 > notmuch show --format=3Djson --part=3D1 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
465 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
466 > @@ -351,7 +351,7 @@ cat <<EOF >EXPECTED
\r
467 > {"id": 8, "content-type": "text/plain", "content": "And this message is =
\r
468 signed.\n\n-Carl\n"}]},=20
\r
469 > {"id": 9, "content-type": "application/pgp-signature"}]}
\r
471 > -test_expect_equal_file OUTPUT EXPECTED
\r
472 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
474 > test_begin_subtest "--format=3Djson --part=3D2, multipart/mixed"
\r
475 > notmuch show --format=3Djson --part=3D2 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
476 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
477 > @@ -366,7 +366,7 @@ cat <<EOF >EXPECTED
\r
478 > {"id": 7, "content-type": "text/plain", "filename": "attachment", "conte=
\r
479 nt": "This is a text attachment.\n"},=20
\r
480 > {"id": 8, "content-type": "text/plain", "content": "And this message is =
\r
481 signed.\n\n-Carl\n"}]}
\r
483 > -test_expect_equal_file OUTPUT EXPECTED
\r
484 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
486 > test_begin_subtest "--format=3Djson --part=3D3, rfc822 part"
\r
487 > notmuch show --format=3Djson --part=3D3 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
488 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
489 > @@ -378,7 +378,7 @@ cat <<EOF >EXPECTED
\r
490 > {"id": 5, "content-type": "text/html"},=20
\r
491 > {"id": 6, "content-type": "text/plain", "content": "This is an embedded =
\r
492 message, with a multipart/alternative part.\n"}]}]}]}
\r
494 > -test_expect_equal_file OUTPUT EXPECTED
\r
495 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
497 > test_begin_subtest "--format=3Djson --part=3D4, rfc822's multipart/alter=
\r
499 > notmuch show --format=3Djson --part=3D4 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
500 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
501 > @@ -389,7 +389,7 @@ cat <<EOF >EXPECTED
\r
502 > {"id": 5, "content-type": "text/html"},=20
\r
503 > {"id": 6, "content-type": "text/plain", "content": "This is an embedded =
\r
504 message, with a multipart/alternative part.\n"}]}
\r
506 > -test_expect_equal_file OUTPUT EXPECTED
\r
507 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
509 > test_begin_subtest "--format=3Djson --part=3D5, rfc822's html part"
\r
510 > notmuch show --format=3Djson --part=3D5 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
511 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
512 > @@ -398,7 +398,7 @@ cat <<EOF >EXPECTED
\r
514 > {"id": 5, "content-type": "text/html"}
\r
516 > -test_expect_equal_file OUTPUT EXPECTED
\r
517 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
519 > test_begin_subtest "--format=3Djson --part=3D6, rfc822's text part"
\r
520 > notmuch show --format=3Djson --part=3D6 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
521 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
522 > @@ -407,7 +407,7 @@ cat <<EOF >EXPECTED
\r
524 > {"id": 6, "content-type": "text/plain", "content": "This is an embedded =
\r
525 message, with a multipart/alternative part.\n"}
\r
527 > -test_expect_equal_file OUTPUT EXPECTED
\r
528 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
530 > test_begin_subtest "--format=3Djson --part=3D7, inline attachment"
\r
531 > notmuch show --format=3Djson --part=3D7 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
532 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
533 > @@ -416,7 +416,7 @@ cat <<EOF >EXPECTED
\r
535 > {"id": 7, "content-type": "text/plain", "filename": "attachment", "conte=
\r
536 nt": "This is a text attachment.\n"}
\r
538 > -test_expect_equal_file OUTPUT EXPECTED
\r
539 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
541 > test_begin_subtest "--format=3Djson --part=3D8, plain text part"
\r
542 > notmuch show --format=3Djson --part=3D8 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
543 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
544 > @@ -425,7 +425,7 @@ cat <<EOF >EXPECTED
\r
546 > {"id": 8, "content-type": "text/plain", "content": "And this message is =
\r
547 signed.\n\n-Carl\n"}
\r
549 > -test_expect_equal_file OUTPUT EXPECTED
\r
550 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
552 > test_begin_subtest "--format=3Djson --part=3D9, pgp signature (unverifie=
\r
554 > notmuch show --format=3Djson --part=3D9 'id:87liy5ap00.fsf@yoom.home.cwo=
\r
555 rth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
556 > @@ -434,7 +434,7 @@ cat <<EOF >EXPECTED
\r
558 > {"id": 9, "content-type": "application/pgp-signature"}
\r
560 > -test_expect_equal_file OUTPUT EXPECTED
\r
561 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
563 > test_expect_success \
\r
564 > "--format=3Djson --part=3D10, no part, expect error" \
\r
565 > @@ -617,8 +617,7 @@ notmuch reply --format=3Djson 'id:87liy5ap00.fsf@yoom=
\r
566 .home.cworth.org' | notmuch_j
\r
567 > cat <<EOF >EXPECTED
\r
568 > {"reply-headers": {"Subject": "Re: Multipart message",
\r
569 > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
570 > - "To": "Carl Worth <cworth@cworth.org>,
\r
571 > - cworth@cworth.org",
\r
572 > + "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",
\r
573 > "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",
\r
574 > "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"},
\r
575 > "original": {"id": "XXXXX",
\r
576 > @@ -631,8 +630,7 @@ cat <<EOF >EXPECTED
\r
577 > "headers": {"Subject": "Multipart message",
\r
578 > "From": "Carl Worth <cworth@cworth.org>",
\r
579 > "To": "cworth@cworth.org",
\r
581 > - 05 Jan 2001 15:43:57 +0000"},
\r
582 > + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
\r
583 > "body": [{"id": 1,
\r
584 > "content-type": "multipart/signed",
\r
585 > "content": [{"id": 2,
\r
586 > @@ -642,16 +640,14 @@ cat <<EOF >EXPECTED
\r
587 > "content": [{"headers": {"Subject": "html message",
\r
588 > "From": "Carl Worth <cworth@cworth.org>",
\r
589 > "To": "cworth@cworth.org",
\r
591 > - 05 Jan 2001 15:42:57 +0000"},
\r
592 > + "Date": "Fri, 05 Jan 2001 15:42:57 +0000"},
\r
593 > "body": [{"id": 4,
\r
594 > "content-type": "multipart/alternative",
\r
595 > "content": [{"id": 5,
\r
596 > "content-type": "text/html"},
\r
598 > "content-type": "text/plain",
\r
599 > - "content": "This is an embedded message,
\r
600 > - with a multipart/alternative part.\n"}]}]}]},
\r
601 > + "content": "This is an embedded message, with a multipart/alternative p=
\r
604 > "content-type": "text/plain",
\r
605 > "filename": "YYYYY",
\r
606 > @@ -662,7 +658,7 @@ cat <<EOF >EXPECTED
\r
608 > "content-type": "application/pgp-signature"}]}]}}
\r
610 > -test_expect_equal_file OUTPUT EXPECTED
\r
611 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
613 > test_begin_subtest "'notmuch show --part' does not corrupt a part with C=
\r
615 > notmuch show --format=3Draw --part=3D3 id:base64-part-with-crlf > crlf.o=
\r
617 > diff --git a/test/search-output b/test/search-output
\r
618 > index 8b57a43..c2a87eb 100755
\r
619 > --- a/test/search-output
\r
620 > +++ b/test/search-output
\r
621 > @@ -62,7 +62,7 @@ cat <<EOF >EXPECTED
\r
625 > -test_expect_equal_file OUTPUT EXPECTED
\r
626 > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
628 > test_begin_subtest "--output=3Dmessages"
\r
629 > notmuch search --output=3Dmessages '*' >OUTPUT
\r
630 > diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
631 > index 06aaea2..791d2dc 100644
\r
632 > --- a/test/test-lib.sh
\r
633 > +++ b/test/test-lib.sh
\r
634 > @@ -512,6 +512,16 @@ test_expect_equal_file ()
\r
638 > +# Like test_expect_equal, but arguments are JSON expressions to be
\r
639 > +# canonicalized before diff'ing. If an argument cannot be parsed, it
\r
640 > +# is used unchanged so that there's something to diff against.
\r
641 > +test_expect_equal_json () {
\r
642 > + output=3D$(echo "$1" | python -mjson.tool || echo "$1")
\r
643 > + expected=3D$(echo "$2" | python -mjson.tool || echo "$2")
\r
645 > + test_expect_equal "$output" "$expected" "$@"
\r
648 > test_emacs_expect_t () {
\r
649 > test "$#" =3D 2 && { prereq=3D$1; shift; } || prereq=3D
\r
650 > test "$#" =3D 1 ||
\r
651 > @@ -565,10 +575,9 @@ notmuch_show_sanitize_all ()
\r
653 > notmuch_json_show_sanitize ()
\r
655 > - sed -e 's|, |,\n |g' | \
\r
657 > - -e 's|"id": "[^"]*",|"id": "XXXXX",|' \
\r
658 > - -e 's|"filename": "[^"]*",|"filename": "YYYYY",|'
\r
660 > + -e 's|"id": "[^"]*",|"id": "XXXXX",|g' \
\r
661 > + -e 's|"filename": "[^"]*",|"filename": "YYYYY",|g'
\r
664 > # End of notmuch helper functions
\r