From: Jani Nikula <jani@nikula.org>
To: notmuch@notmuchmail.org
Subject: [PATCH v2 09/13] devel: add script to generate test databases
Date: Sun, 23 Feb 2014 00:25:40 +0200 [thread overview]
Message-ID: <1411feb2b6955ebaf4f5b4de9157e53f88e1bb1f.1393105055.git.jani@nikula.org> (raw)
In-Reply-To: <cover.1393105055.git.jani@nikula.org>
In-Reply-To: <cover.1393105055.git.jani@nikula.org>
Add script to generate notmuch test databases using specified versions
of notmuch. This is useful for generating material for database
upgrade tests.
This reuses the test infrastructure to have a sandbox environment for
notmuch new etc.
---
devel/gen-testdb.sh | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 124 insertions(+)
create mode 100755 devel/gen-testdb.sh
diff --git a/devel/gen-testdb.sh b/devel/gen-testdb.sh
new file mode 100755
index 000000000000..c291dfff98c9
--- /dev/null
+++ b/devel/gen-testdb.sh
@@ -0,0 +1,124 @@
+#!/usr/bin/env bash
+#
+# NAME
+# gen-testdb.sh - generate test databases
+#
+# SYNOPSIS
+# gen-testdb.sh -v NOTMUCH-VERSION [-c CORPUS-PATH] [-s TAR-SUFFIX]
+#
+# DESCRIPTION
+# Generate a tarball containing the specified test corpus and
+# the corresponding notmuch database, indexed using a specific
+# version of notmuch, resulting in a specific version of the
+# database.
+#
+# The specific version of notmuch will be built on the fly.
+# Therefore the script must be run within a git repository to be
+# able to build the old versions of notmuch.
+#
+# This script reuses the test infrastructure, and the script
+# must be run from within the test directory.
+#
+# The output tarballs, named database-<TAR-SUFFIX>.tar.gz, are
+# placed in the test/test-databases directory.
+#
+# OPTIONS
+# -v NOTMUCH-VERSION
+# Notmuch version in terms of a git tag or commit to use
+# for generating the database. Required.
+#
+# -c CORPUS-PATH
+# Path to a corpus to use for generating the
+# database. Due to CWD changes within the test
+# infrastructure, use absolute paths. Defaults to the
+# test corpus.
+#
+# -s TAR-SUFFIX
+# Suffix for the tarball basename. Empty by default.
+#
+# EXAMPLE
+#
+# Generate a database indexed with notmuch 0.17. Use the default
+# test corpus. Name the tarball database-v1.tar.gz to reflect
+# the fact that notmuch 0.17 used database version 1.
+#
+# $ cd test
+# $ ../devel/gen-testdb.sh -v 0.17 -s v1
+#
+# CAVEATS
+# Test infrastructure options won't work.
+#
+# Any existing databases with the same name will be overwritten.
+#
+# It may not be possible to build old versions of notmuch with
+# the set of dependencies that satisfy building the current
+# version of notmuch.
+#
+# AUTHOR
+# Jani Nikula <jani@nikula.org>
+#
+# LICENSE
+# Same as notmuch test infrastructure (GPLv2+).
+#
+
+test_description="database generation abusing test infrastructure"
+
+# immediate exit on subtest failure; see test_failure_ in test-lib.sh
+immediate=t
+
+VERSION=
+CORPUS=
+SUFFIX=
+
+while getopts v:c:s: opt; do
+ case "$opt" in
+ v) VERSION="$OPTARG";;
+ c) CORPUS="$OPTARG";;
+ s) SUFFIX="-$OPTARG";;
+ esac
+done
+shift `expr $OPTIND - 1`
+
+. ./test-lib.sh
+
+CORPUS=${CORPUS:-${TEST_DIRECTORY}/corpus}
+
+test_expect_code 0 "notmuch version specified on the command line" \
+ "test -n ${VERSION}"
+
+test_expect_code 0 "the specified version ${VERSION} refers to a commit" \
+ "git show ${VERSION} >/dev/null 2>&1"
+
+BUILD_DIR="notmuch-${VERSION}"
+test_expect_code 0 "generate snapshot of notmuch version ${VERSION}" \
+ "git -C $TEST_DIRECTORY/.. archive --prefix=${BUILD_DIR}/ --format=tar ${VERSION} | tar x"
+
+# force version string
+git describe --match '[0-9.]*' ${VERSION} > ${BUILD_DIR}/version
+
+test_expect_code 0 "configure and build notmuch version ${VERSION}" \
+ "make -C ${BUILD_DIR}"
+
+# use the newly built notmuch
+export PATH=./${BUILD_DIR}:$PATH
+
+test_begin_subtest "verify the newly built notmuch version"
+test_expect_equal "`notmuch --version`" "notmuch `cat ${BUILD_DIR}/version`"
+
+# replace the existing mails, if any, with the specified corpus
+rm -rf ${MAIL_DIR}
+cp -a ${CORPUS} ${MAIL_DIR}
+
+test_expect_code 0 "index the corpus" \
+ "notmuch new"
+
+# finally, wrap the resulting mail store and database in a tarball
+DBNAME=database${SUFFIX}
+cp -a ${MAIL_DIR} ${TMP_DIRECTORY}/${DBNAME}
+tar zcf ${TMP_DIRECTORY}/${DBNAME}.tar.gz -C ${TMP_DIRECTORY} ${DBNAME}
+mkdir -p ${TEST_DIRECTORY}/test-databases
+cp -a ${TMP_DIRECTORY}/${DBNAME}.tar.gz ${TEST_DIRECTORY}/test-databases
+test_expect_code 0 "create the output tarball ${DBNAME}.tar.gz" \
+ "test -f ${TEST_DIRECTORY}/test-databases/${DBNAME}.tar.gz"
+
+test_done
--
1.8.5.3
next prev parent reply other threads:[~2014-02-22 22:26 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-22 22:25 [PATCH v2 00/13] literal folder: prefix, new path: prefix Jani Nikula
2014-02-22 22:25 ` [PATCH v2 01/13] lib: refactor folder term update after filename removal Jani Nikula
2014-02-22 22:25 ` [PATCH v2 02/13] lib: add support for path: prefix searches Jani Nikula
2014-02-22 22:25 ` [PATCH v2 03/13] test: make insert test use the path: prefix Jani Nikula
2014-02-22 22:25 ` [PATCH v2 04/13] lib: make folder: prefix literal Jani Nikula
2014-02-22 22:25 ` [PATCH v2 05/13] test: fix test for literal folder: search Jani Nikula
2014-02-23 14:02 ` David Bremner
2014-02-22 22:25 ` [PATCH v2 06/13] test: make it possible to have several corpora Jani Nikula
2014-02-22 22:25 ` [PATCH v2 07/13] test: add new corpus with folders Jani Nikula
2014-02-22 22:25 ` [PATCH v2 08/13] test: add tests for the new boolean folder: and path: prefixes Jani Nikula
2014-02-22 22:25 ` Jani Nikula [this message]
2014-02-22 22:25 ` [PATCH v2 10/13] test: add test database in format version 1 Jani Nikula
2014-02-22 22:25 ` [PATCH v2 11/13] test: add database upgrade test from format version 1 to 2 Jani Nikula
2014-02-22 22:25 ` [PATCH v2 12/13] man: update man pages for folder: and path: search terms Jani Nikula
2014-02-22 22:25 ` [PATCH v2 13/13] man: try to clarify the folder: and path: vs. --output=files confusion Jani Nikula
2014-02-22 23:57 ` [PATCH v2 00/13] literal folder: prefix, new path: prefix Mark Walters
2014-02-23 11:15 ` Tomi Ollila
2014-03-02 19:11 ` David Bremner
2014-03-04 19:37 ` Jani Nikula
2014-03-04 21:15 ` David Bremner
2014-03-05 8:39 ` Tomi Ollila
2014-03-05 11:48 ` David Bremner
2014-03-05 13:10 ` Tomi Ollila
2014-03-05 14:41 ` David Bremner
2014-03-05 15:40 ` Tomi Ollila
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1411feb2b6955ebaf4f5b4de9157e53f88e1bb1f.1393105055.git.jani@nikula.org \
--to=jani@nikula.org \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).