--- /dev/null
+Return-Path: <prvs=372b3579b=jrosenthal@jhu.edu>\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 F3D81431FCB\r
+ for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 13:52:19 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+ 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 HVpMIiVqsDkz for <notmuch@notmuchmail.org>;\r
+ Wed, 29 Oct 2014 13:52:12 -0700 (PDT)\r
+Received: from smtpauth.johnshopkins.edu (smtpauth.johnshopkins.edu\r
+ [128.220.229.177]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id ABDCE431FC2\r
+ for <notmuch@notmuchmail.org>; Wed, 29 Oct 2014 13:52:12 -0700 (PDT)\r
+X-IronPort-AV: E=Sophos;i="5.07,279,1413259200"; d="scan'208";a="129235986"\r
+Received: from guppy.hwcampus.jhu.edu (HELO localhost) ([10.161.32.234])\r
+ by IPMTW4.johnshopkins.edu with ESMTP/TLS/AES128-SHA;\r
+ 29 Oct 2014 16:52:10 -0400\r
+From: Jesse Rosenthal <jrosenthal@jhu.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [v2 3/3] thread-naming test: Test empty subject names.\r
+Date: Wed, 29 Oct 2014 16:51:45 -0400\r
+Message-Id: <1414615905-22554-4-git-send-email-jrosenthal@jhu.edu>\r
+X-Mailer: git-send-email 2.1.2\r
+In-Reply-To: <1414615905-22554-1-git-send-email-jrosenthal@jhu.edu>\r
+References: <1414615905-22554-1-git-send-email-jrosenthal@jhu.edu>\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: Wed, 29 Oct 2014 20:52:20 -0000\r
+\r
+We test all empty subjects, and then empty subjects followed by\r
+non-empty subjects (searching both oldest- and newest-first).\r
+---\r
+ test/T200-thread-naming.sh | 32 ++++++++++++++++++++++++++++++++\r
+ 1 file changed, 32 insertions(+)\r
+\r
+diff --git a/test/T200-thread-naming.sh b/test/T200-thread-naming.sh\r
+index 1a1a48f..dcfc1b3 100755\r
+--- a/test/T200-thread-naming.sh\r
++++ b/test/T200-thread-naming.sh\r
+@@ -63,6 +63,38 @@ add_message '[subject]="Sv: thread-naming: Initial thread subject"' \\r
+ output=$(notmuch search --sort=newest-first thread-naming and tag:inbox | notmuch_search_sanitize)\r
+ test_expect_equal "$output" "thread:XXX 2001-01-12 [6/8] Notmuch Test Suite; thread-naming: Initial thread subject (inbox unread)"\r
+ \r
++test_begin_subtest "Use empty subjects if necessary."\r
++add_message '[subject]="@FORCE_EMPTY"' \\r
++ '[date]="Sat, 13 Jan 2001 15:43:45 -0000"' \\r
++ '[from]="Empty Sender \<empty_test@notmuchmail.org\>"'\r
++empty_parent=${gen_msg_id}\r
++add_message '[subject]="@FORCE_EMPTY"' \\r
++ '[date]="Sun, 14 Jan 2001 15:43:45 -0000"' \\r
++ '[from]="Empty Sender \<empty_test@notmuchmail.org\>"' \\r
++ "[in-reply-to]=\<$empty_parent\>"\r
++output=$(notmuch search --sort=newest-first from:empty_test@notmuchmail.org | notmuch_search_sanitize)\r
++test_expect_equal "$output" "thread:XXX 2001-01-14 [2/2] Empty Sender; (inbox unread)"\r
++\r
++test_begin_subtest "Avoid empty subjects if possible (newest-first)."\r
++add_message '[subject]="Non-empty subject (1)"' \\r
++ '[date]="Mon, 15 Jan 2001 15:43:45 -0000"' \\r
++ '[from]="Empty Sender \<empty_test@notmuchmail.org\>"' \\r
++ "[in-reply-to]=\<$empty_parent\>"\r
++add_message '[subject]="Non-empty subject (2)"' \\r
++ '[date]="Mon, 16 Jan 2001 15:43:45 -0000"' \\r
++ '[from]="Empty Sender \<empty_test@notmuchmail.org\>"' \\r
++ "[in-reply-to]=\<$empty_parent\>"\r
++add_message '[subject]="@FORCE_EMPTY"' \\r
++ '[date]="Tue, 17 Jan 2001 15:43:45 -0000"' \\r
++ '[from]="Empty Sender \<empty_test@notmuchmail.org\>"' \\r
++ "[in-reply-to]=\<$empty_parent\>"\r
++output=$(notmuch search --sort=newest-first from:Empty | notmuch_search_sanitize)\r
++test_expect_equal "$output" "thread:XXX 2001-01-17 [5/5] Empty Sender; Non-empty subject (2) (inbox unread)"\r
++\r
++test_begin_subtest "Avoid empty subjects if possible (oldest-first)."\r
++output=$(notmuch search --sort=oldest-first from:Empty | notmuch_search_sanitize)\r
++test_expect_equal "$output" "thread:XXX 2001-01-13 [5/5] Empty Sender; Non-empty subject (1) (inbox unread)"\r
++\r
+ test_begin_subtest 'Test order of messages in "notmuch show"'\r
+ output=$(notmuch show thread-naming | notmuch_show_sanitize)\r
+ test_expect_equal "$output" "\f\r
+message{ id:msg-$(printf "%03d" $first)@notmuch-test-suite depth:0 match:1 excluded:0 filename:/XXX/mail/msg-$(printf "%03d" $first)\r
+-- \r
+2.1.2\r
+\r