Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Allow most assert functions to accept an optional trailing label parameter to override the failure message title (e.g. `assert_same "a" "$b" "checking user name"`) (#77)

### Fixed
- Fix `--stop-on-failure` not stopping when a test errors with a runtime error (e.g. `command not found`, `illegal option`) (#383)
- Fix spying on `echo` or `printf` causing bashunit to hang due to infinite recursion (#607)
- Fix invalid `.env.example` coverage threshold entry and copy `.env.example` to `.env` in CI test workflows so configuration parse errors are caught during automated test runs
- Fix `clock::now` shell-time parsing when `EPOCHREALTIME` uses a comma decimal separator
Expand Down
8 changes: 8 additions & 0 deletions src/runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,14 @@ function bashunit::runner::run_test() {
bashunit::reports::add_test_failed "$test_file" "$failure_label" "$duration" "$total_assertions" "$error_message"
bashunit::runner::write_failure_result_output "$test_file" "$failure_function" "$error_message" "$runtime_output"
bashunit::internal_log "Test error" "$failure_label" "$error_message"

if bashunit::env::is_stop_on_failure_enabled; then
if bashunit::parallel::is_enabled; then
bashunit::parallel::mark_stop_on_failure
else
exit "$EXIT_CODE_STOP_ON_FAILURE"
fi
fi
return
fi

Expand Down
12 changes: 12 additions & 0 deletions tests/acceptance/bashunit_stop_on_failure_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,15 @@ function test_bashunit_when_stop_on_failure_env_simple_output() {
assert_match_snapshot "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_STOP_ON_FAILURE" "$test_file" --simple)"
assert_general_error "$(./bashunit --no-parallel --env "$TEST_ENV_FILE_STOP_ON_FAILURE" "$test_file" --simple)"
}

function test_bashunit_stop_on_failure_with_runtime_error() {
local test_file=./tests/acceptance/fixtures/test_bashunit_stop_on_failure_runtime_error.sh
local output=""
local exit_code=0

output="$(./bashunit --no-parallel --env "$TEST_ENV_FILE" --stop-on-failure "$test_file")" || exit_code=$?

assert_same 1 "$exit_code"
assert_contains "A runtime error" "$output"
assert_not_contains "B not executed" "$output"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

function test_a_runtime_error() {
nonexistent_command_bashunit_383_xyz
}

function test_b_not_executed() {
assert_same 1 1
}
Loading