--- /dev/null
+Return-Path: <bgamari.foss@gmail.com>\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 9E5A6431FBD\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Oct 2013 18:13:19 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+ tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+ FREEMAIL_FROM=0.001, 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 xsbaOO-LiZij for <notmuch@notmuchmail.org>;\r
+ Mon, 14 Oct 2013 18:13:13 -0700 (PDT)\r
+Received: from mail-qc0-f170.google.com (mail-qc0-f170.google.com\r
+ [209.85.216.170]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 99075431FAF\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Oct 2013 18:13:13 -0700 (PDT)\r
+Received: by mail-qc0-f170.google.com with SMTP id n9so2456851qcw.29\r
+ for <notmuch@notmuchmail.org>; Mon, 14 Oct 2013 18:13:12 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+ h=from:to:cc:subject:date:message-id:in-reply-to:references;\r
+ bh=s6+xZwBuN9GIqyr36WPEvN3Mvmtlnnsmpy8ilby9S6A=;\r
+ b=DkQJ9e3YmrFJr07Y0Q+odW3UjYiASayICT/wtn54P/Ks56XBeo10Fy588WUtG7MOhB\r
+ q9mtT9cB5jU3X13VQ+ES5+klNN3BeI0ghRSa25RWG+9u+G/FQINmPhyzRSqrsnA7oI/W\r
+ dLhLbwRlsFiYt2wfoUrNMIjRvR7baFJNzr5Sul31n1qloND46tyYqhFqIUspjuHVdGzj\r
+ wT2WGZQpQuEGrHfOLtTAV48At5UrjLKWkofiwGInzQzplB9YSIyaXllmTeBB1nC3IsZt\r
+ pi+vnFCPu1DvR0ug+MMYols+SlZ32AIG/JCftbCNpK3t2qCMBI1bIxTCS3tSu8B15fln\r
+ iqBA==\r
+X-Received: by 10.224.123.13 with SMTP id n13mr26257198qar.33.1381799592009;\r
+ Mon, 14 Oct 2013 18:13:12 -0700 (PDT)\r
+Received: from localhost.localdomain\r
+ (pool-108-8-224-250.spfdma.east.verizon.net. [108.8.224.250])\r
+ by mx.google.com with ESMTPSA id\r
+ og1sm105736333qeb.3.1969.12.31.16.00.00\r
+ (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);\r
+ Mon, 14 Oct 2013 18:13:11 -0700 (PDT)\r
+From: Ben Gamari <bgamari.foss@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/3] test: Add compact test\r
+Date: Mon, 14 Oct 2013 21:13:03 -0400\r
+Message-Id: <1381799585-16274-2-git-send-email-bgamari.foss@gmail.com>\r
+X-Mailer: git-send-email 1.8.1.2\r
+In-Reply-To: <1381799585-16274-1-git-send-email-bgamari.foss@gmail.com>\r
+References: <1381799585-16274-1-git-send-email-bgamari.foss@gmail.com>\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: Tue, 15 Oct 2013 01:13:20 -0000\r
+\r
+Signed-off-by: Ben Gamari <bgamari.foss@gmail.com>\r
+---\r
+ test/compact | 35 +++++++++++++++++++++++++++++++++++\r
+ test/notmuch-test | 1 +\r
+ 2 files changed, 36 insertions(+)\r
+ create mode 100755 test/compact\r
+\r
+diff --git a/test/compact b/test/compact\r
+new file mode 100755\r
+index 0000000..54e85ab\r
+--- /dev/null\r
++++ b/test/compact\r
+@@ -0,0 +1,35 @@\r
++#!/usr/bin/env bash\r
++test_description='"notmuch compact"'\r
++. ./test-lib.sh\r
++\r
++add_message '[subject]=One'\r
++add_message '[subject]=Two'\r
++add_message '[subject]=Three'\r
++\r
++notmuch tag +tag1 \*\r
++notmuch tag +tag2 subject:Two\r
++notmuch tag -tag1 +tag3 subject:Three\r
++\r
++test_begin_subtest "Compacting"\r
++notmuch compact\r
++test_expect_success "compact" "notmuch compact"\r
++\r
++notmuch search \*\r
++output=$(notmuch search \* | notmuch_search_sanitize)\r
++test_expect_equal "$output" "\\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 unread)\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"\r
++\r
++test_begin_subtest "Restoring backup"\r
++rm -Rf ${TEST_TMPDIR}/mail/xapian\r
++mv ${TEST_TMPDIR}/mail/xapian.old ${TEST_TMPDIR}/mail/xapian\r
++\r
++notmuch search \*\r
++output=$(notmuch search \* | notmuch_search_sanitize)\r
++test_expect_equal "$output" "\\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; One (inbox tag1 unread)\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Two (inbox tag1 tag2 unread)\r
++thread:XXX 2001-01-05 [1/1] Notmuch Test Suite; Three (inbox tag3 unread)"\r
++\r
++test_done\r
+diff --git a/test/notmuch-test b/test/notmuch-test\r
+index aa28bb0..ec94baf 100755\r
+--- a/test/notmuch-test\r
++++ b/test/notmuch-test\r
+@@ -19,6 +19,7 @@ cd $(dirname "$0")\r
+ TESTS="\r
+ basic\r
+ help-test\r
++ compact\r
+ config\r
+ setup\r
+ new\r
+-- \r
+1.8.1.2\r
+\r