# Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set.
. $(dirname "$0")/export-dirs.sh || exit 1
-# It appears that people try to run tests without building...
-if [[ ! -x "$NOTMUCH_BUILDDIR/notmuch" ]]; then
+# We need either a built tree, or a promise of an installed notmuch
+if [ -z "${NOTMUCH_TEST_INSTALLED-}" -a ! -x "$NOTMUCH_BUILDDIR/notmuch" ]; then
echo >&2 'You do not seem to have built notmuch yet.'
exit 1
fi
test "$#" = 2 ||
error "bug in the test script: not 2 parameters to test_expect_equal_file"
+ for file in "$1" "$2"; do
+ if [ ! -s "$file" ]; then
+ test_failure_ "Missing or zero length file: $file"
+ inside_subtest=
+ return 1
+ fi
+ done
+
expected=$(sed '1,/^$/d' "$1")
output=$(sed '1,/^$/d' "$2")
test_expect_equal "$expected" "$output"
test_subtest_known_broken_=t
}
+test_subtest_broken_for_installed () {
+ if [ -n "${NOTMUCH_TEST_INSTALLED-}" ]; then
+ test_subtest_known_broken_=t
+ fi
+}
+
+test_subtest_broken_for_root () {
+ if [ "$EUID" = "0" ]; then
+ test_subtest_known_broken_=t
+ fi
+}
+
test_expect_success () {
exec 1>&6 2>&7 # Restore stdout and stderr
if [ -z "$inside_subtest" ]; then
}
notmuch_with_shim () {
- local base_name shim_file
- base_name="$1"
+ local base_name shim_file notmuch_cmd
+ if [ -n "${NOTMUCH_TEST_INSTALLED-}" ]; then
+ notmuch_cmd="notmuch"
+ else
+ notmuch_cmd="notmuch-shared"
+ fi
+ base_name=$1
shift
shim_file="${base_name}.so"
- LD_PRELOAD=${LD_PRELOAD:+:$LD_PRELOAD}:./${shim_file} notmuch-shared "$@"
+ LD_PRELOAD=${LD_PRELOAD:+:$LD_PRELOAD}:./${shim_file} $notmuch_cmd "$@"
}
# Creates a script that counts how much time it is executed and calls
# Where to run the tests
-TEST_DIRECTORY=$NOTMUCH_BUILDDIR/test
+if [[ -n "${NOTMUCH_BUILDDIR}" ]]; then
+ TEST_DIRECTORY=$NOTMUCH_BUILDDIR/test
+else
+ TEST_DIRECTORY=$NOTMUCH_SRCDIR/test
+fi
. "$NOTMUCH_SRCDIR/test/test-lib-common.sh" || exit 1