From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 40539431FBC for ; Tue, 5 Mar 2013 19:32:01 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.799 X-Spam-Level: X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, 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 tXGYDyFlBrz9 for ; Tue, 5 Mar 2013 19:31:59 -0800 (PST) Received: from mail-qa0-f43.google.com (mail-qa0-f43.google.com [209.85.216.43]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 9774E431FAE for ; Tue, 5 Mar 2013 19:31:59 -0800 (PST) Received: by mail-qa0-f43.google.com with SMTP id dx4so2300278qab.2 for ; Tue, 05 Mar 2013 19:31:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=7Fjy/phaQvApWnaMV/LrIDhOl0qhFLxzPkDvb4m0qQo=; b=YfcugJB4GC4VOlcsZsFXh6HgWpr0uiz2U3g6jn2OCyC8AqmQvKfVtqEPykCWN1mSTr LuUo4WObXoD+TCsrClST7l2zqAZuL35wEwVcFfL3HwjW7QUTv2g+qQoDa0ySJC4RuqJl Ui6GDYWypt72g6DKm6Nln91dM/wqDoDtR69mnmHzkr0C1jf+FKFqn18OqXkZY4ZpHyd2 Qh5zh4iSrTAD/o2/6LuF+zo4Mza6H6RbNkzUX8Emn38CkN9z6d7lAOTZCtSyZ8ihD2iy cdL5kHOERhLDtJMsFa22bXMyCC+GtUdikroKZljwGdYZqg9G0oPGHdkBxl8x+bWu+zAA NbLQ== X-Received: by 10.224.31.203 with SMTP id z11mr43213942qac.56.1362540717929; Tue, 05 Mar 2013 19:31:57 -0800 (PST) Received: from haize.hsd1.pa.comcast.net (c-68-80-94-73.hsd1.pa.comcast.net. [68.80.94.73]) by mx.google.com with ESMTPS id q5sm46570133qaz.2.2013.03.05.19.31.57 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 05 Mar 2013 19:31:57 -0800 (PST) From: Aaron Ecay To: notmuch@notmuchmail.org Subject: [PATCH 1/2] test: add tests for the handling of References and In-Reply-To headers Date: Tue, 5 Mar 2013 22:31:48 -0500 Message-Id: <1362540709-28765-1-git-send-email-aaronecay@gmail.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <87ppzfzxuk.fsf@zancas.localnet> References: <87ppzfzxuk.fsf@zancas.localnet> 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: Wed, 06 Mar 2013 03:32:01 -0000 These tests are known_broken, the following commit fixes them. --- Thanks to David and Tomi for pointing out test_expect_equal_json. In the process of implementing that, I discovered notmuch_json_show_sanitize, which I had also not been using. This patch fixes the test to use both these conveniences. The second patch is not changed substantively, but I am resending it for tidiness. test/thread-replies | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100755 test/thread-replies diff --git a/test/thread-replies b/test/thread-replies new file mode 100755 index 0000000..a902691 --- /dev/null +++ b/test/thread-replies @@ -0,0 +1,144 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2013 Aaron Ecay +# + +test_description='test of proper handling of in-reply-to and references headers + +This test makes sure that the thread structure in the notmuch database is +constructed properly, even in the presence of non-RFC-compliant headers' + +. ./test-lib.sh + +test_begin_subtest "Use References when In-Reply-To is broken" +test_subtest_known_broken +add_message '[id]="foo@one.com"' \ + '[subject]=one' +add_message '[in-reply-to]="mumble"' \ + '[references]=""' \ + '[subject]="Re: one"' +output=$(notmuch show --format=json 'subject:one' | notmuch_json_show_sanitize) +expected='[[[{"id": "foo@one.com", + "match": true, + "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-001", + "timestamp": 978709437, + "date_relative": "2001-01-05", + "tags": ["inbox", "unread"], + "headers": {"Subject": "one", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, + "body": [{"id": 1, + "content-type": "text/plain", + "content": "This is just a test message (#1)\n"}]}, + [[{"id": "msg-002@notmuch-test-suite", + "match": true, "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-002", + "timestamp": 978709437, "date_relative": "2001-01-05", + "tags": ["inbox", "unread"], "headers": {"Subject": "Re: one", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, + "body": [{"id": 1, "content-type": "text/plain", + "content": "This is just a test message (#2)\n"}]}, []]]]]]' +expected=`echo "$expected" | notmuch_json_show_sanitize` +test_expect_equal_json "$output" "$expected" + +test_begin_subtest "Prefer References to In-Reply-To" +test_subtest_known_broken +add_message '[id]="foo@two.com"' \ + '[subject]=two' +add_message '[in-reply-to]=""' \ + '[references]=""' \ + '[subject]="Re: two"' +output=$(notmuch show --format=json 'subject:two' | notmuch_json_show_sanitize) +expected='[[[{"id": "foo@two.com", + "match": true, "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-003", + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"], + "headers": {"Subject": "two", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, + "body": [{"id": 1, "content-type": "text/plain", + "content": "This is just a test message (#3)\n"}]}, + [[{"id": "msg-004@notmuch-test-suite", "match": true, "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-004", + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"], + "headers": {"Subject": "Re: two", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, + "body": [{"id": 1, + "content-type": "text/plain", "content": "This is just a test message (#4)\n"}]}, + []]]]]]' +expected=`echo "$expected" | notmuch_json_show_sanitize` +test_expect_equal_json "$output" "$expected" + +test_begin_subtest "Use In-Reply-To when no References" +test_subtest_known_broken +add_message '[id]="foo@three.com"' \ + '[subject]="three"' +add_message '[in-reply-to]=""' \ + '[subject]="Re: three"' +output=$(notmuch show --format=json 'subject:three' | notmuch_json_show_sanitize) +expected='[[[{"id": "foo@three.com", "match": true, "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-005", + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"], + "headers": {"Subject": "three", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, + "content-type": "text/plain", "content": "This is just a test message (#5)\n"}]}, + [[{"id": "msg-006@notmuch-test-suite", "match": true, "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-006", + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"], + "headers": {"Subject": "Re: three", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, + "content-type": "text/plain", "content": "This is just a test message (#6)\n"}]}, + []]]]]]' +expected=`echo "$expected" | notmuch_json_show_sanitize` +test_expect_equal_json "$output" "$expected" + +test_begin_subtest "Use last Reference" +test_subtest_known_broken +add_message '[id]="foo@four.com"' \ + '[subject]="four"' +add_message '[id]="bar@four.com"' \ + '[subject]="not-four"' +add_message '[in-reply-to]=""' \ + '[references]=" "' \ + '[subject]="neither"' +output=$(notmuch show --format=json 'subject:four' | notmuch_json_show_sanitize) +expected='[[[{"id": "foo@four.com", "match": true, "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-007", + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"], + "headers": {"Subject": "four", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, + "content-type": "text/plain", "content": "This is just a test message (#7)\n"}]}, + [[{"id": "msg-009@notmuch-test-suite", "match": false, "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-009", + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"], + "headers": {"Subject": "neither", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, + "content-type": "text/plain", "content": "This is just a test message (#9)\n"}]}, + []]]]], [[{"id": "bar@four.com", "match": true, "excluded": false, + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-008", + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"], + "headers": {"Subject": "not-four", + "From": "Notmuch Test Suite ", + "To": "Notmuch Test Suite ", + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1, + "content-type": "text/plain", "content": "This is just a test message (#8)\n"}]}, []]]]' +expected=`echo "$expected" | notmuch_json_show_sanitize` +test_expect_equal_json "$output" "$expected" + + +test_done -- 1.8.1.5