--- /dev/null
+Return-Path: <amdragon@mit.edu>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+ by olra.theworths.org (Postfix) with ESMTP id 2238F431FBD\r
+ for <notmuch@notmuchmail.org>; Wed, 8 Aug 2012 08:46:13 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+ by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+ with ESMTP id EPk1K47ghroK for <notmuch@notmuchmail.org>;\r
+ Wed, 8 Aug 2012 08:46:12 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU\r
+ [18.9.25.15])\r
+ by olra.theworths.org (Postfix) with ESMTP id 19199431FAE\r
+ for <notmuch@notmuchmail.org>; Wed, 8 Aug 2012 08:46:12 -0700 (PDT)\r
+X-AuditID: 1209190f-b7f306d0000008b4-51-502289c3e2eb\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id 06.15.02228.3C982205; Wed, 8 Aug 2012 11:46:11 -0400 (EDT)\r
+Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id q78FkAjX011907; \r
+ Wed, 8 Aug 2012 11:46:11 -0400\r
+Received: from awakening.csail.mit.edu (awakening.csail.mit.edu [18.26.4.91])\r
+ (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q78Fk9l8018579\r
+ (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT);\r
+ Wed, 8 Aug 2012 11:46:10 -0400 (EDT)\r
+Received: from amthrax by awakening.csail.mit.edu with local (Exim 4.77)\r
+ (envelope-from <amdragon@mit.edu>)\r
+ id 1Sz8SW-0006ZA-Se; Wed, 08 Aug 2012 11:46:08 -0400\r
+Date: Wed, 8 Aug 2012 11:46:08 -0400\r
+From: Austin Clements <amdragon@MIT.EDU>\r
+To: Tomi Ollila <tomi.ollila@iki.fi>\r
+Subject: Re: [PATCH v2] test: Add test for messages with missing headers\r
+Message-ID: <20120808154608.GD11179@mit.edu>\r
+References: <1344374501-28185-1-git-send-email-amdragon@mit.edu>\r
+ <1344389313-7886-1-git-send-email-amdragon@mit.edu>\r
+ <m2k3x9olfl.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+Content-Disposition: inline\r
+In-Reply-To: <m2k3x9olfl.fsf@guru.guru-group.fi>\r
+User-Agent: Mutt/1.5.21 (2010-09-15)\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFmphleLIzCtJLcpLzFFi42IR4hRV1j3cqRRg8HuVhsX1mzOZLd6snMfq\r
+ wORx+OtCFo9nq24xBzBFcdmkpOZklqUW6dslcGV8mTuHsWCuTcWPSZuYGxgPaHQxcnJICJhI\r
+ PJ74iRHCFpO4cG89WxcjF4eQwD5Gia5PGxkhnPWMEq82f4RyTjBJTJq+mAXCWcIoseJzN3MX\r
+ IwcHi4CKxNf/7CCj2AQ0JLbtXw42VgQo/KBtPSuIzSwgLfHtdzMTiC0s4CHx4O18sDivgI7E\r
+ vCtrWCFmzmGU+L+jnR0iIShxcuYTFohmLYkb/14ygewCGbT8HwdImFPAQKLl4UewmaJAu6ac\r
+ 3MY2gVFoFpLuWUi6ZyF0L2BkXsUom5JbpZubmJlTnJqsW5ycmJeXWqRropebWaKXmlK6iREc\r
+ 2JL8Oxi/HVQ6xCjAwajEwxudrBggxJpYVlyZe4hRkoNJSZTXsk0pQIgvKT+lMiOxOCO+qDQn\r
+ tfgQowQHs5II79tgoBxvSmJlVWpRPkxKmoNFSZz3aspNfyGB9MSS1OzU1ILUIpisDAeHkgSv\r
+ NzCChQSLUtNTK9Iyc0oQ0kwcnCDDeYCGb+0AGV5ckJhbnJkOkT/FqCglzssB0iwAksgozYPr\r
+ hSWeV4ziQK8I8zKDVPEAkxZc9yugwUxAgw+Lgg0uSURISTUwqu5OsubWEL/J/+FsjcYig7xZ\r
+ /2RZ/ZpEPY5cls403LX4tNai4zPKF/3lzn8k+dRGIuMTc1GZ/4JjSiU+P99XCEY/tMn/z/rc\r
+ T6z38NuHi188y7j9p6BOikGEV7ckWFj7MIejY/SbZXwNaUnB92vb9KZHzBXavMfzteBSnh2P\r
+ jfc13poYVC6rxFKckWioxVxUnAgAg5y81hcDAAA=\r
+Cc: notmuch@notmuchmail.org\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+ <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+ <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 08 Aug 2012 15:46:13 -0000\r
+\r
+Quoth Tomi Ollila on Aug 08 at 11:08 am:\r
+> On Wed, Aug 08 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+> \r
+> > Currently the JSON tests for search and show are broken because\r
+> > notmuch attempts to dereference a NULL pointer.\r
+> > ---\r
+> > This version fixes the "Show: text" test so that it sanitize its\r
+> > output and doesn't hard-code my test paths.\r
+> \r
+> +1\r
+> \r
+> Tomi\r
+> \r
+> w/ python json(.tool) the original order cannot be preserved as the parser\r
+> stores content into dictionary -- without sorting those came in some\r
+> internal python order... the following code could be used to use less\r
+\r
+To be fair, it can output them in original order, but doing so\r
+requires Python 2.7:\r
+\r
+python -c 'import sys,json,collections; json.dump(json.load(sys.stdin, object_pairs_hook=collections.OrderedDict), sys.stdout, indent=4)'\r
+\r
+> indentation, though:\r
+> \r
+> python -c 'import sys,json; j = json.load(sys.stdin);\r
+> json.dump(j, sys.stdout, sort_keys=True, indent=2)' < input_file\r
+> \r
+> The other "problem" with json.tool is that it converts non-ascii chars\r
+> to \uNNNN values :/.\r
+\r
+This one doesn't require 2.7.\r
+\r
+python -c 'import sys,json,codecs; json.dump(json.load(sys.stdin), codecs.getwriter("utf8")(sys.stdout), indent=4, ensure_ascii=False)'\r
+\r
+Though I think that, for test canonicalization, \uNNNN is probably\r
+less error/locale prone.\r
+\r
+> What we could do is to dig a simple c json formatter -- someday in the\r
+> future, maybe -- but for *now* this is the best we can have :D\r
+\r
+Not another JSON parser/printer!\r
+\r
+> >\r
+> > test/missing-headers | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++\r
+> > test/notmuch-test | 1 +\r
+> > 2 files changed, 163 insertions(+)\r
+> > create mode 100755 test/missing-headers\r
+> >\r
+> > diff --git a/test/missing-headers b/test/missing-headers\r
+> > new file mode 100755\r
+> > index 0000000..e79f922\r
+> > --- /dev/null\r
+> > +++ b/test/missing-headers\r
+> > @@ -0,0 +1,162 @@\r
+> > +#!/usr/bin/env bash\r
+> > +test_description='messages with missing headers'\r
+> > +. ./test-lib.sh\r
+> > +\r
+> > +# Notmuch requires at least one of from, subject, or to or it will\r
+> > +# ignore the file. Generate two messages so that together they cover\r
+> > +# all possible missing headers. We also give one of the messages a\r
+> > +# date to ensure stable result ordering.\r
+> > +\r
+> > +cat <<EOF > "${MAIL_DIR}/msg-2"\r
+> > +To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > +Date: Fri, 05 Jan 2001 15:43:57 +0000\r
+> > +\r
+> > +Body\r
+> > +EOF\r
+> > +\r
+> > +cat <<EOF > "${MAIL_DIR}/msg-1"\r
+> > +From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > +\r
+> > +Body\r
+> > +EOF\r
+> > +\r
+> > +NOTMUCH_NEW\r
+> > +\r
+> > +test_begin_subtest "Search: text"\r
+> > +output=$(notmuch search '*' | notmuch_search_sanitize)\r
+> > +test_expect_equal "$output" "\\r
+> > +thread:XXX 2001-01-05 [1/1] (null); (inbox unread)\r
+> > +thread:XXX 1970-01-01 [1/1] Notmuch Test Suite; (inbox unread)"\r
+> > +\r
+> > +test_begin_subtest "Search: json"\r
+> > +test_subtest_known_broken\r
+> > +output=$(notmuch search --format=json '*' | notmuch_search_sanitize)\r
+> > +test_expect_equal_json "$output" '\r
+> > +[\r
+> > + {\r
+> > + "authors": "",\r
+> > + "date_relative": "2001-01-05",\r
+> > + "matched": 1,\r
+> > + "subject": "",\r
+> > + "tags": [\r
+> > + "inbox",\r
+> > + "unread"\r
+> > + ],\r
+> > + "thread": "XXX",\r
+> > + "timestamp": 978709437,\r
+> > + "total": 1\r
+> > + },\r
+> > + {\r
+> > + "authors": "Notmuch Test Suite",\r
+> > + "date_relative": "1970-01-01",\r
+> > + "matched": 1,\r
+> > + "subject": "",\r
+> > + "tags": [\r
+> > + "inbox",\r
+> > + "unread"\r
+> > + ],\r
+> > + "thread": "XXX",\r
+> > + "timestamp": 0,\r
+> > + "total": 1\r
+> > + }\r
+> > +]'\r
+> > +\r
+> > +test_begin_subtest "Show: text"\r
+> > +output=$(notmuch show '*' | notmuch_show_sanitize)\r
+> > +test_expect_equal "$output" "\\r
+> > +\f\r
+message{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-2\r
+> > +\f\r
+header{\r
+> > + (2001-01-05) (inbox unread)\r
+> > +Subject: (null)\r
+> > +From: (null)\r
+> > +To: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > +Date: Fri, 05 Jan 2001 15:43:57 +0000\r
+> > +\f\r
+header}\r
+> > +\f\r
+body{\r
+> > +\f\r
+part{ ID: 1, Content-type: text/plain\r
+> > +Body\r
+> > +\f\r
+part}\r
+> > +\f\r
+body}\r
+> > +\f\r
+message}\r
+> > +\f\r
+message{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-1\r
+> > +\f\r
+header{\r
+> > +Notmuch Test Suite <test_suite@notmuchmail.org> (1970-01-01) (inbox unread)\r
+> > +Subject: (null)\r
+> > +From: Notmuch Test Suite <test_suite@notmuchmail.org>\r
+> > +Date: Thu, 01 Jan 1970 00:00:00 +0000\r
+> > +\f\r
+header}\r
+> > +\f\r
+body{\r
+> > +\f\r
+part{ ID: 1, Content-type: text/plain\r
+> > +Body\r
+> > +\f\r
+part}\r
+> > +\f\r
+body}\r
+> > +\f\r
+message}"\r
+> > +\r
+> > +test_begin_subtest "Show: json"\r
+> > +test_subtest_known_broken\r
+> > +output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize)\r
+> > +test_expect_equal_json "$output" '\r
+> > +[\r
+> > + [\r
+> > + [\r
+> > + {\r
+> > + "body": [\r
+> > + {\r
+> > + "content": "Body\n",\r
+> > + "content-type": "text/plain",\r
+> > + "id": 1\r
+> > + }\r
+> > + ],\r
+> > + "date_relative": "2001-01-05",\r
+> > + "excluded": false,\r
+> > + "filename": "YYYYY",\r
+> > + "headers": {\r
+> > + "Date": "Fri, 05 Jan 2001 15:43:57 +0000",\r
+> > + "From": "",\r
+> > + "Subject": "",\r
+> > + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>"\r
+> > + },\r
+> > + "id": "XXXXX",\r
+> > + "match": true,\r
+> > + "tags": [\r
+> > + "inbox",\r
+> > + "unread"\r
+> > + ],\r
+> > + "timestamp": 978709437\r
+> > + },\r
+> > + []\r
+> > + ]\r
+> > + ],\r
+> > + [\r
+> > + [\r
+> > + {\r
+> > + "body": [\r
+> > + {\r
+> > + "content": "Body\n",\r
+> > + "content-type": "text/plain",\r
+> > + "id": 1\r
+> > + }\r
+> > + ],\r
+> > + "date_relative": "1970-01-01",\r
+> > + "excluded": false,\r
+> > + "filename": "YYYYY",\r
+> > + "headers": {\r
+> > + "Date": "Thu, 01 Jan 1970 00:00:00 +0000",\r
+> > + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> > + "Subject": ""\r
+> > + },\r
+> > + "id": "XXXXX",\r
+> > + "match": true,\r
+> > + "tags": [\r
+> > + "inbox",\r
+> > + "unread"\r
+> > + ],\r
+> > + "timestamp": 0\r
+> > + },\r
+> > + []\r
+> > + ]\r
+> > + ]\r
+> > +]'\r
+> > +\r
+> > +\r
+> > +test_done\r
+> > diff --git a/test/notmuch-test b/test/notmuch-test\r
+> > index ea39dfc..cc732c3 100755\r
+> > --- a/test/notmuch-test\r
+> > +++ b/test/notmuch-test\r
+> > @@ -59,6 +59,7 @@ TESTS="\r
+> > emacs-address-cleaning\r
+> > emacs-hello\r
+> > emacs-show\r
+> > + missing-headers\r
+> > "\r
+> > TESTS=${NOTMUCH_TESTS:=$TESTS}\r
+> > \r
+> >\r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r