Skip to content

Commit 4672fb7

Browse files
committed
test(runner): fix strict-mode capture in stop-on-failure runtime error test
Under `--strict` (`set -euo pipefail`), `output=$(./bashunit …)` would abort the test body on the inner non-zero exit. Capture the exit code via `|| exit_code=$?` and compare with `assert_same`, since `assert_general_error` reads `$?` (or arg3), not arg1.
1 parent 98b3a67 commit 4672fb7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tests/acceptance/bashunit_stop_on_failure_test.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ function test_bashunit_when_stop_on_failure_env_simple_output() {
3434

3535
function test_bashunit_stop_on_failure_with_runtime_error() {
3636
local test_file=./tests/acceptance/fixtures/test_bashunit_stop_on_failure_runtime_error.sh
37-
local output
38-
output="$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --stop-on-failure "$test_file")"
37+
local output=""
38+
local exit_code=0
3939

40-
assert_general_error "$?"
40+
output="$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --stop-on-failure "$test_file")" || exit_code=$?
41+
42+
assert_same 1 "$exit_code"
4143
assert_contains "A runtime error" "$output"
4244
assert_not_contains "B not executed" "$output"
4345
}

0 commit comments

Comments
 (0)