--- /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 1C134431FD5\r
+ for <notmuch@notmuchmail.org>; Fri, 3 Oct 2014 07:20:00 -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 XWSUxXJPR6xl for <notmuch@notmuchmail.org>;\r
+ Fri, 3 Oct 2014 07:19:52 -0700 (PDT)\r
+Received: from dmz-mailsec-scanner-6.mit.edu (dmz-mailsec-scanner-6.mit.edu\r
+ [18.7.68.35])\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 EEAE4431FD8\r
+ for <notmuch@notmuchmail.org>; Fri, 3 Oct 2014 07:19:31 -0700 (PDT)\r
+X-AuditID: 12074423-f799d6d00000337c-fc-542eb0739b19\r
+Received: from mailhub-auth-4.mit.edu ( [18.7.62.39])\r
+ (using TLS with cipher AES256-SHA (256/256 bits))\r
+ (Client did not present a certificate)\r
+ by dmz-mailsec-scanner-6.mit.edu (Symantec Messaging Gateway) with SMTP\r
+ id F4.B6.13180.370BE245; Fri, 3 Oct 2014 10:19:31 -0400 (EDT)\r
+Received: from outgoing.mit.edu (outgoing-auth-1.mit.edu [18.9.28.11])\r
+ by mailhub-auth-4.mit.edu (8.13.8/8.9.2) with ESMTP id s93EJROL020229; \r
+ Fri, 3 Oct 2014 10:19:28 -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 s93EJQbA023389\r
+ (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT);\r
+ Fri, 3 Oct 2014 10:19:27 -0400\r
+Received: from amthrax by drake.dyndns.org with local (Exim 4.84)\r
+ (envelope-from <aclements@csail.mit.edu>)\r
+ id 1Xa3hZ-0002KH-C2; Fri, 03 Oct 2014 10:19:21 -0400\r
+From: Austin Clements <aclements@csail.mit.edu>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 10/11] test: Test upgrade to ghost messages feature\r
+Date: Fri, 3 Oct 2014 10:19:17 -0400\r
+Message-Id: <1412345958-8278-11-git-send-email-aclements@csail.mit.edu>\r
+X-Mailer: git-send-email 2.1.0\r
+In-Reply-To: <1412345958-8278-1-git-send-email-aclements@csail.mit.edu>\r
+References: <1412345958-8278-1-git-send-email-aclements@csail.mit.edu>\r
+X-Brightmail-Tracker:\r
+ H4sIAAAAAAAAA+NgFtrMIsWRmVeSWpSXmKPExsUixG6nrlu8QS/EYP03CYvrN2cyOzB6PFt1\r
+ izmAMYrLJiU1J7MstUjfLoEr4/C/S+wFx7gqujtamRsY33N0MXJySAiYSPRd7mCBsMUkLtxb\r
+ z9bFyMUhJDCbSWLH1etQzgZGiY3zNjFDOLeZJFa0XoPKLGGU+L7mBStIP5uAvsSKtZPAbBEB\r
+ aYmdd2cD2RwczAK6Es3tyiBhYQFniScdU5lAbBYBVYkX/5oZQWxeAXeJafebGCHOkJPYsPs/\r
+ mM0JFL9w9ykbiC0k4Cax6lg32wRG/gWMDKsYZVNyq3RzEzNzilOTdYuTE/PyUot0zfRyM0v0\r
+ UlNKNzGCw8ZFeQfjn4NKhxgFOBiVeHg/3NANEWJNLCuuzD3EKMnBpCTKW7lYL0SILyk/pTIj\r
+ sTgjvqg0J7X4EKMEB7OSCO+ClUA53pTEyqrUonyYlDQHi5I476YffCFCAumJJanZqakFqUUw\r
+ WRkODiUJ3vb1QI2CRanpqRVpmTklCGkmDk6Q4TxAw8FqeIsLEnOLM9Mh8qcYFaXEeR+uA0oI\r
+ gCQySvPgemFx/YpRHOgVYd4ukHYeYEqA634FNJgJaPA7e12QwSWJCCmpBkYvBoPySO2jVzy+\r
+ Va9sT/X7dunqrisrziT6tejqvI1I3ZH8/dmHdS5B34on1z7MimV+dnK6W6jj7+Arwb/X3c6t\r
+ OaGu5cKzNanIJu56yUm/cv1527zKqx999V29OiC30l0oROr/zFeP+WSjrn3X3/WQs9ziV83X\r
+ yqpNORwMhsvviEX6Taj+sUyJpTgj0VCLuag4EQBvxJvvxgIAAA==\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: Fri, 03 Oct 2014 14:20:00 -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