From e50c19f284dad6b4b7b79f91cc8576a97626be8a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 16 Dec 2022 15:32:04 -0500 Subject: tests: Turn on set -e --- tests/tests.sh | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'tests/tests.sh') diff --git a/tests/tests.sh b/tests/tests.sh index 844de5c..7ccd9b5 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -476,16 +476,24 @@ function bfs_verbose() { function invoke_bfs() { bfs_verbose "$@" "${BFS[@]}" "$@" - local status=$? + local status="$?" # Allow bfs to fail, but not crash if ((status > 125)); then - exit $status + exit "$status" else - return $status + return "$status" fi } +function check_exit() { + local expected="$1" + local actual="0" + shift + "$@" || actual="$?" + ((actual == expected)) +} + # Detect colored diff support if [ -t 2 ] && diff --color=always /dev/null /dev/null 2>/dev/null; then DIFF="diff --color=always" @@ -655,9 +663,9 @@ for TEST in "${TEST_CASES[@]}"; do mkdir -p "${OUT%/*}" if [ "$VERBOSE_ERRORS" ]; then - (. "$TESTS/$TEST.sh") + (set -e; . "$TESTS/$TEST.sh") else - (. "$TESTS/$TEST.sh") 2>"$TMP/stderr" + (set -e; . "$TESTS/$TEST.sh") 2>"$TMP/stderr" fi status=$? -- cgit v1.2.3