mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 09:24:54 +01:00
test: split variable settings to their own file
This allows sharing more variable settings between the (correctness) tests and the performance-tests. Unfortunately it seems a bit tricky to move settings to test-lib-common.sh, as that is sourced late in test-lib.sh, and moving it earlier breaks things.
This commit is contained in:
parent
92b6b991b0
commit
371fa28ced
3 changed files with 61 additions and 54 deletions
|
@ -41,6 +41,8 @@ done
|
|||
# Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set.
|
||||
. $(dirname "$0")/../test/export-dirs.sh || exit 1
|
||||
|
||||
. "$NOTMUCH_SRCDIR/test/test-vars.sh" || exit 1
|
||||
|
||||
# Where to run the tests
|
||||
TEST_DIRECTORY=$NOTMUCH_BUILDDIR/performance-test
|
||||
|
||||
|
|
|
@ -64,55 +64,7 @@ exec 6>&1 7>&2
|
|||
BASH_XTRACEFD=7
|
||||
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||
|
||||
# Keep the original TERM for say_color and test_emacs
|
||||
ORIGINAL_TERM=$TERM
|
||||
|
||||
# Set SMART_TERM to vt100 for known dumb/unknown terminal.
|
||||
# Otherwise use whatever TERM is currently used so that
|
||||
# users' actual TERM environments are being used in tests.
|
||||
case ${TERM-} in
|
||||
'' | dumb | unknown )
|
||||
SMART_TERM=vt100 ;;
|
||||
*)
|
||||
SMART_TERM=$TERM ;;
|
||||
esac
|
||||
|
||||
# For repeatability, reset the environment to known value.
|
||||
LANG=C
|
||||
LC_ALL=C
|
||||
PAGER=cat
|
||||
TZ=UTC
|
||||
TERM=dumb
|
||||
export LANG LC_ALL PAGER TERM TZ
|
||||
GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
|
||||
if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \
|
||||
( -z "$TEST_EMACS" && -n "$TEST_EMACSCLIENT" ) ]]; then
|
||||
echo "error: must specify both or neither of TEST_EMACS and TEST_EMACSCLIENT" >&2
|
||||
exit 1
|
||||
fi
|
||||
TEST_EMACS=${TEST_EMACS:-${EMACS:-emacs}}
|
||||
TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient}
|
||||
TEST_GDB=${TEST_GDB:-gdb}
|
||||
TEST_CC=${TEST_CC:-cc}
|
||||
TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}
|
||||
TEST_SHIM_CFLAGS=${TEST_SHIM_CFLAGS:-"-fpic -shared"}
|
||||
TEST_SHIM_LDFLAGS=${TEST_SHIM_LDFLAGS:-"-ldl"}
|
||||
|
||||
# Protect ourselves from common misconfiguration to export
|
||||
# CDPATH into the environment
|
||||
unset CDPATH
|
||||
|
||||
unset GREP_OPTIONS
|
||||
|
||||
# For lib/open.cc:_load_key_file
|
||||
unset XDG_CONFIG_HOME
|
||||
|
||||
# For emacsclient
|
||||
unset ALTERNATE_EDITOR
|
||||
|
||||
# for reproducibility
|
||||
unset EMAIL
|
||||
unset NAME
|
||||
. "$NOTMUCH_SRCDIR/test/test-vars.sh" || exit 1
|
||||
|
||||
add_gnupg_home () {
|
||||
[ -e "${GNUPGHOME}/gpg.conf" ] && return
|
||||
|
@ -330,11 +282,6 @@ die () {
|
|||
exit 1
|
||||
}
|
||||
|
||||
GIT_EXIT_OK=
|
||||
# Note: TEST_TMPDIR *NOT* exported!
|
||||
TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX")
|
||||
# Put GNUPGHOME in TMPDIR to avoid problems with long paths.
|
||||
export GNUPGHOME="${TEST_TMPDIR}/gnupg"
|
||||
trap 'trap_exit' EXIT
|
||||
trap 'trap_signal' HUP INT TERM
|
||||
|
||||
|
|
58
test/test-vars.sh
Normal file
58
test/test-vars.sh
Normal file
|
@ -0,0 +1,58 @@
|
|||
# Common variable settings for (correctness) tests and performance
|
||||
# tests.
|
||||
|
||||
# Keep the original TERM for say_color and test_emacs
|
||||
ORIGINAL_TERM=$TERM
|
||||
|
||||
# Set SMART_TERM to vt100 for known dumb/unknown terminal.
|
||||
# Otherwise use whatever TERM is currently used so that
|
||||
# users' actual TERM environments are being used in tests.
|
||||
case ${TERM-} in
|
||||
'' | dumb | unknown )
|
||||
SMART_TERM=vt100 ;;
|
||||
*)
|
||||
SMART_TERM=$TERM ;;
|
||||
esac
|
||||
|
||||
# For repeatability, reset the environment to known value.
|
||||
LANG=C
|
||||
LC_ALL=C
|
||||
PAGER=cat
|
||||
TZ=UTC
|
||||
TERM=dumb
|
||||
export LANG LC_ALL PAGER TERM TZ
|
||||
GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
|
||||
if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \
|
||||
( -z "$TEST_EMACS" && -n "$TEST_EMACSCLIENT" ) ]]; then
|
||||
echo "error: must specify both or neither of TEST_EMACS and TEST_EMACSCLIENT" >&2
|
||||
exit 1
|
||||
fi
|
||||
TEST_EMACS=${TEST_EMACS:-${EMACS:-emacs}}
|
||||
TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient}
|
||||
TEST_GDB=${TEST_GDB:-gdb}
|
||||
TEST_CC=${TEST_CC:-cc}
|
||||
TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}
|
||||
TEST_SHIM_CFLAGS=${TEST_SHIM_CFLAGS:-"-fpic -shared"}
|
||||
TEST_SHIM_LDFLAGS=${TEST_SHIM_LDFLAGS:-"-ldl"}
|
||||
|
||||
# Protect ourselves from common misconfiguration to export
|
||||
# CDPATH into the environment
|
||||
unset CDPATH
|
||||
|
||||
unset GREP_OPTIONS
|
||||
|
||||
# For lib/open.cc:_load_key_file
|
||||
unset XDG_CONFIG_HOME
|
||||
|
||||
# For emacsclient
|
||||
unset ALTERNATE_EDITOR
|
||||
|
||||
# for reproducibility
|
||||
unset EMAIL
|
||||
unset NAME
|
||||
|
||||
GIT_EXIT_OK=
|
||||
# Note: TEST_TMPDIR *NOT* exported!
|
||||
TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX")
|
||||
# Put GNUPGHOME in TMPDIR to avoid problems with long paths.
|
||||
export GNUPGHOME="${TEST_TMPDIR}/gnupg"
|
Loading…
Reference in a new issue