From: Simon McVittie Date: Sun, 18 Apr 2021 11:45:24 +0000 (+0100) Subject: libtest-core: On failure, make it clearer what has happened X-Git-Tag: archive/raspbian/2022.1-3+rpi1~1^2~4^2~3^2~8^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d7cdde5d3445e004c783f86a985d58725f3e6646;p=ostree.git libtest-core: On failure, make it clearer what has happened If we fail as a result of `set -x`, It's often not completely obvious which command failed or how. Use a trap on ERR to show the command that failed, and its exit status. Signed-off-by: Simon McVittie --- diff --git a/tests/kolainst/libtest-core.sh b/tests/kolainst/libtest-core.sh index 471a63f0..7179a408 100644 --- a/tests/kolainst/libtest-core.sh +++ b/tests/kolainst/libtest-core.sh @@ -179,3 +179,11 @@ skip() { echo "1..0 # SKIP" "$@" exit 0 } + +report_err () { + local exit_status="$?" + { { local BASH_XTRACEFD=3; } 2> /dev/null + echo "Unexpected nonzero exit status $exit_status while running: $BASH_COMMAND" >&2 + } 3> /dev/null +} +trap report_err ERR