--- /dev/null
+Return-Path: <jani@nikula.org>\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 D28A9431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 4 May 2013 09:23:11 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 Ruj34YxJdC50 for <notmuch@notmuchmail.org>;\r
+ Sat, 4 May 2013 09:23:08 -0700 (PDT)\r
+Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com\r
+ [209.85.217.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id A6E8A431FAF\r
+ for <notmuch@notmuchmail.org>; Sat, 4 May 2013 09:23:07 -0700 (PDT)\r
+Received: by mail-lb0-f173.google.com with SMTP id t10so2375074lbi.32\r
+ for <notmuch@notmuchmail.org>; Sat, 04 May 2013 09:23:06 -0700 (PDT)\r
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;\r
+ d=google.com; s=20120113;\r
+ h=x-received:from:to:subject:in-reply-to:references:user-agent:date\r
+ :message-id:mime-version:content-type:x-gm-message-state;\r
+ bh=QesV6RgIEyHENxdxJ4jr47k+hh309GFqojK05iPa3oM=;\r
+ b=A/7QrkVAB45Efg7BEPuT8893k1k3qJC+6pQOjZDtqZ4DstFUJIAIukGA91pxmjQ9lN\r
+ /I4J6lo5/3+pK7vxQtdthzIcu5JxZKOc96easlZ48CUwuxY9coClm2p2XkMRm54f4n3M\r
+ NhhRRX7BcPDi+5V0y3ScukTSgQmVo87RRY05mqZTPGeVKRohlz9lhbQ7t9YUa7j1IZso\r
+ d6/+Hd/bXu4vrLRlJKpzvC5Y3/HBLD76lURwjTMbTfZGjT4HaA1ZzH+5dZ1Cf/8x4Td+\r
+ +adwK2saB3S6/bcfLO0EHjAshvWUpR+KwTUJFNiKvrCY7a/v/eIuLqBFJkS1OgJB2Z/5\r
+ qjpA==\r
+X-Received: by 10.112.137.73 with SMTP id qg9mr5789472lbb.3.1367684586153;\r
+ Sat, 04 May 2013 09:23:06 -0700 (PDT)\r
+Received: from localhost (dsl-hkibrasgw2-58c376-211.dhcp.inet.fi.\r
+ [88.195.118.211]) by mx.google.com with ESMTPSA id\r
+ rn10sm5824440lbb.16.2013.05.04.09.23.04 for <multiple recipients>\r
+ (version=TLSv1.2 cipher=RC4-SHA bits=128/128);\r
+ Sat, 04 May 2013 09:23:05 -0700 (PDT)\r
+From: Jani Nikula <jani@nikula.org>\r
+To: Aaron Ecay <aaronecay@gmail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH 1/2] test: add tests for the handling of References and\r
+ In-Reply-To headers\r
+In-Reply-To: <1362540709-28765-1-git-send-email-aaronecay@gmail.com>\r
+References: <87ppzfzxuk.fsf@zancas.localnet>\r
+ <1362540709-28765-1-git-send-email-aaronecay@gmail.com>\r
+User-Agent: Notmuch/0.15.2+87~gc69f540 (http://notmuchmail.org) Emacs/24.3.1\r
+ (x86_64-pc-linux-gnu)\r
+Date: Sat, 04 May 2013 19:23:00 +0300\r
+Message-ID: <87txmi1zq3.fsf@nikula.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-Gm-Message-State:\r
+ ALoCoQm3/685lEZ9wykLYzdVl9f8jhiD2fVl5WKx4rCFvXT2qVnARSQP8hA6KFT6VIc4wJjl/5fH\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: Sat, 04 May 2013 16:23:12 -0000\r
+\r
+On Wed, 06 Mar 2013, Aaron Ecay <aaronecay@gmail.com> wrote:\r
+> These tests are known_broken, the following commit fixes them.\r
+> ---\r
+>\r
+> Thanks to David and Tomi for pointing out test_expect_equal_json. In\r
+> the process of implementing that, I discovered\r
+> notmuch_json_show_sanitize, which I had also not been using. This\r
+> patch fixes the test to use both these conveniences. The second patch\r
+> is not changed substantively, but I am resending it for tidiness.\r
+>\r
+> test/thread-replies | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++\r
+> 1 file changed, 144 insertions(+)\r
+> create mode 100755 test/thread-replies\r
+>\r
+> diff --git a/test/thread-replies b/test/thread-replies\r
+> new file mode 100755\r
+> index 0000000..a902691\r
+> --- /dev/null\r
+> +++ b/test/thread-replies\r
+> @@ -0,0 +1,144 @@\r
+> +#!/usr/bin/env bash\r
+> +#\r
+> +# Copyright (c) 2013 Aaron Ecay\r
+> +#\r
+> +\r
+> +test_description='test of proper handling of in-reply-to and references headers\r
+> +\r
+> +This test makes sure that the thread structure in the notmuch database is\r
+> +constructed properly, even in the presence of non-RFC-compliant headers'\r
+\r
+Nitpick, most other tests have one line test descriptions. The second\r
+paragraph could be left as comment.\r
+\r
+> +\r
+> +. ./test-lib.sh\r
+> +\r
+> +test_begin_subtest "Use References when In-Reply-To is broken"\r
+> +test_subtest_known_broken\r
+> +add_message '[id]="foo@one.com"' \\r
+> + '[subject]=one'\r
+> +add_message '[in-reply-to]="mumble"' \\r
+> + '[references]="<foo@one.com>"' \\r
+> + '[subject]="Re: one"'\r
+> +output=$(notmuch show --format=json 'subject:one' | notmuch_json_show_sanitize)\r
+> +expected='[[[{"id": "foo@one.com",\r
+> + "match": true,\r
+> + "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-001",\r
+\r
+Please replace the path with:\r
+\r
+ "filename": "YYYYY",\r
+\r
+Ditto below for all of them.\r
+\r
+> + "timestamp": 978709437,\r
+> + "date_relative": "2001-01-05",\r
+> + "tags": ["inbox", "unread"],\r
+> + "headers": {"Subject": "one",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
+> + "body": [{"id": 1,\r
+> + "content-type": "text/plain",\r
+> + "content": "This is just a test message (#1)\n"}]},\r
+> + [[{"id": "msg-002@notmuch-test-suite",\r
+> + "match": true, "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-002",\r
+> + "timestamp": 978709437, "date_relative": "2001-01-05",\r
+> + "tags": ["inbox", "unread"], "headers": {"Subject": "Re: one",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
+> + "body": [{"id": 1, "content-type": "text/plain",\r
+> + "content": "This is just a test message (#2)\n"}]}, []]]]]]'\r
+> +expected=`echo "$expected" | notmuch_json_show_sanitize`\r
+> +test_expect_equal_json "$output" "$expected"\r
+> +\r
+> +test_begin_subtest "Prefer References to In-Reply-To"\r
+> +test_subtest_known_broken\r
+> +add_message '[id]="foo@two.com"' \\r
+> + '[subject]=two'\r
+> +add_message '[in-reply-to]="<bar@baz.com>"' \\r
+> + '[references]="<foo@two.com>"' \\r
+> + '[subject]="Re: two"'\r
+> +output=$(notmuch show --format=json 'subject:two' | notmuch_json_show_sanitize)\r
+> +expected='[[[{"id": "foo@two.com",\r
+> + "match": true, "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-003",\r
+> + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
+> + "headers": {"Subject": "two",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
+> + "body": [{"id": 1, "content-type": "text/plain",\r
+> + "content": "This is just a test message (#3)\n"}]},\r
+> + [[{"id": "msg-004@notmuch-test-suite", "match": true, "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-004",\r
+> + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
+> + "headers": {"Subject": "Re: two",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"},\r
+> + "body": [{"id": 1,\r
+> + "content-type": "text/plain", "content": "This is just a test message (#4)\n"}]},\r
+> + []]]]]]'\r
+> +expected=`echo "$expected" | notmuch_json_show_sanitize`\r
+> +test_expect_equal_json "$output" "$expected"\r
+> +\r
+> +test_begin_subtest "Use In-Reply-To when no References"\r
+> +test_subtest_known_broken\r
+\r
+As David said, this is not broken currently, as In-Reply-To is used\r
+unconditionally. Just drop the broken annotation, the test itself is\r
+useful.\r
+\r
+> +add_message '[id]="foo@three.com"' \\r
+> + '[subject]="three"'\r
+> +add_message '[in-reply-to]="<foo@three.com>"' \\r
+> + '[subject]="Re: three"'\r
+> +output=$(notmuch show --format=json 'subject:three' | notmuch_json_show_sanitize)\r
+> +expected='[[[{"id": "foo@three.com", "match": true, "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-005",\r
+> + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
+> + "headers": {"Subject": "three",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
+> + "content-type": "text/plain", "content": "This is just a test message (#5)\n"}]},\r
+> + [[{"id": "msg-006@notmuch-test-suite", "match": true, "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-006",\r
+> + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
+> + "headers": {"Subject": "Re: three",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
+> + "content-type": "text/plain", "content": "This is just a test message (#6)\n"}]},\r
+> + []]]]]]'\r
+> +expected=`echo "$expected" | notmuch_json_show_sanitize`\r
+> +test_expect_equal_json "$output" "$expected"\r
+> +\r
+> +test_begin_subtest "Use last Reference"\r
+> +test_subtest_known_broken\r
+> +add_message '[id]="foo@four.com"' \\r
+> + '[subject]="four"'\r
+> +add_message '[id]="bar@four.com"' \\r
+> + '[subject]="not-four"'\r
+> +add_message '[in-reply-to]="<baz@four.com>"' \\r
+> + '[references]="<baz@four.com> <foo@four.com>"' \\r
+> + '[subject]="neither"'\r
+> +output=$(notmuch show --format=json 'subject:four' | notmuch_json_show_sanitize)\r
+> +expected='[[[{"id": "foo@four.com", "match": true, "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-007",\r
+> + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
+> + "headers": {"Subject": "four",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
+> + "content-type": "text/plain", "content": "This is just a test message (#7)\n"}]},\r
+> + [[{"id": "msg-009@notmuch-test-suite", "match": false, "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-009",\r
+> + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
+> + "headers": {"Subject": "neither",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
+> + "content-type": "text/plain", "content": "This is just a test message (#9)\n"}]},\r
+> + []]]]], [[{"id": "bar@four.com", "match": true, "excluded": false,\r
+> + "filename": "/home/aecay/development/notmuch/notmuch-git/src/notmuch/test/tmp.thread-replies/mail/msg-008",\r
+> + "timestamp": 978709437, "date_relative": "2001-01-05", "tags": ["inbox", "unread"],\r
+> + "headers": {"Subject": "not-four",\r
+> + "From": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "To": "Notmuch Test Suite <test_suite@notmuchmail.org>",\r
+> + "Date": "Fri, 05 Jan 2001 15:43:57 +0000"}, "body": [{"id": 1,\r
+> + "content-type": "text/plain", "content": "This is just a test message (#8)\n"}]}, []]]]'\r
+> +expected=`echo "$expected" | notmuch_json_show_sanitize`\r
+> +test_expect_equal_json "$output" "$expected"\r
+> +\r
+> +\r
+> +test_done\r
+> -- \r
+> 1.8.1.5\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r