diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-06 10:56:22 -0500 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2023-01-06 10:56:22 -0500 |
commit | 989b8065b45e52a8df2a803b1a72e0d0a7c35536 (patch) | |
tree | ffd7d779cf35dc13396aef3b1871a7bc954af350 /tests/common.sh.in | |
parent | 08b8657978de0d56064aad9c3e925b64d91b28a2 (diff) | |
parent | e9fc1e4fdb0ab5adb6b163c3db361b86a4f5c69b (diff) |
Merge branch 'path-info' into ca-drv-exotic
Diffstat (limited to 'tests/common.sh.in')
-rw-r--r-- | tests/common.sh.in | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/tests/common.sh.in b/tests/common.sh.in index 8ce28d318..73c2d2309 100644 --- a/tests/common.sh.in +++ b/tests/common.sh.in @@ -50,6 +50,8 @@ export busybox="@sandbox_shell@" export version=@PACKAGE_VERSION@ export system=@system@ +export BUILD_SHARED_LIBS=@BUILD_SHARED_LIBS@ + export IMPURE_VAR1=foo export IMPURE_VAR2=bar @@ -117,11 +119,11 @@ killDaemon() { } restartDaemon() { - [[ -z "${pidDaemon:-}" ]] && return 0 + [[ -z "${pidDaemon:-}" ]] && return 0 - killDaemon - unset NIX_REMOTE - startDaemon + killDaemon + unset NIX_REMOTE + startDaemon } if [[ $(uname) == Linux ]] && [[ -L /proc/self/ns/user ]] && unshare --user true; then @@ -157,11 +159,12 @@ expect() { local expected res expected="$1" shift - set +e - "$@" - res="$?" - set -e - [[ $res -eq $expected ]] + "$@" || res="$?" + if [[ $res -ne $expected ]]; then + echo "Expected '$expected' but got '$res' while running '$*'" + return 1 + fi + return 0 } needLocalStore() { @@ -187,4 +190,15 @@ if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then startDaemon fi +onError() { + set +x + echo "$0: test failed at:" >&2 + for ((i = 1; i < ${#BASH_SOURCE[@]}; i++)); do + if [[ -z ${BASH_SOURCE[i]} ]]; then break; fi + echo " ${FUNCNAME[i]} in ${BASH_SOURCE[i]}:${BASH_LINENO[i-1]}" >&2 + done +} + +trap onError ERR + fi # COMMON_SH_SOURCED |