aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-07-14 15:56:06 +0200
committerGitHub <noreply@github.com>2022-07-14 15:56:06 +0200
commit73ff9b863c479c79ee2dd73039504060b8483d0d (patch)
tree3420a5cfcc17d632a5ff1ac039df524d27c3976a /tests
parent819615c7f477799c6a0fcd1953012a393907c9eb (diff)
parent2532fee157adf45bcd262f0f24a1740990df6e76 (diff)
Merge pull request #6803 from edolstra/test-stack-trace
On test failures, print a bash stack trace
Diffstat (limited to 'tests')
-rw-r--r--tests/common.sh.in19
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/common.sh.in b/tests/common.sh.in
index 5efd025ee..79da10199 100644
--- a/tests/common.sh.in
+++ b/tests/common.sh.in
@@ -119,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
@@ -190,4 +190,15 @@ if [[ -n "${NIX_DAEMON_PACKAGE:-}" ]]; then
startDaemon
fi
+onError() {
+ set +x
+ echo "$0: test failed at:" >&2
+ for ((i = 1; i < 16; 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