--- /dev/null
+Return-Path: <bremner@tethera.net>\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 DA1FE431FC7\r
+ for <notmuch@notmuchmail.org>; Sat, 8 Mar 2014 13:20:16 -0800 (PST)\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 8wm6Zf+GkkXX for <notmuch@notmuchmail.org>;\r
+ Sat, 8 Mar 2014 13:20:09 -0800 (PST)\r
+Received: from yantan.tethera.net (yantan.tethera.net [199.188.72.155])\r
+ (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\r
+ (No client certificate requested)\r
+ by olra.theworths.org (Postfix) with ESMTPS id 59C52431FB6\r
+ for <notmuch@notmuchmail.org>; Sat, 8 Mar 2014 13:20:09 -0800 (PST)\r
+Received: from remotemail by yantan.tethera.net with local (Exim 4.80)\r
+ (envelope-from <bremner@tethera.net>) id 1WMOf8-00057h-AK\r
+ for notmuch@notmuchmail.org; Sat, 08 Mar 2014 17:20:06 -0400\r
+Received: (nullmailer pid 28523 invoked by uid 1000); Sat, 08 Mar 2014\r
+ 21:20:02 -0000\r
+From: David Bremner <david@tethera.net>\r
+To: notmuch@notmuchmail.org\r
+Subject: v3 of boolean folder: patches\r
+Date: Sat, 8 Mar 2014 17:19:30 -0400\r
+Message-Id: <1394313585-28422-1-git-send-email-david@tethera.net>\r
+X-Mailer: git-send-email 1.8.5.3\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, 08 Mar 2014 21:20:17 -0000\r
+\r
+This is a followup to \r
+\r
+ id:cover.1393105055.git.jani@nikula.org\r
+\r
+The first 11 patches are very close to that series; in the last 4 I\r
+have added some minimalist infrastructure to download and verify\r
+pre-built test databases.\r
+\r
+I decided that the benefits of being to really apply and test the\r
+patch series outweighed the fact that one of patchs is about\r
+150K. Apologies to those of you on GSM modems and the like.\r
+\r
+Interdiff follows \r
+\r
+diff --git a/Makefile b/Makefile\r
+index 0428160..97084b1 100644\r
+--- a/Makefile\r
++++ b/Makefile\r
+@@ -5,7 +5,8 @@ all:\r
+ # List all subdirectories here. Each contains its own Makefile.local.\r
+ # Use of '=', without '+=', seems to be required for out-of-tree\r
+ # builds to work.\r
+-subdirs = compat completion emacs lib man parse-time-string performance-test util test\r
++subdirs = compat completion emacs lib man parse-time-string performance-test util test \\r
++ test/test-databases\r
+ \r
+ # We make all targets depend on the Makefiles themselves.\r
+ global_deps = Makefile Makefile.config Makefile.local \\r
+diff --git a/devel/gen-testdb.sh b/devel/gen-testdb.sh\r
+index c291dff..621b31e 100755\r
+--- a/devel/gen-testdb.sh\r
++++ b/devel/gen-testdb.sh\r
+@@ -81,6 +81,10 @@ shift `expr $OPTIND - 1`\r
+ \r
+ . ./test-lib.sh\r
+ \r
++SHORT_CORPUS=$(basename ${CORPUS:-database})\r
++DBNAME=${SHORT_CORPUS}${SUFFIX}\r
++TARBALLNAME=${DBNAME}.tar.xz\r
++\r
+ CORPUS=${CORPUS:-${TEST_DIRECTORY}/corpus}\r
+ \r
+ test_expect_code 0 "notmuch version specified on the command line" \\r
+@@ -112,13 +116,16 @@ cp -a ${CORPUS} ${MAIL_DIR}\r
+ test_expect_code 0 "index the corpus" \\r
+ "notmuch new"\r
+ \r
+-# finally, wrap the resulting mail store and database in a tarball\r
+-DBNAME=database${SUFFIX}\r
++# wrap the resulting mail store and database in a tarball\r
++\r
+ cp -a ${MAIL_DIR} ${TMP_DIRECTORY}/${DBNAME}\r
+-tar zcf ${TMP_DIRECTORY}/${DBNAME}.tar.gz -C ${TMP_DIRECTORY} ${DBNAME}\r
++tar Jcf ${TMP_DIRECTORY}/${TARBALLNAME} -C ${TMP_DIRECTORY} ${DBNAME}\r
+ mkdir -p ${TEST_DIRECTORY}/test-databases\r
+-cp -a ${TMP_DIRECTORY}/${DBNAME}.tar.gz ${TEST_DIRECTORY}/test-databases\r
+-test_expect_code 0 "create the output tarball ${DBNAME}.tar.gz" \\r
+- "test -f ${TEST_DIRECTORY}/test-databases/${DBNAME}.tar.gz"\r
++cp -a ${TMP_DIRECTORY}/${TARBALLNAME} ${TEST_DIRECTORY}/test-databases\r
++test_expect_code 0 "create the output tarball ${TARBALLNAME}" \\r
++ "test -f ${TEST_DIRECTORY}/test-databases/${TARBALLNAME}"\r
+ \r
++# generate a checksum file\r
++test_expect_code 0 "compute checksum" \\r
++ "(cd ${TEST_DIRECTORY}/test-databases/ && sha256sum ${TARBALLNAME} > ${TARBALLNAME}.sha256)"\r
+ test_done\r
+diff --git a/test/Makefile.local b/test/Makefile.local\r
+index 99324ba..bfabd15 100644\r
+--- a/test/Makefile.local\r
++++ b/test/Makefile.local\r
+@@ -2,6 +2,8 @@\r
+ \r
+ dir := test\r
+ \r
++# save against changes in $(dir)\r
++test_src_dir := $(dir)\r
+ extra_cflags += -I.\r
+ \r
+ smtp_dummy_srcs = \\r
+@@ -44,12 +46,12 @@ TEST_BINARIES=$(dir)/arg-test \\r
+ \r
+ test-binaries: $(TEST_BINARIES)\r
+ \r
+-test: all test-binaries\r
+- @${dir}/notmuch-test $(OPTIONS)\r
++test: all test-binaries fetch-test-databases\r
++ @${test_src_dir}/notmuch-test $(OPTIONS)\r
+ \r
+ check: test\r
+ \r
+ SRCS := $(SRCS) $(smtp_dummy_srcs)\r
+ CLEAN += $(TEST_BINARIES) $(addsuffix .o,$(TEST_BINARIES)) \\r
+ $(dir)/database-test.o \\r
+- $(dir)/corpus.mail $(dir)/test-results $(dir)/tmp.*\r
++ $(dir)/corpus.mail.* $(dir)/test-results $(dir)/tmp.*\r
+diff --git a/test/README b/test/README\r
+index 79a9b1b..81a1c82 100644\r
+--- a/test/README\r
++++ b/test/README\r
+@@ -64,6 +64,14 @@ The following command-line options are available when running tests:\r
+ Pointing this argument at a tmpfs filesystem can improve the\r
+ speed of the test suite for some users.\r
+ \r
++Certain tests require precomputed databases to complete. You can fetch these\r
++databases with\r
++\r
++ make download-test-databases\r
++\r
++If you do not download the test databases, the relevant tests will be\r
++skipped.\r
++\r
+ When invoking the test suite via "make test" any of the above options\r
+ can be specified as follows:\r
+ \r
+diff --git a/test/T530-upgrade.sh b/test/T530-upgrade.sh\r
+index cf9914e..e1e8ac5 100755\r
+--- a/test/T530-upgrade.sh\r
++++ b/test/T530-upgrade.sh\r
+@@ -3,7 +3,19 @@ test_description="database upgrade"\r
+ \r
+ . ./test-lib.sh\r
+ \r
+-tar zxf $TEST_DIRECTORY/test-databases/database-v1.tar.gz -C ${MAIL_DIR} --strip-components=1\r
++dbtarball=folders-v1.tar.xz\r
++\r
++# XXX: Accomplish the same with test lib helpers\r
++if [ ! -e ${TEST_DIRECTORY}/test-databases/${dbtarball} ]; then\r
++ test_subtest_missing_external_prereq_["${dbtarball} - fetch with 'make download-test-databases'"]=t\r
++fi\r
++\r
++test_expect_success \\r
++ 'database checksum' \\r
++ '( cd $TEST_DIRECTORY/test-databases &&\r
++ sha256sum --quiet --check --status ${dbtarball}.sha256 )'\r
++\r
++tar xf $TEST_DIRECTORY/test-databases/${dbtarball} -C ${MAIL_DIR} --strip-components=1\r
+ \r
+ test_begin_subtest "folder: search does not work with old database version"\r
+ output=$(notmuch search folder:foo)\r
+diff --git a/test/test-databases/.gitignore b/test/test-databases/.gitignore\r
+new file mode 100644\r
+index 0000000..b5624b7\r
+--- /dev/null\r
++++ b/test/test-databases/.gitignore\r
+@@ -0,0 +1 @@\r
++*.tar.xz\r
+diff --git a/test/test-databases/Makefile b/test/test-databases/Makefile\r
+new file mode 100644\r
+index 0000000..b250a8b\r
+--- /dev/null\r
++++ b/test/test-databases/Makefile\r
+@@ -0,0 +1,7 @@\r
++# See Makefile.local for the list of files to be compiled in this\r
++# directory.\r
++all:\r
++ $(MAKE) -C ../.. all\r
++\r
++.DEFAULT:\r
++ $(MAKE) -C ../.. $@\r
+diff --git a/test/test-databases/Makefile.local b/test/test-databases/Makefile.local\r
+new file mode 100644\r
+index 0000000..e777ada\r
+--- /dev/null\r
++++ b/test/test-databases/Makefile.local\r
+@@ -0,0 +1,14 @@\r
++# -*- makefile -*-\r
++\r
++TEST_DATABASE_MIRROR=http://notmuchmail.org/releases/test-databases\r
++\r
++dir := test/test-databases\r
++\r
++test_databases := $(dir)/folders-v1.tar.xz\r
++\r
++%.tar.xz:\r
++ wget -nv -O $@ ${TEST_DATABASE_MIRROR}/$(notdir $@);\r
++\r
++download-test-databases: ${test_databases}\r
++\r
++DISTCLEAN := $(DISTCLEAN) ${test_databases}\r
+diff --git a/test/test-databases/README b/test/test-databases/README\r
+deleted file mode 100644\r
+index af5defe..0000000\r
+--- a/test/test-databases/README\r
++++ /dev/null\r
+@@ -1,5 +0,0 @@\r
+-Notmuch test databases\r
+-======================\r
+-\r
+-This directory contains pre-generated databases with their source\r
+-corpus, chiefly for the purpose of testing database upgrade.\r
+diff --git a/test/test-databases/database-v1.tar.gz b/test/test-databases/database-v1.tar.gz\r
+deleted file mode 100644\r
+index bb4df4d..0000000\r
+Binary files a/test/test-databases/database-v1.tar.gz and /dev/null differ\r
+diff --git a/test/test-databases/folders-v1.tar.xz.sha256 b/test/test-databases/folders-v1.tar.xz.sha256\r
+new file mode 100644\r
+index 0000000..01ad79d\r
+--- /dev/null\r
++++ b/test/test-databases/folders-v1.tar.xz.sha256\r
+@@ -0,0 +1 @@\r
++ace8a61216756b90a421e23d03910e1228bcb910e197c35e51e29f2cf57b37d9 folders-v1.tar.xz\r