[PATCH 3/3] debian packaging: drop dep notmuch-mutt -> libmailtools-perl
[notmuch-archives.git] / 33 / fbb2c3844969060a307fd75b01a614f472ff7c
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 5DB0E429E37\r
6         for <notmuch@notmuchmail.org>; Thu,  2 Aug 2012 18:15:21 -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: -0.7\r
10 X-Spam-Level: \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 uLvByIttvw5i for <notmuch@notmuchmail.org>;\r
16         Thu,  2 Aug 2012 18:15:15 -0700 (PDT)\r
17 Received: from dmz-mailsec-scanner-3.mit.edu (DMZ-MAILSEC-SCANNER-3.MIT.EDU\r
18         [18.9.25.14])\r
19         by olra.theworths.org (Postfix) with ESMTP id 6998F429E25\r
20         for <notmuch@notmuchmail.org>; Thu,  2 Aug 2012 18:15:08 -0700 (PDT)\r
21 X-AuditID: 1209190e-b7fb56d0000008b2-05-501b261b98f6\r
22 Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
23         by dmz-mailsec-scanner-3.mit.edu (Symantec Messaging Gateway) with SMTP\r
24         id C1.97.02226.B162B105; Thu,  2 Aug 2012 21:15:07 -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 q731F6Fj008874; \r
27         Thu, 2 Aug 2012 21:15:06 -0400\r
28 Received: from drake.dyndns.org\r
29         (209-6-116-242.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
30         [209.6.116.242]) (authenticated bits=0)\r
31         (User authenticated as amdragon@ATHENA.MIT.EDU)\r
32         by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q731F4cr002784\r
33         (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
34         Thu, 2 Aug 2012 21:15:05 -0400 (EDT)\r
35 Received: from amthrax by drake.dyndns.org with local (Exim 4.77)\r
36         (envelope-from <amdragon@mit.edu>)\r
37         id 1Sx6To-0003w9-0Z; Thu, 02 Aug 2012 21:15:04 -0400\r
38 From: Austin Clements <amdragon@MIT.EDU>\r
39 To: notmuch@notmuchmail.org\r
40 Subject:\r
41  [PATCH v3 01/13] test: Uniformly canonicalize actual and expected JSON\r
42 Date: Thu,  2 Aug 2012 21:14:47 -0400\r
43 Message-Id: <1343956499-14543-2-git-send-email-amdragon@mit.edu>\r
44 X-Mailer: git-send-email 1.7.10\r
45 In-Reply-To: <1343956499-14543-1-git-send-email-amdragon@mit.edu>\r
46 References: <1343956499-14543-1-git-send-email-amdragon@mit.edu>\r
47 MIME-Version: 1.0\r
48 Content-Type: text/plain; charset=UTF-8\r
49 Content-Transfer-Encoding: 8bit\r
50 X-Brightmail-Tracker:\r
51  H4sIAAAAAAAAA+NgFprJKsWRmVeSWpSXmKPExsUixG6nriujJh1gsFDGYvVcHovrN2cyW7xZ\r
52         OY/Vgdlj56y77B6Hvy5k8Xi26hZzAHMUl01Kak5mWWqRvl0CV8bfCy4Fi/YwVjxYM4uxgbFn\r
53         EWMXIyeHhICJxLl3a5ggbDGJC/fWs3UxcnEICexjlOiYsIkZwlnPKLHx1xqozEMmibaPx9gh\r
54         nLmMEvuPt7KD9LMJaEhs278cbK6IgLTEzruzWUFsZoE4iS1T/oPFhQWKJU5e2QFWzyKgKjFp\r
55         23Gw3bwCDhLHZq9kh7hDXuLp/T42EJtTwFHi9dtXYL1CQDXL27pZIeoFJU7OfMLSxcgBNF9d\r
56         Yv08IYhV8hLNW2czT2AUmoWkahZC1SwkVQsYmVcxyqbkVunmJmbmFKcm6xYnJ+blpRbpGuvl\r
57         ZpbopaaUbmIEhTqnJN8Oxq8HlQ4xCnAwKvHwGktKBwixJpYVV+YeYpTkYFIS5WVWAgrxJeWn\r
58         VGYkFmfEF5XmpBYfYpTgYFYS4a1aIhUgxJuSWFmVWpQPk5LmYFES572SctNfSCA9sSQ1OzW1\r
59         ILUIJivDwaEkwdunCjRUsCg1PbUiLTOnBCHNxMEJMpwHaHg1SA1vcUFibnFmOkT+FKMux+3D\r
60         L24zCrHk5eelSonzpoMUCYAUZZTmwc2BpahXjOJAbwnztoNU8QDTG9ykV0BLmICW2JmBfFBc\r
61         koiQkmpgbL7iePbK9q+HJ5dLs7AFXv49aeVdhZTgzZm3Ndrn75I6tv+bq86jZ5sEPbznL/L4\r
62         Nc1uzQfbXWHTVof9yF32/aSerGu/dPPz/w5LzPbMWfPkwYQJ/JFn73MemnKC4cX8b7ukL66/\r
63         0LmfcU7utYigsP89F7n4Uh+0xf3cl/ruQb8Cs50dk+GH39+UWIozEg21mIuKEwGIEFErLAMA        AA==\r
64 Cc: tomi.ollila@iki.fi\r
65 X-BeenThere: notmuch@notmuchmail.org\r
66 X-Mailman-Version: 2.1.13\r
67 Precedence: list\r
68 List-Id: "Use and development of the notmuch mail system."\r
69         <notmuch.notmuchmail.org>\r
70 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
71         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
72 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
73 List-Post: <mailto:notmuch@notmuchmail.org>\r
74 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
75 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
76         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
77 X-List-Received-Date: Fri, 03 Aug 2012 01:15:22 -0000\r
78 \r
79 Previously, we used a variety of ad-hoc canonicalizations for JSON\r
80 output in the test suite, but were ultimately very sensitive to JSON\r
81 irrelevancies such as whitespace.  This introduces a new test\r
82 comparison function, test_expect_equal_json, that first pretty-prints\r
83 *both* the actual and expected JSON and the compares the result.\r
84 \r
85 The current implementation of this simply uses Python's json.tool to\r
86 perform pretty-printing (with a fallback to the identity function if\r
87 parsing fails).  However, since the interface it introduces is\r
88 semantically high-level, we could swap in other mechanisms in the\r
89 future, such as another pretty-printer or something that does not\r
90 re-order object keys (if we decide that we care about that).\r
91 \r
92 In general, this patch does not remove the existing ad-hoc\r
93 canonicalization because it does no harm.  We do have to remove the\r
94 newline-after-comma rule from notmuch_json_show_sanitize and\r
95 filter_show_json because it results in invalid JSON that cannot be\r
96 pretty-printed.\r
97 \r
98 Most of this patch simply replaces test_expect_equal and\r
99 test_expect_equal_file with test_expect_equal_json.  It changes the\r
100 expected JSON in a few places where sanitizers had placed newlines\r
101 after commas inside strings.\r
102 ---\r
103  test/crypto        |   37 +++++++++++++++----------------------\r
104  test/json          |   14 +++++++-------\r
105  test/maildir-sync  |   11 ++++-------\r
106  test/multipart     |   34 +++++++++++++++-------------------\r
107  test/search-output |    2 +-\r
108  test/test-lib.sh   |   17 +++++++++++++----\r
109  6 files changed, 55 insertions(+), 60 deletions(-)\r
110 \r
111 diff --git a/test/crypto b/test/crypto\r
112 index be752b1..5dd14c4 100755\r
113 --- a/test/crypto\r
114 +++ b/test/crypto\r
115 @@ -51,8 +51,7 @@ expected='[[[{"id": "XXXXX",\r
116   "headers": {"Subject": "test signed message 001",\r
117   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
118   "To": "test_suite@notmuchmail.org",\r
119 - "Date": "Sat,\r
120 - 01 Jan 2000 12:00:00 +0000"},\r
121 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
122   "body": [{"id": 1,\r
123   "sigstatus": [{"status": "good",\r
124   "fingerprint": "'$FINGERPRINT'",\r
125 @@ -64,7 +63,7 @@ expected='[[[{"id": "XXXXX",\r
126   {"id": 3,\r
127   "content-type": "application/pgp-signature"}]}]},\r
128   []]]]'\r
129 -test_expect_equal \\r
130 +test_expect_equal_json \\r
131      "$output" \\r
132      "$expected"\r
133  \r
134 @@ -85,8 +84,7 @@ expected='[[[{"id": "XXXXX",\r
135   "headers": {"Subject": "test signed message 001",\r
136   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
137   "To": "test_suite@notmuchmail.org",\r
138 - "Date": "Sat,\r
139 - 01 Jan 2000 12:00:00 +0000"},\r
140 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
141   "body": [{"id": 1,\r
142   "sigstatus": [{"status": "good",\r
143   "fingerprint": "'$FINGERPRINT'",\r
144 @@ -99,7 +97,7 @@ expected='[[[{"id": "XXXXX",\r
145   {"id": 3,\r
146   "content-type": "application/pgp-signature"}]}]},\r
147   []]]]'\r
148 -test_expect_equal \\r
149 +test_expect_equal_json \\r
150      "$output" \\r
151      "$expected"\r
152  \r
153 @@ -119,8 +117,7 @@ expected='[[[{"id": "XXXXX",\r
154   "headers": {"Subject": "test signed message 001",\r
155   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
156   "To": "test_suite@notmuchmail.org",\r
157 - "Date": "Sat,\r
158 - 01 Jan 2000 12:00:00 +0000"},\r
159 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
160   "body": [{"id": 1,\r
161   "sigstatus": [{"status": "error",\r
162   "keyid": "'$(echo $FINGERPRINT | cut -c 25-)'",\r
163 @@ -132,7 +129,7 @@ expected='[[[{"id": "XXXXX",\r
164   {"id": 3,\r
165   "content-type": "application/pgp-signature"}]}]},\r
166   []]]]'\r
167 -test_expect_equal \\r
168 +test_expect_equal_json \\r
169      "$output" \\r
170      "$expected"\r
171  mv "${GNUPGHOME}"{.bak,}\r
172 @@ -193,8 +190,7 @@ expected='[[[{"id": "XXXXX",\r
173   "headers": {"Subject": "test encrypted message 001",\r
174   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
175   "To": "test_suite@notmuchmail.org",\r
176 - "Date": "Sat,\r
177 - 01 Jan 2000 12:00:00 +0000"},\r
178 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
179   "body": [{"id": 1,\r
180   "encstatus": [{"status": "good"}],\r
181   "sigstatus": [],\r
182 @@ -210,7 +206,7 @@ expected='[[[{"id": "XXXXX",\r
183   "content-type": "application/octet-stream",\r
184   "filename": "TESTATTACHMENT"}]}]}]},\r
185   []]]]'\r
186 -test_expect_equal \\r
187 +test_expect_equal_json \\r
188      "$output" \\r
189      "$expected"\r
190  \r
191 @@ -221,7 +217,7 @@ output=$(notmuch show --format=json --part=4 --decrypt subject:"test encrypted m\r
192  expected='{"id": 4,\r
193   "content-type": "text/plain",\r
194   "content": "This is a test encrypted message.\n"}'\r
195 -test_expect_equal \\r
196 +test_expect_equal_json \\r
197      "$output" \\r
198      "$expected"\r
199  \r
200 @@ -248,8 +244,7 @@ expected='[[[{"id": "XXXXX",\r
201   "headers": {"Subject": "test encrypted message 001",\r
202   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
203   "To": "test_suite@notmuchmail.org",\r
204 - "Date": "Sat,\r
205 - 01 Jan 2000 12:00:00 +0000"},\r
206 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
207   "body": [{"id": 1,\r
208   "encstatus": [{"status": "bad"}],\r
209   "content-type": "multipart/encrypted",\r
210 @@ -258,7 +253,7 @@ expected='[[[{"id": "XXXXX",\r
211   {"id": 3,\r
212   "content-type": "application/octet-stream"}]}]},\r
213   []]]]'\r
214 -test_expect_equal \\r
215 +test_expect_equal_json \\r
216      "$output" \\r
217      "$expected"\r
218  mv "${GNUPGHOME}"{.bak,}\r
219 @@ -283,8 +278,7 @@ expected='[[[{"id": "XXXXX",\r
220   "headers": {"Subject": "test encrypted message 002",\r
221   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
222   "To": "test_suite@notmuchmail.org",\r
223 - "Date": "Sat,\r
224 - 01 Jan 2000 12:00:00 +0000"},\r
225 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
226   "body": [{"id": 1,\r
227   "encstatus": [{"status": "good"}],\r
228   "sigstatus": [{"status": "good",\r
229 @@ -298,7 +292,7 @@ expected='[[[{"id": "XXXXX",\r
230   "content-type": "text/plain",\r
231   "content": "This is another test encrypted message.\n"}]}]},\r
232   []]]]'\r
233 -test_expect_equal \\r
234 +test_expect_equal_json \\r
235      "$output" \\r
236      "$expected"\r
237  \r
238 @@ -338,8 +332,7 @@ expected='[[[{"id": "XXXXX",\r
239   "headers": {"Subject": "test signed message 001",\r
240   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
241   "To": "test_suite@notmuchmail.org",\r
242 - "Date": "Sat,\r
243 - 01 Jan 2000 12:00:00 +0000"},\r
244 + "Date": "Sat, 01 Jan 2000 12:00:00 +0000"},\r
245   "body": [{"id": 1,\r
246   "sigstatus": [{"status": "error",\r
247   "keyid": "6D92612D94E46381",\r
248 @@ -351,7 +344,7 @@ expected='[[[{"id": "XXXXX",\r
249   {"id": 3,\r
250   "content-type": "application/pgp-signature"}]}]},\r
251   []]]]'\r
252 -test_expect_equal \\r
253 +test_expect_equal_json \\r
254      "$output" \\r
255      "$expected"\r
256  \r
257 diff --git a/test/json b/test/json\r
258 index 831e105..d86ee46 100755\r
259 --- a/test/json\r
260 +++ b/test/json\r
261 @@ -5,21 +5,21 @@ test_description="--format=json output"\r
262  test_begin_subtest "Show message: json"\r
263  add_message "[subject]=\"json-show-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-show-message\""\r
264  output=$(notmuch show --format=json "json-show-message")\r
265 -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
266 +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
267  \r
268  # This should be the same output as above.\r
269  test_begin_subtest "Show message: json --body=true"\r
270  output=$(notmuch show --format=json --body=true "json-show-message")\r
271 -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
272 +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
273  \r
274  test_begin_subtest "Show message: json --body=false"\r
275  output=$(notmuch show --format=json --body=false "json-show-message")\r
276 -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
277 +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
278  \r
279  test_begin_subtest "Search message: json"\r
280  add_message "[subject]=\"json-search-subject\"" "[date]=\"Sat, 01 Jan 2000 12:00:00 -0000\"" "[body]=\"json-search-message\""\r
281  output=$(notmuch search --format=json "json-search-message" | notmuch_json_show_sanitize | notmuch_search_sanitize)\r
282 -test_expect_equal "$output" "[{\"thread\": \"XXX\",\r
283 +test_expect_equal_json "$output" "[{\"thread\": \"XXX\",\r
284   \"timestamp\": 946728000,\r
285   \"date_relative\": \"2000-01-01\",\r
286   \"matched\": 1,\r
287 @@ -32,7 +32,7 @@ test_expect_equal "$output" "[{\"thread\": \"XXX\",\r
288  test_begin_subtest "Show message: json, utf-8"\r
289  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
290  output=$(notmuch show --format=json "jsön-show-méssage")\r
291 -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
292 +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
293  \r
294  test_begin_subtest "Show message: json, inline attachment filename"\r
295  subject='json-show-inline-attachment-filename'\r
296 @@ -45,12 +45,12 @@ emacs_deliver_message \\r
297       (insert \"Message-ID: <$id>\n\")"\r
298  output=$(notmuch show --format=json "id:$id")\r
299  filename=$(notmuch search --output=files "id:$id")\r
300 -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
301 +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
302  \r
303  test_begin_subtest "Search message: json, utf-8"\r
304  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
305  output=$(notmuch search --format=json "jsön-search-méssage" | notmuch_json_show_sanitize | notmuch_search_sanitize)\r
306 -test_expect_equal "$output" "[{\"thread\": \"XXX\",\r
307 +test_expect_equal_json "$output" "[{\"thread\": \"XXX\",\r
308   \"timestamp\": 946728000,\r
309   \"date_relative\": \"2000-01-01\",\r
310   \"matched\": 1,\r
311 diff --git a/test/maildir-sync b/test/maildir-sync\r
312 index 01348d3..b748d04 100755\r
313 --- a/test/maildir-sync\r
314 +++ b/test/maildir-sync\r
315 @@ -4,11 +4,9 @@ test_description="maildir synchronization"\r
316  \r
317  . ./test-lib.sh\r
318  \r
319 -# Much easier to examine differences if the "notmuch show\r
320 -# --format=json" output includes some newlines. Also, need to avoid\r
321 -# including the local value of MAIL_DIR in the result.\r
322 +# Avoid including the local value of MAIL_DIR in the result.\r
323  filter_show_json() {\r
324 -    sed -e 's/, /,\n/g'  | sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"\r
325 +    sed -e "s|${MAIL_DIR}/|MAIL_DIR/|"\r
326      echo\r
327  }\r
328  \r
329 @@ -44,7 +42,7 @@ test_expect_equal "$output" "adding-replied-tag:2,RS"\r
330  \r
331  test_begin_subtest "notmuch show works with renamed file (without notmuch new)"\r
332  output=$(notmuch show --format=json id:${gen_msg_id} | filter_show_json)\r
333 -test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",\r
334 +test_expect_equal_json "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",\r
335  "match": true,\r
336  "excluded": false,\r
337  "filename": "MAIL_DIR/cur/adding-replied-tag:2,RS",\r
338 @@ -54,8 +52,7 @@ test_expect_equal "$output" '[[[{"id": "adding-replied-tag@notmuch-test-suite",\r
339  "headers": {"Subject": "Adding replied tag",\r
340  "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
341  "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
342 -"Date": "Fri,\r
343 -05 Jan 2001 15:43:57 +0000"},\r
344 +"Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
345  "body": [{"id": 1,\r
346  "content-type": "text/plain",\r
347  "content": "This is just a test message (#3)\n"}]},\r
348 diff --git a/test/multipart b/test/multipart\r
349 index 72d3927..3ccf27f 100755\r
350 --- a/test/multipart\r
351 +++ b/test/multipart\r
352 @@ -334,7 +334,7 @@ cat <<EOF >EXPECTED\r
353  {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
354  {"id": 9, "content-type": "application/pgp-signature"}]}]}\r
355  EOF\r
356 -test_expect_equal_file OUTPUT EXPECTED\r
357 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
358  \r
359  test_begin_subtest "--format=json --part=1, message body"\r
360  notmuch show --format=json --part=1 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
361 @@ -351,7 +351,7 @@ cat <<EOF >EXPECTED\r
362  {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}, \r
363  {"id": 9, "content-type": "application/pgp-signature"}]}\r
364  EOF\r
365 -test_expect_equal_file OUTPUT EXPECTED\r
366 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
367  \r
368  test_begin_subtest "--format=json --part=2, multipart/mixed"\r
369  notmuch show --format=json --part=2 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
370 @@ -366,7 +366,7 @@ cat <<EOF >EXPECTED\r
371  {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}, \r
372  {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}]}\r
373  EOF\r
374 -test_expect_equal_file OUTPUT EXPECTED\r
375 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
376  \r
377  test_begin_subtest "--format=json --part=3, rfc822 part"\r
378  notmuch show --format=json --part=3 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
379 @@ -378,7 +378,7 @@ cat <<EOF >EXPECTED\r
380  {"id": 5, "content-type": "text/html"}, \r
381  {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]}\r
382  EOF\r
383 -test_expect_equal_file OUTPUT EXPECTED\r
384 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
385  \r
386  test_begin_subtest "--format=json --part=4, rfc822's multipart/alternative"\r
387  notmuch show --format=json --part=4 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
388 @@ -389,7 +389,7 @@ cat <<EOF >EXPECTED\r
389  {"id": 5, "content-type": "text/html"}, \r
390  {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}]}\r
391  EOF\r
392 -test_expect_equal_file OUTPUT EXPECTED\r
393 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
394  \r
395  test_begin_subtest "--format=json --part=5, rfc822's html part"\r
396  notmuch show --format=json --part=5 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
397 @@ -398,7 +398,7 @@ cat <<EOF >EXPECTED\r
398  \r
399  {"id": 5, "content-type": "text/html"}\r
400  EOF\r
401 -test_expect_equal_file OUTPUT EXPECTED\r
402 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
403  \r
404  test_begin_subtest "--format=json --part=6, rfc822's text part"\r
405  notmuch show --format=json --part=6 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
406 @@ -407,7 +407,7 @@ cat <<EOF >EXPECTED\r
407  \r
408  {"id": 6, "content-type": "text/plain", "content": "This is an embedded message, with a multipart/alternative part.\n"}\r
409  EOF\r
410 -test_expect_equal_file OUTPUT EXPECTED\r
411 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
412  \r
413  test_begin_subtest "--format=json --part=7, inline attachment"\r
414  notmuch show --format=json --part=7 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
415 @@ -416,7 +416,7 @@ cat <<EOF >EXPECTED\r
416  \r
417  {"id": 7, "content-type": "text/plain", "filename": "attachment", "content": "This is a text attachment.\n"}\r
418  EOF\r
419 -test_expect_equal_file OUTPUT EXPECTED\r
420 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
421  \r
422  test_begin_subtest "--format=json --part=8, plain text part"\r
423  notmuch show --format=json --part=8 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
424 @@ -425,7 +425,7 @@ cat <<EOF >EXPECTED\r
425  \r
426  {"id": 8, "content-type": "text/plain", "content": "And this message is signed.\n\n-Carl\n"}\r
427  EOF\r
428 -test_expect_equal_file OUTPUT EXPECTED\r
429 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
430  \r
431  test_begin_subtest "--format=json --part=9, pgp signature (unverified)"\r
432  notmuch show --format=json --part=9 'id:87liy5ap00.fsf@yoom.home.cworth.org' | sed 's|{"id":|\n{"id":|g' >OUTPUT\r
433 @@ -434,7 +434,7 @@ cat <<EOF >EXPECTED\r
434  \r
435  {"id": 9, "content-type": "application/pgp-signature"}\r
436  EOF\r
437 -test_expect_equal_file OUTPUT EXPECTED\r
438 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
439  \r
440  test_expect_success \\r
441      "--format=json --part=10, no part, expect error" \\r
442 @@ -617,8 +617,7 @@ notmuch reply --format=json 'id:87liy5ap00.fsf@yoom.home.cworth.org' | notmuch_j\r
443  cat <<EOF >EXPECTED\r
444  {"reply-headers": {"Subject": "Re: Multipart message",\r
445   "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
446 - "To": "Carl Worth <cworth@cworth.org>,\r
447 - cworth@cworth.org",\r
448 + "To": "Carl Worth <cworth@cworth.org>, cworth@cworth.org",\r
449   "In-reply-to": "<87liy5ap00.fsf@yoom.home.cworth.org>",\r
450   "References": " <87liy5ap00.fsf@yoom.home.cworth.org>"},\r
451   "original": {"id": "XXXXX",\r
452 @@ -631,8 +630,7 @@ cat <<EOF >EXPECTED\r
453   "headers": {"Subject": "Multipart message",\r
454   "From": "Carl Worth <cworth@cworth.org>",\r
455   "To": "cworth@cworth.org",\r
456 - "Date": "Fri,\r
457 - 05 Jan 2001 15:43:57 +0000"},\r
458 + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
459   "body": [{"id": 1,\r
460   "content-type": "multipart/signed",\r
461   "content": [{"id": 2,\r
462 @@ -642,16 +640,14 @@ cat <<EOF >EXPECTED\r
463   "content": [{"headers": {"Subject": "html message",\r
464   "From": "Carl Worth <cworth@cworth.org>",\r
465   "To": "cworth@cworth.org",\r
466 - "Date": "Fri,\r
467 - 05 Jan 2001 15:42:57 +0000"},\r
468 + "Date": "Fri, 05 Jan 2001 15:42:57 +0000"},\r
469   "body": [{"id": 4,\r
470   "content-type": "multipart/alternative",\r
471   "content": [{"id": 5,\r
472   "content-type": "text/html"},\r
473   {"id": 6,\r
474   "content-type": "text/plain",\r
475 - "content": "This is an embedded message,\r
476 - with a multipart/alternative part.\n"}]}]}]},\r
477 + "content": "This is an embedded message, with a multipart/alternative part.\n"}]}]}]},\r
478   {"id": 7,\r
479   "content-type": "text/plain",\r
480   "filename": "YYYYY",\r
481 @@ -662,7 +658,7 @@ cat <<EOF >EXPECTED\r
482   {"id": 9,\r
483   "content-type": "application/pgp-signature"}]}]}}\r
484  EOF\r
485 -test_expect_equal_file OUTPUT EXPECTED\r
486 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
487  \r
488  test_begin_subtest "'notmuch show --part' does not corrupt a part with CRLF pair"\r
489  notmuch show --format=raw --part=3 id:base64-part-with-crlf > crlf.out\r
490 diff --git a/test/search-output b/test/search-output\r
491 index 8b57a43..c2a87eb 100755\r
492 --- a/test/search-output\r
493 +++ b/test/search-output\r
494 @@ -62,7 +62,7 @@ cat <<EOF >EXPECTED\r
495  "THREADID",\r
496  "THREADID"]\r
497  EOF\r
498 -test_expect_equal_file OUTPUT EXPECTED\r
499 +test_expect_equal_json "$(cat OUTPUT)" "$(cat EXPECTED)"\r
500  \r
501  test_begin_subtest "--output=messages"\r
502  notmuch search --output=messages '*' >OUTPUT\r
503 diff --git a/test/test-lib.sh b/test/test-lib.sh\r
504 index 06aaea2..791d2dc 100644\r
505 --- a/test/test-lib.sh\r
506 +++ b/test/test-lib.sh\r
507 @@ -512,6 +512,16 @@ test_expect_equal_file ()\r
508      fi\r
509  }\r
510  \r
511 +# Like test_expect_equal, but arguments are JSON expressions to be\r
512 +# canonicalized before diff'ing.  If an argument cannot be parsed, it\r
513 +# is used unchanged so that there's something to diff against.\r
514 +test_expect_equal_json () {\r
515 +    output=$(echo "$1" | python -mjson.tool || echo "$1")\r
516 +    expected=$(echo "$2" | python -mjson.tool || echo "$2")\r
517 +    shift 2\r
518 +    test_expect_equal "$output" "$expected" "$@"\r
519 +}\r
520 +\r
521  test_emacs_expect_t () {\r
522         test "$#" = 2 && { prereq=$1; shift; } || prereq=\r
523         test "$#" = 1 ||\r
524 @@ -565,10 +575,9 @@ notmuch_show_sanitize_all ()\r
525  \r
526  notmuch_json_show_sanitize ()\r
527  {\r
528 -    sed -e 's|, |,\n |g' | \\r
529 -       sed \\r
530 -       -e 's|"id": "[^"]*",|"id": "XXXXX",|' \\r
531 -       -e 's|"filename": "[^"]*",|"filename": "YYYYY",|'\r
532 +    sed \\r
533 +       -e 's|"id": "[^"]*",|"id": "XXXXX",|g' \\r
534 +       -e 's|"filename": "[^"]*",|"filename": "YYYYY",|g'\r
535  }\r
536  \r
537  # End of notmuch helper functions\r
538 -- \r
539 1.7.10\r
540 \r