unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 61ae48a316ad6d52755eb578a3db32230638ddf2 3846 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
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-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 || exit 1

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

debug log:

solving 61ae48a3 ...
found 61ae48a3 in https://yhetil.org/notmuch.git/

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).