Re: [PATCH v2] test: Add test for messages with missing headers
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 8 Aug 2012 18:47:49 +0000 (21:47 +0300)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:59 +0000 (09:48 -0800)
29/7d8cc1fe0328d0a54099d141ede33a37a0e056 [new file with mode: 0644]

diff --git a/29/7d8cc1fe0328d0a54099d141ede33a37a0e056 b/29/7d8cc1fe0328d0a54099d141ede33a37a0e056
new file mode 100644 (file)
index 0000000..e91524d
--- /dev/null
@@ -0,0 +1,336 @@
+Return-Path: <tomi.ollila@iki.fi>\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 1877F431FBD\r
+       for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 11:47:43 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       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 RJlYXhFsvrvo for <notmuch@notmuchmail.org>;\r
+       Wed,  8 Aug 2012 11:47:41 -0700 (PDT)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 6B127431FAE\r
+       for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 11:47:41 -0700 (PDT)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id E59CD1002A4; Wed,  8 Aug 2012 21:47:49 +0300 (EEST)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Austin Clements <amdragon@MIT.EDU>\r
+Subject: Re: [PATCH v2] test: Add test for messages with missing headers\r
+In-Reply-To: <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
+       <20120808154608.GD11179@mit.edu>\r
+User-Agent: Notmuch/0.13.2+128~g07453d8 (http://notmuchmail.org) Emacs/23.1.1\r
+       (x86_64-redhat-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Wed, 08 Aug 2012 21:47:49 +0300\r
+Message-ID: <m2ehnhfcfe.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\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 18:47:43 -0000\r
+\r
+On Wed, Aug 08 2012, Austin Clements <amdragon@MIT.EDU> wrote:\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,\r
+> object_pairs_hook=collections.OrderedDict), sys.stdout, indent=4)'\r
+\r
+ack.\r
+\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),\r
+> codecs.getwriter("utf8")(sys.stdout), indent=4, ensure_ascii=False)'\r
+\r
+nice.\r
+\r
+>\r
+> Though I think that, for test canonicalization, \uNNNN is probably\r
+> less error/locale prone.\r
+\r
+true.\r
+\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
+Why not, one from scratch, without looking any source there is already >;)\r
+\r
+Well, you're right; the json.tool version python 2.6 provides is good --\r
+-- ordering and those \uNNNN:s doesn't really matter.\r
+Probably thinking (or planning!) anything else at this time is waste of time.\r
+\r
+At least these 2 questions remain:\r
+\r
+Is the test requirement of python 2.6 suitable/acceptable ?\r
+\r
+How do we pretty-print S-expression syntax ;) ?\r
+\r
+\r
+Tomi\r
+\r
+\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
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r