X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=test%2Ftest-lib-common.sh;h=a96cfbeba019c081ef0f164ddffaad90561f06f3;hp=4903038dd9ce531ea7dda467a0d0eac6f86d8bd4;hb=1044775fc003914ee63b53254b7ca8700983a6e7;hpb=ce44657c9e4919b1e4bbbbbe37dbd72257d40736 diff --git a/test/test-lib-common.sh b/test/test-lib-common.sh index 4903038d..a96cfbeb 100644 --- a/test/test-lib-common.sh +++ b/test/test-lib-common.sh @@ -1,5 +1,6 @@ # # Copyright (c) 2005 Junio C Hamano +# Copyright (c) 2010 Notmuch Developers # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -12,11 +13,17 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see http://www.gnu.org/licenses/ . +# along with this program. If not, see https://www.gnu.org/licenses/ . # This file contains common code to be used by both the regular # (correctness) tests and the performance tests. +# test-lib.sh defines die() which echoes to nonstandard fd where +# output was redirected earlier in that file. If test-lib.sh is not +# loaded, neither this redirection nor die() function were defined. +# +type die >/dev/null 2>&1 || die () { echo "$@" >&2; exit 1; } + find_notmuch_path () { dir="$1" @@ -34,13 +41,30 @@ find_notmuch_path () done } +backup_database () { + test_name=$(basename $0 .sh) + rm -rf notmuch-dir-backup."$test_name" + cp -pR ${MAIL_DIR}/.notmuch 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 +} + # Test the binaries we have just built. The tests are kept in # test/ subdirectory and are run in 'trash directory' subdirectory. -TEST_DIRECTORY=$(pwd) +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 +. $notmuch_path/sh.config || exit 1 if test -n "$valgrind" then @@ -122,7 +146,7 @@ esac test ! -z "$debug" || remove_tmp=$TMP_DIRECTORY rm -fr "$test" || { GIT_EXIT_OK=t - echo >&5 "FATAL: Cannot prepare test area" + echo >&6 "FATAL: Cannot prepare test area" exit 1 } @@ -134,7 +158,6 @@ export HOME="${TMP_DIRECTORY}/home" mkdir -p "${HOME}" MAIL_DIR="${TMP_DIRECTORY}/mail" -export GNUPGHOME="${TMP_DIRECTORY}/gnupg" export NOTMUCH_CONFIG="${TMP_DIRECTORY}/notmuch-config" mkdir -p "${test}"