From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 1AF1F431FC4 for ; Sun, 9 Mar 2014 14:42:04 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kxwHpCKZdIRu for ; Sun, 9 Mar 2014 14:41:58 -0700 (PDT) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com [209.85.215.51]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 05BA4431FC0 for ; Sun, 9 Mar 2014 14:41:05 -0700 (PDT) Received: by mail-la0-f51.google.com with SMTP id pv20so4071938lab.24 for ; Sun, 09 Mar 2014 14:41:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=UKnf5YhA4YqmiCnEmU6V2W69jh5cvxd9Eo/bRGHWN44=; b=J7ZhTtGBN+INavbcKF1rdxis0xaIkssFD3I5Yb58xjomQaNnlhcfIpbnJ36t3kuLd6 /kkfhfGPK5OEZPy4eBD9dTsVBTBLx64RGi+bTWQG/uIC+QTDzxo0t3ek3Ao5h7Ra6QX5 xqgz9VNW7fVeuOUuS1vnhPhFYxlfCvGYGkDD7U0lAkkFY5FP9RyNteXEcS5EOAMxaAsi zjHTAZxIXu+W+atZC9cnlyfLC6aQFsVk9XGXJUtn6SOmE7rb+6HKjPHGxeowffzDUmF0 Wv+BTL2a5dMdR6jKBYXCloLECKEt8vtT6XcByXcVGzyQKXMIwhjJ9YSxROy4pX1k2r+T QpNQ== X-Gm-Message-State: ALoCoQmHvT+1Rrxt65Q+BXXsPSvMl3S3x6mBWNTWs3T8RUpLff5OsFHHMzuKd8q8FrNMSdkykzRi X-Received: by 10.152.18.135 with SMTP id w7mr1567699lad.29.1394401264575; Sun, 09 Mar 2014 14:41:04 -0700 (PDT) Received: from localhost (dsl-hkibrasgw2-58c36f-91.dhcp.inet.fi. [88.195.111.91]) by mx.google.com with ESMTPSA id i7sm26923161lai.5.2014.03.09.14.41.03 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sun, 09 Mar 2014 14:41:03 -0700 (PDT) From: Jani Nikula To: notmuch@notmuchmail.org Subject: [PATCH v4 11/13] devel: add script to generate test databases Date: Sun, 9 Mar 2014 23:40:32 +0200 Message-Id: X-Mailer: git-send-email 1.9.0 In-Reply-To: References: In-Reply-To: References: X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Mar 2014 21:42:04 -0000 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 | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 131 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..621b31e67fc2 --- /dev/null +++ b/devel/gen-testdb.sh @@ -0,0 +1,131 @@ +#!/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.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 +# +# 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 + +SHORT_CORPUS=$(basename ${CORPUS:-database}) +DBNAME=${SHORT_CORPUS}${SUFFIX} +TARBALLNAME=${DBNAME}.tar.xz + +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" + +# wrap the resulting mail store and database in a tarball + +cp -a ${MAIL_DIR} ${TMP_DIRECTORY}/${DBNAME} +tar Jcf ${TMP_DIRECTORY}/${TARBALLNAME} -C ${TMP_DIRECTORY} ${DBNAME} +mkdir -p ${TEST_DIRECTORY}/test-databases +cp -a ${TMP_DIRECTORY}/${TARBALLNAME} ${TEST_DIRECTORY}/test-databases +test_expect_code 0 "create the output tarball ${TARBALLNAME}" \ + "test -f ${TEST_DIRECTORY}/test-databases/${TARBALLNAME}" + +# generate a checksum file +test_expect_code 0 "compute checksum" \ + "(cd ${TEST_DIRECTORY}/test-databases/ && sha256sum ${TARBALLNAME} > ${TARBALLNAME}.sha256)" +test_done -- 1.9.0