Re: [PATCH v2] test: Add test for messages with missing headers
authorMark Walters <markwalters1009@gmail.com>
Wed, 8 Aug 2012 07:36:21 +0000 (08:36 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:48:58 +0000 (09:48 -0800)
9c/7a7f6be4394547369bc8120c55f04c8a0c1191 [new file with mode: 0644]

diff --git a/9c/7a7f6be4394547369bc8120c55f04c8a0c1191 b/9c/7a7f6be4394547369bc8120c55f04c8a0c1191
new file mode 100644 (file)
index 0000000..f89a4e9
--- /dev/null
@@ -0,0 +1,299 @@
+Return-Path: <m.walters@qmul.ac.uk>\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 6544C431FBD\r
+       for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 00:36:33 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.098\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
+       tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
+       NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 HDAI1lXYXCkB for <notmuch@notmuchmail.org>;\r
+       Wed,  8 Aug 2012 00:36:32 -0700 (PDT)\r
+Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
+       (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id AFEA5431FAE\r
+       for <notmuch@notmuchmail.org>; Wed,  8 Aug 2012 00:36:31 -0700 (PDT)\r
+Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
+       by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Sz0od-00027N-Eu; Wed, 08 Aug 2012 08:36:29 +0100\r
+Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
+       helo=localhost)\r
+       by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
+       (envelope-from <m.walters@qmul.ac.uk>)\r
+       id 1Sz0od-0000Wb-0r; Wed, 08 Aug 2012 08:36:27 +0100\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2] test: Add test for messages with missing headers\r
+In-Reply-To: <1344389313-7886-1-git-send-email-amdragon@mit.edu>\r
+References: <1344374501-28185-1-git-send-email-amdragon@mit.edu>\r
+       <1344389313-7886-1-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Wed, 08 Aug 2012 08:36:21 +0100\r
+Message-ID: <87628t3kei.fsf@qmul.ac.uk>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-Sender-Host-Address: 94.192.233.223\r
+X-QM-SPAM-Info: Sender has good ham record.  :)\r
+X-QM-Body-MD5: d65b4b6cda6ec7a9b633692dbd1a2548 (of first 20000 bytes)\r
+X-SpamAssassin-Score: -1.8\r
+X-SpamAssassin-SpamBar: -\r
+X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
+       determine if it is\r
+       spam. We require at least 5.0 points to mark a message as spam.\r
+       This message scored -1.8 points.\r
+       Summary of the scoring: \r
+       * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
+       *      medium trust\r
+       *      [138.37.6.40 listed in list.dnswl.org]\r
+       * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
+       provider *      (markwalters1009[at]gmail.com)\r
+       * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
+       *      domain\r
+       *  0.5 AWL AWL: From: address is in the auto white-list\r
+X-QM-Scan-Virus: ClamAV says the message is clean\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 07:36:33 -0000\r
+\r
+\r
+On Wed, 08 Aug 2012, Austin Clements <amdragon@MIT.EDU> wrote:\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
+LGTM +1. Tests work as expected and all tests pass with\r
+id:"874noe1o0r.fsf@qmul.ac.uk" applied.\r
+\r
+Best wishes\r
+\r
+Mark\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
+> 1.7.10\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r