X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Ftest-lib-common.sh;h=2f7950ac75b7b6c61777560bb933d847b9a7e3f7;hp=984a7c1a579845faa29ac74013e2fb0f4fa11fa5;hb=7c7cebffe6f05c8bbb07c3714fde08562444c72e;hpb=43668950626f347f05aad7d49cd9ea4383030443 diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh index 984a7c1a..2f7950ac 100644 --- a/test/test-lib-common.sh +++ b/test/test-lib-common.sh @@ -24,51 +24,34 @@ # type die >/dev/null 2>&1 || die () { echo "$@" >&2; exit 1; } -find_notmuch_path () -{ - dir="$1" - - while [ -n "$dir" ]; do - bin="$dir/notmuch" - if [ -x "$bin" ]; then - echo "$dir" - return - fi - dir="$(dirname "$dir")" - if [ "$dir" = "/" ]; then - break - fi - done -} +if [[ -z "$NOTMUCH_SRCDIR" ]] || [[ -z "$NOTMUCH_BUILDDIR" ]]; then + echo "internal: srcdir or builddir not set" >&2 + exit 1 +fi backup_database () { test_name=$(basename $0 .sh) - rm -rf notmuch-dir-backup."$test_name" - cp -pR ${MAIL_DIR}/.notmuch notmuch-dir-backup."${test_name}" + rm -rf $TMP_DIRECTORY/notmuch-dir-backup."$test_name" + cp -pR ${MAIL_DIR}/.notmuch $TMP_DIRECTORY/notmuch-dir-backup."${test_name}" } restore_database () { test_name=$(basename $0 .sh) rm -rf ${MAIL_DIR}/.notmuch - cp -pR notmuch-dir-backup."${test_name}" ${MAIL_DIR}/.notmuch + cp -pR $TMP_DIRECTORY/notmuch-dir-backup."${test_name}" ${MAIL_DIR}/.notmuch } -# Test the binaries we have just built. The tests are kept in -# test/ subdirectory and are run in 'trash directory' subdirectory. -TEST_DIRECTORY=$(pwd -P) -notmuch_path=`find_notmuch_path "$TEST_DIRECTORY"` - # Prepend $TEST_DIRECTORY/../lib to LD_LIBRARY_PATH, to make tests work # on systems where ../notmuch depends on LD_LIBRARY_PATH. LD_LIBRARY_PATH=${TEST_DIRECTORY%/*}/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} export LD_LIBRARY_PATH # configure output -. $notmuch_path/sh.config || exit 1 +. "$NOTMUCH_BUILDDIR/sh.config" || exit 1 # load OS specifics -if [ -e ./test-lib-$PLATFORM.sh ]; then - . ./test-lib-$PLATFORM.sh || exit 1 +if [[ -e "$NOTMUCH_SRCDIR/test/test-lib-$PLATFORM.sh" ]]; then + . "$NOTMUCH_SRCDIR/test/test-lib-$PLATFORM.sh" || exit 1 fi # Generate a new message in the mail directory, with a unique message @@ -308,25 +291,21 @@ then PATH=$GIT_VALGRIND/bin:$PATH GIT_EXEC_PATH=$GIT_VALGRIND/bin export GIT_VALGRIND - test -n "$notmuch_path" && MANPATH="$notmuch_path/doc/_build/man" + test -n "$NOTMUCH_BUILDDIR" && MANPATH="$NOTMUCH_BUILDDIR/doc/_build/man" else # normal case - if test -n "$notmuch_path" + if test -n "$NOTMUCH_BUILDDIR" then - PATH="$notmuch_path:$PATH" - MANPATH="$notmuch_path/doc/_build/man" + PATH="$NOTMUCH_BUILDDIR:$PATH" + MANPATH="$NOTMUCH_BUILDDIR/doc/_build/man" fi fi export PATH MANPATH # Test repository test="tmp.$(basename "$0" .sh)" -test -n "$root" && test="$root/$test" -case "$test" in -/*) TMP_DIRECTORY="$test" ;; - *) TMP_DIRECTORY="$TEST_DIRECTORY/$test" ;; -esac +TMP_DIRECTORY="$TEST_DIRECTORY/$test" test ! -z "$debug" || remove_tmp=$TMP_DIRECTORY -rm -fr "$test" || { +rm -rf "$TMP_DIRECTORY" || { GIT_EXIT_OK=t echo >&6 "FATAL: Cannot prepare test area" exit 1 @@ -342,7 +321,6 @@ mkdir -p "${HOME}" MAIL_DIR="${TMP_DIRECTORY}/mail" export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config" -mkdir -p "${test}" mkdir -p "${MAIL_DIR}" cat <"${NOTMUCH_CONFIG}"