--- /dev/null
+Return-Path: <aclements@csail.mit.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 1B17B431FD4\r
+ for <notmuch@notmuchmail.org>; Thu, 23 Oct 2014 05:31:29 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -2.3\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-2.3 tagged_above=-999 required=5\r
+ tests=[RCVD_IN_DNSWL_MED=-2.3] 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 qO6t+kRkwWEb for <notmuch@notmuchmail.org>;\r
+ Thu, 23 Oct 2014 05:31:20 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-8.mit.edu (dmz-mailsec-scanner-8.mit.edu\r
+ [18.7.68.37])\r
+ (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 48FD6429E26\r
+ for <notmuch@notmuchmail.org>; Thu, 23 Oct 2014 05:30:58 -0700 (PDT)\r
+X-AuditID: 12074425-f79e46d000002583-a5-5448f501dd64\r
+Received: from mailhub-auth-1.mit.edu ( [18.9.21.35])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-8.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id BD.F4.09603.105F8445; Thu, 23 Oct 2014 08:30:57 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-1.mit.edu (8.13.8/8.9.2) with ESMTP id s9NCUtbY030367; \r
+ Thu, 23 Oct 2014 08:30:55 -0400\r
+Received: from drake.dyndns.org\r
+ (216-15-114-40.c3-0.arl-ubr1.sbo-arl.ma.cable.rcn.com\r
+ [216.15.114.40]) (authenticated bits=0)\r
+ (User authenticated as amdragon@ATHENA.MIT.EDU)\r
+ by outgoing.mit.edu (8.13.8/8.12.4) with ESMTP id s9NCUsKU008986\r
+ (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);\r
+ Thu, 23 Oct 2014 08:30:54 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.84)\r
+ (envelope-from <aclements@csail.mit.edu>)\r
+ id 1XhHXU-0007c8-Ff; Thu, 23 Oct 2014 08:30:48 -0400\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3 8/9] test: Test upgrade to ghost messages feature\r
+Date: Thu, 23 Oct 2014 08:30:40 -0400\r
+Message-Id: <1414067441-29054-9-git-send-email-aclements@csail.mit.edu>\r
+X-Mailer: git-send-email 2.1.0\r
+In-Reply-To: <1414067441-29054-1-git-send-email-aclements@csail.mit.edu>\r
+References: <1414067441-29054-1-git-send-email-aclements@csail.mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrLIsWRmVeSWpSXmKPExsUixCmqrMv41SPE4NkCdYvVc3ksrt+cyezA\r
+ 5LFz1l12j2erbjEHMEVx2aSk5mSWpRbp2yVwZRz+d4m94BhXRXdHK3MD43uOLkZODgkBE4kr\r
+ O14yQ9hiEhfurWfrYuTiEBKYzSSxcfF5RghnI6PEqqVT2SGcO0wSt+88ZIVwljBK7J/7Bqyf\r
+ TUBfYsXaSawgtoiAtMTOu7PBbGYBD4kpra/AbGEBF4kzD7awgNgsAqoSZz++BbN5Bdwlvuz9\r
+ xwRxh5zEht3/GUFsTqDePTvusIHYQkA1258fZJ3AyL+AkWEVo2xKbpVubmJmTnFqsm5xcmJe\r
+ XmqRroVebmaJXmpK6SZGUCixu6juYJxwSOkQowAHoxIP74VUjxAh1sSy4srcQ4ySHExKorwx\r
+ D4BCfEn5KZUZicUZ8UWlOanFhxglOJiVRHjjLwDleFMSK6tSi/JhUtIcLErivJt+8IUICaQn\r
+ lqRmp6YWpBbBZGU4OJQkeBm/ADUKFqWmp1akZeaUIKSZODhBhvMADb/1GWR4cUFibnFmOkT+\r
+ FKOilDhvMkhCACSRUZoH1wuL9VeM4kCvCPOqgazgAaYJuO5XQIOZQK7eADa4JBEhJdXAmGaz\r
+ qP/E3edha5KzzIWEr195dOqvTnzxQVO1urSPljcnf1NVMuetlPc6e++DvInBwvJlNTY3OZ+Z\r
+ cIW/7MzwnLL1UdaLzlfrtoatffBoS0vXjs6SJ9PdFuxiY/jN2CK10MpaVTry+UGbT3q7604o\r
+ hlhNXnjEe4qO7SWr+Z7CDz6YfcuTStXYosRSnJFoqMVcVJwIAFJdcx7QAgAA\r
+Cc: Austin Clements <aclements@csail.mit.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: Thu, 23 Oct 2014 12:31:29 -0000\r
+\r
+---\r
+ test/T530-upgrade.sh | 21 +++++++++++++++++++++\r
+ 1 file changed, 21 insertions(+)\r
+\r
+diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh\r
+index c4c4ac8..6b42a69 100755\r
+--- a/test/T530-upgrade.sh\r
++++ b/test/T530-upgrade.sh\r
+@@ -116,4 +116,25 @@ MAIL_DIR/bar/new/21:2,\r
+ MAIL_DIR/bar/new/22:2,\r
+ MAIL_DIR/cur/51:2,"\r
+ \r
++# Ghost messages are difficult to test since they're nearly invisible.\r
++# However, if the upgrade works correctly, the ghost message should\r
++# retain the right thread ID even if all of the original messages in\r
++# the thread are deleted. That's what we test. This won't detect if\r
++# the upgrade just plain didn't happen, but it should detect if\r
++# something went wrong.\r
++test_begin_subtest "ghost message retains thread ID"\r
++# Upgrade database\r
++notmuch new\r
++# Get thread ID of real message\r
++thread=$(notmuch search --output=threads id:4EFC743A.3060609@april.org)\r
++# Delete all real messages in that thread\r
++rm $(notmuch search --output=files $thread)\r
++notmuch new\r
++# "Deliver" ghost message\r
++add_message '[subject]=Ghost' '[id]=4EFC3931.6030007@april.org'\r
++# If the ghost upgrade worked, the new message should be attached to\r
++# the existing thread ID.\r
++nthread=$(notmuch search --output=threads id:4EFC3931.6030007@april.org)\r
++test_expect_equal "$thread" "$nthread"\r
++\r
+ test_done\r
+-- \r
+2.1.0\r
+\r