#
type die >/dev/null 2>&1 || die () { echo "$@" >&2; exit 1; }
-if [[ -z "$NOTMUCH_SRCDIR" ]] || [[ -z "$NOTMUCH_BUILDDIR" ]]; then
+if [[ -z "$NOTMUCH_SRCDIR" ]] || [ -z "${NOTMUCH_TEST_INSTALLED-}" -a -z "$NOTMUCH_BUILDDIR" ]; then
echo "internal: srcdir or builddir not set" >&2
exit 1
fi
+# Explicitly require external prerequisite. Useful when binary is
+# called indirectly (e.g. from emacs).
+# Returns success if dependency is available, failure otherwise.
+test_require_external_prereq () {
+ local binary
+ binary="$1"
+ if [[ ${test_missing_external_prereq_["${binary}"]} == t ]]; then
+ # dependency is missing, call the replacement function to note it
+ eval "$binary"
+ else
+ true
+ fi
+}
+
backup_database () {
test_name=$(basename $0 .sh)
rm -rf $TMP_DIRECTORY/notmuch-dir-backup."$test_name"
export LD_LIBRARY_PATH
# configure output
-. "$NOTMUCH_BUILDDIR/sh.config" || exit 1
+if [ -z "${NOTMUCH_TEST_INSTALLED-}" ]; then
+ . "$NOTMUCH_BUILDDIR/sh.config" || exit 1
+fi
# load OS specifics
if [[ -e "$NOTMUCH_SRCDIR/test/test-lib-$PLATFORM.sh" ]]; then
gen_msg_cnt=0
gen_msg_filename=""
gen_msg_id=""
-generate_message ()
-{
+generate_message () {
# This is our (bash-specific) magic for doing named parameters
local -A template="($@)"
local additional_headers
#
# All of the arguments and return values supported by generate_message
# are also supported here, so see that function for details.
-add_message ()
-{
+add_message () {
generate_message "$@" &&
notmuch new > /dev/null
}
# Test repository
test="tmp.$(basename "$0" .sh)"
-TMP_DIRECTORY="$TEST_DIRECTORY/$test"
+if [ -z "${NOTMUCH_TEST_INSTALLED-}" ]; then
+ TMP_DIRECTORY="$TEST_DIRECTORY/$test"
+else
+ TMP_DIRECTORY=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-$test.XXXXXX")
+fi
+
test ! -z "$debug" || remove_tmp=$TMP_DIRECTORY
rm -rf "$TMP_DIRECTORY" || {
GIT_EXIT_OK=t
exit 1
}
+# Provide a guess at a usable Python, to support running tests without
+# running configure first.
+NOTMUCH_PYTHON=${NOTMUCH_PYTHON-python3}
+
# A temporary home directory is needed by at least:
# - emacs/"Sending a message via (fake) SMTP"
# - emacs/"Reply within emacs"