From: Austin Clements Date: Tue, 7 Aug 2012 21:21:41 +0000 (+2000) Subject: [PATCH] test: Add test for messages with missing headers X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=d675a73771c2ecd919e86cc8a11518701bae1e3c;p=notmuch-archives.git [PATCH] test: Add test for messages with missing headers --- diff --git a/cf/6e2720935c88c525c5975314ec18ce42241848 b/cf/6e2720935c88c525c5975314ec18ce42241848 new file mode 100644 index 000000000..82d1b0785 --- /dev/null +++ b/cf/6e2720935c88c525c5975314ec18ce42241848 @@ -0,0 +1,290 @@ +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 A0664431FC0 + for ; Tue, 7 Aug 2012 14:21:51 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -0.7 +X-Spam-Level: +X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 ttP0WbXWpSrw for ; + Tue, 7 Aug 2012 14:21:49 -0700 (PDT) +Received: from dmz-mailsec-scanner-4.mit.edu (DMZ-MAILSEC-SCANNER-4.MIT.EDU + [18.9.25.15]) + by olra.theworths.org (Postfix) with ESMTP id B7B26431FAF + for ; Tue, 7 Aug 2012 14:21:49 -0700 (PDT) +X-AuditID: 1209190f-b7f306d0000008b4-f9-502186ec59fb +Received: from mailhub-auth-4.mit.edu ( [18.7.62.39]) + by dmz-mailsec-scanner-4.mit.edu (Symantec Messaging Gateway) with SMTP + id 73.66.02228.CE681205; Tue, 7 Aug 2012 17:21:48 -0400 (EDT) +Received: from outgoing.mit.edu (OUTGOING-AUTH.MIT.EDU [18.7.22.103]) + by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id q77LLl1n018296; + Tue, 7 Aug 2012 17:21:47 -0400 +Received: from drake.dyndns.org (26-4-181.dynamic.csail.mit.edu [18.26.4.181]) + (authenticated bits=0) + (User authenticated as amdragon@ATHENA.MIT.EDU) + by outgoing.mit.edu (8.13.6/8.12.4) with ESMTP id q77LLkdC027381 + (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); + Tue, 7 Aug 2012 17:21:47 -0400 (EDT) +Received: from amthrax by drake.dyndns.org with local (Exim 4.77) + (envelope-from ) + id 1SyrDm-0007b0-AX; Tue, 07 Aug 2012 17:21:46 -0400 +From: Austin Clements +To: notmuch@notmuchmail.org +Subject: [PATCH] test: Add test for messages with missing headers +Date: Tue, 7 Aug 2012 17:21:41 -0400 +Message-Id: <1344374501-28185-1-git-send-email-amdragon@mit.edu> +X-Mailer: git-send-email 1.7.10 +X-Brightmail-Tracker: + H4sIAAAAAAAAA+NgFprNIsWRmVeSWpSXmKPExsUixG6nrvumTTHA4EQLj8X1mzOZHRg9nq26 + xRzAGMVlk5Kak1mWWqRvl8CV8W7nC+aCKfoV7zbPZWtgPCDfxcjJISFgIvH57DFWCFtM4sK9 + 9WxdjFwcQgL7GCWWti5mhXDWM0rsfLedGcI5ySSxve8WE4Qzl1GiaeM6NpB+NgENiW37lzOC + 2CIC0hI7784GaufgYBZQk/jTpQISFhZwlPjY85odxGYRUJW43vUbbDWvgIPE+qkroc6Ql3h6 + v49tAiPvAkaGVYyyKblVurmJmTnFqcm6xcmJeXmpRbomermZJXqpKaWbGEFhwCnJv4Px20Gl + Q4wCHIxKPLzRyYoBQqyJZcWVuYcYJTmYlER5fzUDhfiS8lMqMxKLM+KLSnNSiw8xSnAwK4nw + trUC5XhTEiurUovyYVLSHCxK4rxXU276CwmkJ5akZqemFqQWwWRlODiUJHiFvIAaBYtS01Mr + 0jJzShDSTBycIMN5gIZLtIEMLy5IzC3OTIfIn2JUlBLnPQWyVQAkkVGaB9cLi9NXjOJArwjz + SoO08wBjHK77FdBgJqDB3vJyIINLEhFSUg2M5SuTG1ZMvyN3v1xIdN5nX99av42Zi/fcjQoW + 92z78mf9Xpmp4r9NzzAEzuU/usiOk//nA7m24vpD320q9jzSsj4iLeN2qW7f7/zGBP7gCfuO + 3OVbpqI7U+RQosOUNXr7bDjXd3xS5mfzm7j1TaXjhM8uGbP/z71bpaWbMfHnUk1F/RtTJzSz + K7EUZyQaajEXFScCAAb1Wk+uAgAA +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 21:21:51 -0000 + +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. + +* 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. + + 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 ++ +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 +