From 81883497ba72bfb0e1975aab95175065784e50ff Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Tue, 7 Aug 2012 23:43:51 +0100 Subject: [PATCH] Re: [PATCH] test: Add test for messages with missing headers --- f5/13c93102f1b96a4fd1d5519bcc6c314049c6d4 | 321 ++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 f5/13c93102f1b96a4fd1d5519bcc6c314049c6d4 diff --git a/f5/13c93102f1b96a4fd1d5519bcc6c314049c6d4 b/f5/13c93102f1b96a4fd1d5519bcc6c314049c6d4 new file mode 100644 index 000000000..260c82ed0 --- /dev/null +++ b/f5/13c93102f1b96a4fd1d5519bcc6c314049c6d4 @@ -0,0 +1,321 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 6435D431FBC + for ; Tue, 7 Aug 2012 15:44:04 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id Kbw41tkgR2V8 for ; + Tue, 7 Aug 2012 15:44:03 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 3E891431FAE + for ; Tue, 7 Aug 2012 15:44:03 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1SysVK-00047h-Hx; Tue, 07 Aug 2012 23:44:01 +0100 +Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] + helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1SysVK-0002rq-18; Tue, 07 Aug 2012 23:43:58 +0100 +From: Mark Walters +To: Austin Clements , notmuch@notmuchmail.org +Subject: Re: [PATCH] test: Add test for messages with missing headers +In-Reply-To: <1344374501-28185-1-git-send-email-amdragon@mit.edu> +References: <1344374501-28185-1-git-send-email-amdragon@mit.edu> +User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1 + (x86_64-pc-linux-gnu) +Date: Tue, 07 Aug 2012 23:43:51 +0100 +Message-ID: <87ipcumifs.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 94.192.233.223 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: 164e43691eeaacaf685370cbfa71e8f3 (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * 0.5 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Tue, 07 Aug 2012 22:44:04 -0000 + + +Hi + +This generally looks good but there is a bug in the test from a +hardcoded /tmp/ path (see below). And as confirmation with the patch in +id:"874noe1o0r.fsf@qmul.ac.uk" the tests (modulo the test bug) pass. + +On Tue, 07 Aug 2012, Austin Clements wrote: +> Currently the JSON tests for search and show are broken because +> notmuch attempts to dereference a NULL pointer. +> --- +> Things to bikeshed: +> +> * Should we include From and Subject in the headers object when there +> are no from or subject headers? Currently the schema says that +> everything but those two and "Date" is optional (indeed, "To" is +> missing from the second message) but that was just post facto +> standardization. + +I think Date and From are compulsory in an email but the others are not +(but I am unsure which Date and which From so that may be unhelpful). +If I am correct it might be sensible to always include those two. + +> * How should we format expected JSON in the test suite, now that we +> can format it however we want? Here I've just pasted in the result +> of python -mjson.tool. While that was very easy and the result is +> quite readable, it's the antithesis of compact and the keys have +> been alphabetized. + +I like this: making the tests readable is a big plus. + +> test/missing-headers | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++ +> test/notmuch-test | 1 + +> 2 files changed, 163 insertions(+) +> create mode 100755 test/missing-headers +> +> diff --git a/test/missing-headers b/test/missing-headers +> new file mode 100755 +> index 0000000..744c04e +> --- /dev/null +> +++ b/test/missing-headers +> @@ -0,0 +1,162 @@ +> +#!/usr/bin/env bash +> +test_description='messages with missing headers' +> +. ./test-lib.sh +> + +> +# Notmuch requires at least one of from, subject, or to or it will +> +# ignore the file. Generate two messages so that together they cover +> +# all possible missing headers. We also give one of the messages a +> +# date to ensure stable result ordering. +> + +> +cat < "${MAIL_DIR}/msg-2" +> +To: Notmuch Test Suite +> +Date: Fri, 05 Jan 2001 15:43:57 +0000 +> + +> +Body +> +EOF +> + +> +cat < "${MAIL_DIR}/msg-1" +> +From: Notmuch Test Suite +> + +> +Body +> +EOF +> + +> +NOTMUCH_NEW +> + +> +test_begin_subtest "Search: text" +> +output=$(notmuch search '*' | notmuch_search_sanitize) +> +test_expect_equal "$output" "\ +> +thread:XXX 2001-01-05 [1/1] (null); (inbox unread) +> +thread:XXX 1970-01-01 [1/1] Notmuch Test Suite; (inbox unread)" +> + +> +test_begin_subtest "Search: json" +> +test_subtest_known_broken +> +output=$(notmuch search --format=json '*' | notmuch_search_sanitize) +> +test_expect_equal_json "$output" ' +> +[ +> + { +> + "authors": "", +> + "date_relative": "2001-01-05", +> + "matched": 1, +> + "subject": "", +> + "tags": [ +> + "inbox", +> + "unread" +> + ], +> + "thread": "XXX", +> + "timestamp": 978709437, +> + "total": 1 +> + }, +> + { +> + "authors": "Notmuch Test Suite", +> + "date_relative": "1970-01-01", +> + "matched": 1, +> + "subject": "", +> + "tags": [ +> + "inbox", +> + "unread" +> + ], +> + "thread": "XXX", +> + "timestamp": 0, +> + "total": 1 +> + } +> +]' +> + +> +test_begin_subtest "Show: text" +> +output=$(notmuch show '*') +> +test_expect_equal "$output" "\ +> + +message{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/tmp/nmtest/tmp.missing-headers/mail/msg-2 + +The filename above has not been sanitised so contains your tmp path. + +Best wishes + +Mark + +> + +header{ +> + (2001-01-05) (inbox unread) +> +Subject: (null) +> +From: (null) +> +To: Notmuch Test Suite +> +Date: Fri, 05 Jan 2001 15:43:57 +0000 +> + +header} +> + +body{ +> + +part{ ID: 1, Content-type: text/plain +> +Body +> + +part} +> + +body} +> + +message} +> + +message{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/tmp/nmtest/tmp.missing-headers/mail/msg-1 +> + +header{ +> +Notmuch Test Suite (1970-01-01) (inbox unread) +> +Subject: (null) +> +From: Notmuch Test Suite +> +Date: Thu, 01 Jan 1970 00:00:00 +0000 +> + +header} +> + +body{ +> + +part{ ID: 1, Content-type: text/plain +> +Body +> + +part} +> + +body} +> + +message}" +> + +> +test_begin_subtest "Show: json" +> +test_subtest_known_broken +> +output=$(notmuch show --format=json '*' | notmuch_json_show_sanitize) +> +test_expect_equal_json "$output" ' +> +[ +> + [ +> + [ +> + { +> + "body": [ +> + { +> + "content": "Body\n", +> + "content-type": "text/plain", +> + "id": 1 +> + } +> + ], +> + "date_relative": "2001-01-05", +> + "excluded": false, +> + "filename": "YYYYY", +> + "headers": { +> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000", +> + "From": "", +> + "Subject": "", +> + "To": "Notmuch Test Suite " +> + }, +> + "id": "XXXXX", +> + "match": true, +> + "tags": [ +> + "inbox", +> + "unread" +> + ], +> + "timestamp": 978709437 +> + }, +> + [] +> + ] +> + ], +> + [ +> + [ +> + { +> + "body": [ +> + { +> + "content": "Body\n", +> + "content-type": "text/plain", +> + "id": 1 +> + } +> + ], +> + "date_relative": "1970-01-01", +> + "excluded": false, +> + "filename": "YYYYY", +> + "headers": { +> + "Date": "Thu, 01 Jan 1970 00:00:00 +0000", +> + "From": "Notmuch Test Suite ", +> + "Subject": "" +> + }, +> + "id": "XXXXX", +> + "match": true, +> + "tags": [ +> + "inbox", +> + "unread" +> + ], +> + "timestamp": 0 +> + }, +> + [] +> + ] +> + ] +> +]' +> + +> + +> +test_done +> diff --git a/test/notmuch-test b/test/notmuch-test +> index ea39dfc..cc732c3 100755 +> --- a/test/notmuch-test +> +++ b/test/notmuch-test +> @@ -59,6 +59,7 @@ TESTS=" +> emacs-address-cleaning +> emacs-hello +> emacs-show +> + missing-headers +> " +> TESTS=${NOTMUCH_TESTS:=$TESTS} +> +> -- +> 1.7.10 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch -- 2.26.2