From: Austin Clements <amdragon@MIT.EDU>
To: notmuch@notmuchmail.org
Subject: [PATCH v2] test: Add test for messages with missing headers
Date: Tue, 7 Aug 2012 21:28:33 -0400 [thread overview]
Message-ID: <1344389313-7886-1-git-send-email-amdragon@mit.edu> (raw)
In-Reply-To: <1344374501-28185-1-git-send-email-amdragon@mit.edu>
Currently the JSON tests for search and show are broken because
notmuch attempts to dereference a NULL pointer.
---
This version fixes the "Show: text" test so that it sanitize its
output and doesn't hard-code my test paths.
| 162 ++++++++++++++++++++++++++++++++++++++++++++++++++
test/notmuch-test | 1 +
2 files changed, 163 insertions(+)
create mode 100755 test/missing-headers
--git a/test/missing-headers b/test/missing-headers
new file mode 100755
index 0000000..e79f922
--- /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 <<EOF > "${MAIL_DIR}/msg-2"
+To: Notmuch Test Suite <test_suite@notmuchmail.org>
+Date: Fri, 05 Jan 2001 15:43:57 +0000
+
+Body
+EOF
+
+cat <<EOF > "${MAIL_DIR}/msg-1"
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+
+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 '*' | notmuch_show_sanitize)
+test_expect_equal "$output" "\
+\fmessage{ id:notmuch-sha1-7a6e4eac383ef958fcd3ebf2143db71b8ff01161 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-2
+\fheader{
+ (2001-01-05) (inbox unread)
+Subject: (null)
+From: (null)
+To: Notmuch Test Suite <test_suite@notmuchmail.org>
+Date: Fri, 05 Jan 2001 15:43:57 +0000
+\fheader}
+\fbody{
+\fpart{ ID: 1, Content-type: text/plain
+Body
+\fpart}
+\fbody}
+\fmessage}
+\fmessage{ id:notmuch-sha1-ca55943aff7a72baf2ab21fa74fab3d632401334 depth:0 match:1 excluded:0 filename:/XXX/mail/msg-1
+\fheader{
+Notmuch Test Suite <test_suite@notmuchmail.org> (1970-01-01) (inbox unread)
+Subject: (null)
+From: Notmuch Test Suite <test_suite@notmuchmail.org>
+Date: Thu, 01 Jan 1970 00:00:00 +0000
+\fheader}
+\fbody{
+\fpart{ ID: 1, Content-type: text/plain
+Body
+\fpart}
+\fbody}
+\fmessage}"
+
+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 <test_suite@notmuchmail.org>"
+ },
+ "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 <test_suite@notmuchmail.org>",
+ "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
next prev parent reply other threads:[~2012-08-08 1:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-07 21:21 [PATCH] test: Add test for messages with missing headers Austin Clements
2012-08-07 22:43 ` Mark Walters
2012-08-08 1:28 ` Austin Clements [this message]
2012-08-08 7:36 ` [PATCH v2] " Mark Walters
2012-08-08 8:08 ` Tomi Ollila
2012-08-08 15:46 ` Austin Clements
2012-08-08 18:47 ` Tomi Ollila
2012-08-08 19:10 ` Austin Clements
2012-08-08 21:23 ` [PATCH] sprinters: bugfix when NULL passed for a string Mark Walters
2012-08-08 21:28 ` Austin Clements
2012-08-12 19:51 ` David Bremner
2012-08-12 19:50 ` [PATCH v2] test: Add test for messages with missing headers David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1344389313-7886-1-git-send-email-amdragon@mit.edu \
--to=amdragon@mit.edu \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).