1 Return-Path: <amdragon@mit.edu>
\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 5B632431FAF
\r
6 for <notmuch@notmuchmail.org>; Sat, 28 Jul 2012 12:22:05 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\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 nla4Ewd7y8rW for <notmuch@notmuchmail.org>;
\r
16 Sat, 28 Jul 2012 12:22:03 -0700 (PDT)
\r
17 Received: from dmz-mailsec-scanner-8.mit.edu (DMZ-MAILSEC-SCANNER-8.MIT.EDU
\r
19 by olra.theworths.org (Postfix) with ESMTP id 0D33B431FAE
\r
20 for <notmuch@notmuchmail.org>; Sat, 28 Jul 2012 12:22:02 -0700 (PDT)
\r
21 X-AuditID: 12074425-b7f9b6d0000008c4-73-50143bda9f72
\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])
\r
23 by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP
\r
24 id D6.0E.02244.ADB34105; Sat, 28 Jul 2012 15:22:02 -0400 (EDT)
\r
25 Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])
\r
26 by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q6SJM1DY001316;
\r
27 Sat, 28 Jul 2012 15:22:01 -0400
\r
28 Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])
\r
29 (authenticated bits=0)
\r
30 (User authenticated as amdragon@ATHENA.MIT.EDU)
\r
31 by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q6SJLxtm000674
\r
32 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);
\r
33 Sat, 28 Jul 2012 15:21:59 -0400 (EDT)
\r
34 Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)
\r
35 (envelope-from <amdragon@mit.edu>)
\r
36 id 1SvCaM-0004Ta-S1; Sat, 28 Jul 2012 15:21:58 -0400
\r
37 Date: Sat, 28 Jul 2012 15:21:58 -0400
\r
38 From: Austin Clements <amdragon@MIT.EDU>
\r
39 To: Mark Walters <markwalters1009@gmail.com>
\r
40 Subject: Re: [PATCH v2 01/13] test: Uniformly canonicalize actual and
\r
42 Message-ID: <20120728192158.GE8502@mit.edu>
\r
43 References: <1343449754-9010-1-git-send-email-amdragon@mit.edu>
\r
44 <1343449754-9010-2-git-send-email-amdragon@mit.edu>
\r
45 <87lii4uir2.fsf@qmul.ac.uk>
\r
47 Content-Type: text/plain; charset=iso-8859-1
\r
48 Content-Disposition: inline
\r
49 Content-Transfer-Encoding: 8bit
\r
50 In-Reply-To: <87lii4uir2.fsf@qmul.ac.uk>
\r
51 User-Agent: Mutt/1.5.21 (2010-09-15)
\r
52 X-Brightmail-Tracker:
\r
53 H4sIAAAAAAAAA+NgFjrEKsWRmVeSWpSXmKPExsUixG6nrnvLWiTAYMMXaYu9De2MFqvn8lhc
\r
54 vzmT2eLNynmsDiweO2fdZfdYvGk/m8fhrwtZPJ6tusUcwBLFZZOSmpNZllqkb5fAlfHlwVfW
\r
55 gq/nGSt6dl9ga2DcsZaxi5GTQ0LARGLt2x9MELaYxIV769lAbCGBfYwSE7e4dDFyAdkbGCXO
\r
56 HX/OAuGcZJJ4tuYnE4SzhFHixNa5YO0sAqoSF3sngtlsAhoS2/YvB1shIqAjcfvQAnYQm1nA
\r
57 XmLa2ROsILawQKhE787lQOs4OHgFtCWONEtCzJwMtHnfT7AaXgFBiZMzn7BA9OpI7Nx6B6ye
\r
58 WUBaYvk/DoiwvETz1tnMIDYn0Npd5z+BrRIVUJGYcnIb2wRG4VlIJs1CMmkWwqRZSCYtYGRZ
\r
59 xSibklulm5uYmVOcmqxbnJyYl5dapGuhl5tZopeaUrqJERwxLqo7GCccUjrEKMDBqMTDe+qK
\r
60 UIAQa2JZcWXuIUZJDiYlUd7P5iIBQnxJ+SmVGYnFGfFFpTmpxYcYJTiYlUR4rV8JBwjxpiRW
\r
61 VqUW5cOkpDlYlMR5b6Tc9BcSSE8sSc1OTS1ILYLJynBwKEnwcgATg5BgUWp6akVaZk4JQpqJ
\r
62 gxNkOA/Q8F8WQDW8xQWJucWZ6RD5U4zGHPefP7nNyHH78IvbjEIsefl5qVLivBetgEoFQEoz
\r
63 SvPgpsGS3itGcaDnhHllQZbyABMm3LxXQKuYgFZZRAuBrCpJREhJNTCeVUoOmKToeW/vpGBF
\r
64 obi64JP2rGUX+G4/vpJ5cUe/7qErr/wCDDl5Dvq87ynfo335mkRg5af8xWL7+gorF9V7la1h
\r
65 +r39YkYCw2Kf1RLNhwpsV7uHBvNwp/By1dYxBW9+sEmh/2Sh4uP8BO5PUypfc06+N8/k898l
\r
66 Np51U9Vj0pKEhUye7FViKc5INNRiLipOBAAfJ1STVQMAAA==
\r
67 Cc: tomi.ollila@iki.fi, notmuch@notmuchmail.org
\r
68 X-BeenThere: notmuch@notmuchmail.org
\r
69 X-Mailman-Version: 2.1.13
\r
71 List-Id: "Use and development of the notmuch mail system."
\r
72 <notmuch.notmuchmail.org>
\r
73 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
74 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
75 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
76 List-Post: <mailto:notmuch@notmuchmail.org>
\r
77 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
78 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
79 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
80 X-List-Received-Date: Sat, 28 Jul 2012 19:22:05 -0000
\r
82 Quoth Mark Walters on Jul 28 at 2:18 pm:
\r
84 > This looks good to me. I have read the test patches too now and they
\r
85 > look fine. I just have one possible thought (see below) which is
\r
86 > definitely not worth holding up this series for.
\r
92 > On Sat, 28 Jul 2012, Austin Clements <amdragon@MIT.EDU> wrote:
\r
93 > > Previously, we used a variety of ad-hoc canonicalizations for JSON
\r
94 > > output in the test suite, but were ultimately very sensitive to JSON
\r
95 > > irrelevancies such as whitespace. This introduces a new test
\r
96 > > comparison function, test_expect_equal_json, that first pretty-prints
\r
97 > > *both* the actual and expected JSON and the compares the result.
\r
99 > > The current implementation of this simply uses Python's json.tool to
\r
100 > > perform pretty-printing (with a fallback to the identity function if
\r
101 > > parsing fails). However, since the interface it introduces is
\r
102 > > semantically high-level, we could swap in other mechanisms in the
\r
103 > > future, such as another pretty-printer or something that does not
\r
104 > > re-order object keys (if we decide that we care about that).
\r
106 > > In general, this patch does not remove the existing ad-hoc
\r
107 > > canonicalization because it does no harm. We do have to remove the
\r
108 > > newline-after-comma rule from notmuch_json_show_sanitize and
\r
109 > > filter_show_json because it results in invalid JSON that cannot be
\r
110 > > pretty-printed.
\r
112 > > Most of this patch simply replaces test_expect_equal and
\r
113 > > test_expect_equal_file with test_expect_equal_json. It changes the
\r
114 > > expected JSON in a few places where sanitizers had placed newlines
\r
115 > > after commas inside strings.
\r
117 > > test/crypto | 37 +++++++++++++++----------------------
\r
118 > > test/json | 14 +++++++-------
\r
119 > > test/maildir-sync | 11 ++++-------
\r
120 > > test/multipart | 34 +++++++++++++++-------------------
\r
121 > > test/search-output | 2 +-
\r
122 > > test/test-lib.sh | 17 +++++++++++++----
\r
123 > > 6 files changed, 55 insertions(+), 60 deletions(-)
\r
125 > > diff --git a/test/crypto b/test/crypto
\r
126 > > index be752b1..5dd14c4 100755
\r
127 > > --- a/test/crypto
\r
128 > > +++ b/test/crypto
\r
129 > > @@ -51,8 +51,7 @@ expected='[[[{"id": "XXXXX",
\r
130 > > "headers": {"Subject": "test signed message 001",
\r
131 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
132 > > "To": "test_suite@notmuchmail.org",
\r
133 > > - "Date": "Sat,
\r
134 > > - 01 Jan 2000 12:00:00 +0000"},
\r
135 > > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
136 > > "body": [{"id": 1,
\r
137 > > "sigstatus": [{"status": "good",
\r
138 > > "fingerprint": "'$FINGERPRINT'",
\r
139 > > @@ -64,7 +63,7 @@ expected='[[[{"id": "XXXXX",
\r
141 > > "content-type": "application/pgp-signature"}]}]},
\r
143 > > -test_expect_equal \
\r
144 > > +test_expect_equal_json \
\r
148 > > @@ -85,8 +84,7 @@ expected='[[[{"id": "XXXXX",
\r
149 > > "headers": {"Subject": "test signed message 001",
\r
150 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
151 > > "To": "test_suite@notmuchmail.org",
\r
152 > > - "Date": "Sat,
\r
153 > > - 01 Jan 2000 12:00:00 +0000"},
\r
154 > > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
155 > > "body": [{"id": 1,
\r
156 > > "sigstatus": [{"status": "good",
\r
157 > > "fingerprint": "'$FINGERPRINT'",
\r
158 > > @@ -99,7 +97,7 @@ expected='[[[{"id": "XXXXX",
\r
160 > > "content-type": "application/pgp-signature"}]}]},
\r
162 > > -test_expect_equal \
\r
163 > > +test_expect_equal_json \
\r
167 > > @@ -119,8 +117,7 @@ expected='[[[{"id": "XXXXX",
\r
168 > > "headers": {"Subject": "test signed message 001",
\r
169 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
170 > > "To": "test_suite@notmuchmail.org",
\r
171 > > - "Date": "Sat,
\r
172 > > - 01 Jan 2000 12:00:00 +0000"},
\r
173 > > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
174 > > "body": [{"id": 1,
\r
175 > > "sigstatus": [{"status": "error",
\r
176 > > "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'",
\r
177 > > @@ -132,7 +129,7 @@ expected='[[[{"id": "XXXXX",
\r
179 > > "content-type": "application/pgp-signature"}]}]},
\r
181 > > -test_expect_equal \
\r
182 > > +test_expect_equal_json \
\r
185 > > mv "${GNUPGHOME}"{.bak,}
\r
186 > > @@ -193,8 +190,7 @@ expected='[[[{"id": "XXXXX",
\r
187 > > "headers": {"Subject": "test encrypted message 001",
\r
188 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
189 > > "To": "test_suite@notmuchmail.org",
\r
190 > > - "Date": "Sat,
\r
191 > > - 01 Jan 2000 12:00:00 +0000"},
\r
192 > > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
193 > > "body": [{"id": 1,
\r
194 > > "encstatus": [{"status": "good"}],
\r
195 > > "sigstatus": [],
\r
196 > > @@ -210,7 +206,7 @@ expected='[[[{"id": "XXXXX",
\r
197 > > "content-type": "application/octet-stream",
\r
198 > > "filename": "TESTATTACHMENT"}]}]}]},
\r
200 > > -test_expect_equal \
\r
201 > > +test_expect_equal_json \
\r
205 > > @@ -221,7 +217,7 @@ output=$(notmuch show --format=json --part=4 --decrypt subject:"test encrypted m
\r
206 > > expected='{"id": 4,
\r
207 > > "content-type": "text/plain",
\r
208 > > "content": "This is a test encrypted message.\n"}'
\r
209 > > -test_expect_equal \
\r
210 > > +test_expect_equal_json \
\r
214 > > @@ -248,8 +244,7 @@ expected='[[[{"id": "XXXXX",
\r
215 > > "headers": {"Subject": "test encrypted message 001",
\r
216 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
217 > > "To": "test_suite@notmuchmail.org",
\r
218 > > - "Date": "Sat,
\r
219 > > - 01 Jan 2000 12:00:00 +0000"},
\r
220 > > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
221 > > "body": [{"id": 1,
\r
222 > > "encstatus": [{"status": "bad"}],
\r
223 > > "content-type": "multipart/encrypted",
\r
224 > > @@ -258,7 +253,7 @@ expected='[[[{"id": "XXXXX",
\r
226 > > "content-type": "application/octet-stream"}]}]},
\r
228 > > -test_expect_equal \
\r
229 > > +test_expect_equal_json \
\r
232 > > mv "${GNUPGHOME}"{.bak,}
\r
233 > > @@ -283,8 +278,7 @@ expected='[[[{"id": "XXXXX",
\r
234 > > "headers": {"Subject": "test encrypted message 002",
\r
235 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
236 > > "To": "test_suite@notmuchmail.org",
\r
237 > > - "Date": "Sat,
\r
238 > > - 01 Jan 2000 12:00:00 +0000"},
\r
239 > > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
240 > > "body": [{"id": 1,
\r
241 > > "encstatus": [{"status": "good"}],
\r
242 > > "sigstatus": [{"status": "good",
\r
243 > > @@ -298,7 +292,7 @@ expected='[[[{"id": "XXXXX",
\r
244 > > "content-type": "text/plain",
\r
245 > > "content": "This is another test encrypted message.\n"}]}]},
\r
247 > > -test_expect_equal \
\r
248 > > +test_expect_equal_json \
\r
252 > > @@ -338,8 +332,7 @@ expected='[[[{"id": "XXXXX",
\r
253 > > "headers": {"Subject": "test signed message 001",
\r
254 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
255 > > "To": "test_suite@notmuchmail.org",
\r
256 > > - "Date": "Sat,
\r
257 > > - 01 Jan 2000 12:00:00 +0000"},
\r
258 > > + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},
\r
259 > > "body": [{"id": 1,
\r
260 > > "sigstatus": [{"status": "error",
\r
261 > > "keyid": "6D92612D94E46381",
\r
262 > > @@ -351,7 +344,7 @@ expected='[[[{"id": "XXXXX",
\r
264 > > "content-type": "application/pgp-signature"}]}]},
\r
266 > > -test_expect_equal \
\r
267 > > +test_expect_equal_json \
\r
271 > > diff --git a/test/json b/test/json
\r
272 > > index 831e105..d86ee46 100755
\r
273 > > --- a/test/json
\r
274 > > +++ b/test/json
\r
275 > > @@ -5,21 +5,21 @@ test_description="--format=json output"
\r
276 > > test_begin_subtest "Show message: json"
\r
277 > > add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\""
\r
278 > > output=$(notmuch show --format=json "json-show-message")
\r
279 > > -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
\r
280 > > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
\r
282 > Since test_expect_equal_json does not care about whitespace (outside of
\r
283 > strings) would it be worth splitting the expected output for each of
\r
284 > these tests into multiple lines?
\r
286 Yes, that's a good idea. I'd rather do that in a follow-up patch that
\r
287 cleans up all of the expected JSON output, since even the stuff that
\r
288 is wrapped is wrapped strangely and not indented.
\r
290 > > # This should be the same output as above.
\r
291 > > test_begin_subtest "Show message: json --body=true"
\r
292 > > output=$(notmuch show --format=json --body=true "json-show-message")
\r
293 > > -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
\r
294 > > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"json-show-message\n\"}]}, []]]]"
\r
296 > > test_begin_subtest "Show message: json --body=false"
\r
297 > > output=$(notmuch show --format=json --body=false "json-show-message")
\r
298 > > -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}}, []]]]"
\r
299 > > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}}, []]]]"
\r
301 > > test_begin_subtest "Search message: json"
\r
302 > > add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""
\r
303 > > output=$(notmuch search --format=json "json-search-message" | notmuch_json_show_sanitize | notmuch_search_sanitize)
\r
304 > > -test_expect_equal "$output" "[{\"thread\": \"XXX\",
\r
305 > > +test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
\r
306 > > \"timestamp\": 946728000,
\r
307 > > \"date_relative\": \"2000-01-01\",
\r
308 > > \"matched\": 1,
\r
309 > > @@ -32,7 +32,7 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\",
\r
310 > > test_begin_subtest "Show message: json, utf-8"
\r
311 > > add_message "[subject]=\"json-show-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-show-méssage\""
\r
312 > > output=$(notmuch show --format=json "jsön-show-méssage")
\r
313 > > -test_expect_equal "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]"
\r
314 > > +test_expect_equal_json "$output" "[[[{\"id\": \"${gen_msg_id}\", \"match\": true, \"excluded\": false, \"filename\": \"${gen_msg_filename}\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\",\"unread\"], \"headers\": {\"Subject\": \"json-show-utf8-body-sübjéct\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"text/plain\", \"content\": \"jsön-show-méssage\n\"}]}, []]]]"
\r
316 > > test_begin_subtest "Show message: json, inline attachment filename"
\r
317 > > subject='json-show-inline-attachment-filename'
\r
318 > > @@ -45,12 +45,12 @@ emacs_deliver_message \
\r
319 > > (insert \"Message-ID: <$id>\n\")"
\r
320 > > output=$(notmuch show --format=json "id:$id")
\r
321 > > filename=$(notmuch search --output=files "id:$id")
\r
322 > > -test_expect_equal "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"filename\": \"README\"}]}]}, []]]]"
\r
323 > > +test_expect_equal_json "$output" "[[[{\"id\": \"$id\", \"match\": true, \"excluded\": false, \"filename\": \"$filename\", \"timestamp\": 946728000, \"date_relative\": \"2000-01-01\", \"tags\": [\"inbox\"], \"headers\": {\"Subject\": \"$subject\", \"From\": \"Notmuch Test Suite <test_suite@notmuchmail.org>\", \"To\": \"test_suite@notmuchmail.org\", \"Date\": \"Sat, 01 Jan 2000 12:00:00 +0000\"}, \"body\": [{\"id\": 1, \"content-type\": \"multipart/mixed\", \"content\": [{\"id\": 2, \"content-type\": \"text/plain\", \"content\": \"This is a test message with inline attachment with a filename\"}, {\"id\": 3, \"content-type\": \"application/octet-stream\", \"filename\": \"README\"}]}]}, []]]]"
\r
325 > > test_begin_subtest "Search message: json, utf-8"
\r
326 > > add_message "[subject]=\"json-search-utf8-body-sübjéct\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"jsön-search-méssage\""
\r
327 > > output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_json_show_sanitize | notmuch_search_sanitize)
\r
328 > > -test_expect_equal "$output" "[{\"thread\": \"XXX\",
\r
329 > > +test_expect_equal_json "$output" "[{\"thread\": \"XXX\",
\r
330 > > \"timestamp\": 946728000,
\r
331 > > \"date_relative\": \"2000-01-01\",
\r
332 > > \"matched\": 1,
\r
333 > > diff --git a/test/maildir-sync b/test/maildir-sync
\r
334 > > index 01348d3..b748d04 100755
\r
335 > > --- a/test/maildir-sync
\r
336 > > +++ b/test/maildir-sync
\r
337 > > @@ -4,11 +4,9 @@ test_description="maildir synchronization"
\r
339 > > . ./test-lib.sh
\r
341 > > -# Much easier to examine differences if the "notmuch show
\r
342 > > -# --format=json" output includes some newlines. Also, need to avoid
\r
343 > > -# including the local value of MAIL_DIR in the result.
\r
344 > > +# Avoid including the local value of MAIL_DIR in the result.
\r
345 > > filter_show_json() {
\r
346 > > - sed -e 's/, /,\n/g' | sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"
\r
347 > > + sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"
\r
351 > > @@ -44,7 +42,7 @@ test_expect_equal "$output" "adding-replied-tag:2,RS"
\r
353 > > test_begin_subtest "notmuch show works with renamed file (without notmuch new)"
\r
354 > > output=$(notmuch show --format=json id:${gen_msg_id} | filter_show_json)
\r
355 > > -test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",
\r
356 > > +test_expect_equal_json "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",
\r
358 > > "excluded": false,
\r
359 > > "filename": "MAIL_DIR/cur/adding-replied-tag:2,RS",
\r
360 > > @@ -54,8 +52,7 @@ test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",
\r
361 > > "headers": {"Subject": "Adding replied tag",
\r
362 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
363 > > "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
365 > > -05 Jan 2001 15:43:57 +0000"},
\r
366 > > +"Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
\r
367 > > "body": [{"id": 1,
\r
368 > > "content-type": "text/plain",
\r
369 > > "content": "This is just a test message (#3)\n"}]},
\r
370 > > diff --git a/test/multipart b/test/multipart
\r
371 > > index 72d3927..3ccf27f 100755
\r
372 > > --- a/test/multipart
\r
373 > > +++ b/test/multipart
\r
374 > > @@ -334,7 +334,7 @@ cat <<EOF >EXPECTED
\r
375 > > {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
\r
376 > > {"id": 9, "content-type": "application/pgp-signature"}]}]}
\r
378 > > -test_expect_equal_file OUTPUT EXPECTED
\r
379 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
381 > > test_begin_subtest "--format=json --part=1, message body"
\r
382 > > notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
383 > > @@ -351,7 +351,7 @@ cat <<EOF >EXPECTED
\r
384 > > {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]},
\r
385 > > {"id": 9, "content-type": "application/pgp-signature"}]}
\r
387 > > -test_expect_equal_file OUTPUT EXPECTED
\r
388 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
390 > > test_begin_subtest "--format=json --part=2, multipart/mixed"
\r
391 > > notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
392 > > @@ -366,7 +366,7 @@ cat <<EOF >EXPECTED
\r
393 > > {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"},
\r
394 > > {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}
\r
396 > > -test_expect_equal_file OUTPUT EXPECTED
\r
397 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
399 > > test_begin_subtest "--format=json --part=3, rfc822 part"
\r
400 > > notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
401 > > @@ -378,7 +378,7 @@ cat <<EOF >EXPECTED
\r
402 > > {"id": 5, "content-type": "text/html"},
\r
403 > > {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}
\r
405 > > -test_expect_equal_file OUTPUT EXPECTED
\r
406 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
408 > > test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"
\r
409 > > notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
410 > > @@ -389,7 +389,7 @@ cat <<EOF >EXPECTED
\r
411 > > {"id": 5, "content-type": "text/html"},
\r
412 > > {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}
\r
414 > > -test_expect_equal_file OUTPUT EXPECTED
\r
415 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
417 > > test_begin_subtest "--format=json --part=5, rfc822's html part"
\r
418 > > notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
419 > > @@ -398,7 +398,7 @@ cat <<EOF >EXPECTED
\r
421 > > {"id": 5, "content-type": "text/html"}
\r
423 > > -test_expect_equal_file OUTPUT EXPECTED
\r
424 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
426 > > test_begin_subtest "--format=json --part=6, rfc822's text part"
\r
427 > > notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
428 > > @@ -407,7 +407,7 @@ cat <<EOF >EXPECTED
\r
430 > > {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}
\r
432 > > -test_expect_equal_file OUTPUT EXPECTED
\r
433 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
435 > > test_begin_subtest "--format=json --part=7, inline attachment"
\r
436 > > notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
437 > > @@ -416,7 +416,7 @@ cat <<EOF >EXPECTED
\r
439 > > {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}
\r
441 > > -test_expect_equal_file OUTPUT EXPECTED
\r
442 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
444 > > test_begin_subtest "--format=json --part=8, plain text part"
\r
445 > > notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
446 > > @@ -425,7 +425,7 @@ cat <<EOF >EXPECTED
\r
448 > > {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}
\r
450 > > -test_expect_equal_file OUTPUT EXPECTED
\r
451 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
453 > > test_begin_subtest "--format=json --part=9, pgp signature (unverified)"
\r
454 > > notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT
\r
455 > > @@ -434,7 +434,7 @@ cat <<EOF >EXPECTED
\r
457 > > {"id": 9, "content-type": "application/pgp-signature"}
\r
459 > > -test_expect_equal_file OUTPUT EXPECTED
\r
460 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
462 > > test_expect_success \
\r
463 > > "--format=json --part=10, no part, expect error" \
\r
464 > > @@ -617,8 +617,7 @@ notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_j
\r
465 > > cat <<EOF >EXPECTED
\r
466 > > {"reply-headers": {"Subject": "Re: Multipart message",
\r
467 > > "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",
\r
468 > > - "To": "Carl Worth <cworth@cworth.org>,
\r
469 > > - cworth@cworth.org",
\r
470 > > + "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",
\r
471 > > "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",
\r
472 > > "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"},
\r
473 > > "original": {"id": "XXXXX",
\r
474 > > @@ -631,8 +630,7 @@ cat <<EOF >EXPECTED
\r
475 > > "headers": {"Subject": "Multipart message",
\r
476 > > "From": "Carl Worth <cworth@cworth.org>",
\r
477 > > "To": "cworth@cworth.org",
\r
478 > > - "Date": "Fri,
\r
479 > > - 05 Jan 2001 15:43:57 +0000"},
\r
480 > > + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},
\r
481 > > "body": [{"id": 1,
\r
482 > > "content-type": "multipart/signed",
\r
483 > > "content": [{"id": 2,
\r
484 > > @@ -642,16 +640,14 @@ cat <<EOF >EXPECTED
\r
485 > > "content": [{"headers": {"Subject": "html message",
\r
486 > > "From": "Carl Worth <cworth@cworth.org>",
\r
487 > > "To": "cworth@cworth.org",
\r
488 > > - "Date": "Fri,
\r
489 > > - 05 Jan 2001 15:42:57 +0000"},
\r
490 > > + "Date": "Fri, 05 Jan 2001 15:42:57 +0000"},
\r
491 > > "body": [{"id": 4,
\r
492 > > "content-type": "multipart/alternative",
\r
493 > > "content": [{"id": 5,
\r
494 > > "content-type": "text/html"},
\r
496 > > "content-type": "text/plain",
\r
497 > > - "content": "This is an embedded message,
\r
498 > > - with a multipart/alternative part.\n"}]}]}]},
\r
499 > > + "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},
\r
501 > > "content-type": "text/plain",
\r
502 > > "filename": "YYYYY",
\r
503 > > @@ -662,7 +658,7 @@ cat <<EOF >EXPECTED
\r
505 > > "content-type": "application/pgp-signature"}]}]}}
\r
507 > > -test_expect_equal_file OUTPUT EXPECTED
\r
508 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
510 > > test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"
\r
511 > > notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out
\r
512 > > diff --git a/test/search-output b/test/search-output
\r
513 > > index 8b57a43..c2a87eb 100755
\r
514 > > --- a/test/search-output
\r
515 > > +++ b/test/search-output
\r
516 > > @@ -62,7 +62,7 @@ cat <<EOF >EXPECTED
\r
520 > > -test_expect_equal_file OUTPUT EXPECTED
\r
521 > > +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"
\r
523 > > test_begin_subtest "--output=messages"
\r
524 > > notmuch search --output=messages '*' >OUTPUT
\r
525 > > diff --git a/test/test-lib.sh b/test/test-lib.sh
\r
526 > > index 06aaea2..791d2dc 100644
\r
527 > > --- a/test/test-lib.sh
\r
528 > > +++ b/test/test-lib.sh
\r
529 > > @@ -512,6 +512,16 @@ test_expect_equal_file ()
\r
533 > > +# Like test_expect_equal, but arguments are JSON expressions to be
\r
534 > > +# canonicalized before diff'ing. If an argument cannot be parsed, it
\r
535 > > +# is used unchanged so that there's something to diff against.
\r
536 > > +test_expect_equal_json () {
\r
537 > > + output=$(echo "$1" | python -mjson.tool || echo "$1")
\r
538 > > + expected=$(echo "$2" | python -mjson.tool || echo "$2")
\r
540 > > + test_expect_equal "$output" "$expected" "$@"
\r
543 > > test_emacs_expect_t () {
\r
544 > > test "$#" = 2 && { prereq=$1; shift; } || prereq=
\r
545 > > test "$#" = 1 ||
\r
546 > > @@ -565,10 +575,9 @@ notmuch_show_sanitize_all ()
\r
548 > > notmuch_json_show_sanitize ()
\r
550 > > - sed -e 's|, |,\n |g' | \
\r
552 > > - -e 's|"id": "[^"]*",|"id": "XXXXX",|' \
\r
553 > > - -e 's|"filename": "[^"]*",|"filename": "YYYYY",|'
\r
555 > > + -e 's|"id": "[^"]*",|"id": "XXXXX",|g' \
\r
556 > > + -e 's|"filename": "[^"]*",|"filename": "YYYYY",|g'
\r
559 > > # End of notmuch helper functions
\r