You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A malformed benchmark annotation aborts bashunit bench with exit 1 from inside the per-file loop. set_up_before_script has already run at that point, and tear_down_after_script never does.
Same class as #1318, in the bench runner. #1319 paired setup with teardown on the bench setup-failure path. This is the other early exit on the same loop.
Current behavior
bashunit::benchmark::parse_annotations rejects the bad value, the runner exits 1, and the file's teardown hook is skipped.
$ CLEANUP_MARKER=/tmp/bu-bench.marker ./bashunit bench bench_bad.sh
● set_up_before_script 10ms
Running bench_bad.sh
Error: @revs in '# @revs=abc' is not a valid value.
$ ls /tmp/bu-bench.marker
/tmp/bu-bench.marker
Expected behavior
The annotation error still aborts the run with a non-zero status, and tear_down_after_script runs for the file whose setup already ran.
That sits inside bashunit::runner::call_bench_functions, called directly at src/runner/bench.sh:84
bashunit::runner::run_tear_down_after_script on src/runner/bench.sh:85 is never reached
Acceptance criteria
A test in tests/acceptance/bashunit_bench_test.sh following the shape of test_bench_cleans_up_when_set_up_before_script_fails: a bench file with a malformed annotation whose tear_down_after_script releases a resource, asserted gone with assert_file_not_exists.
The error message text and the non-zero exit code are unchanged. Existing annotation tests still pass.
CHANGELOG.md gets a Fixed entry.
Notes for the implementer
Return non-zero from call_bench_functions and let the loop finish the file, instead of exiting from the inner frame.
Keep the guarantee Malformed benchmark annotations are silently ignored #884 added: the exit status of $(...) inside read <<< is discarded, which is why the capture is separate and the failure is explicit. A malformed annotation must not be silently ignored.
Bash 3.0+ only. See .claude/rules/bash-style.md.
make sa, make lint, ./bashunit tests/, ./bashunit --parallel tests/.
Summary
A malformed benchmark annotation aborts
bashunit benchwithexit 1from inside the per-file loop.set_up_before_scripthas already run at that point, andtear_down_after_scriptnever does.Same class as #1318, in the bench runner. #1319 paired setup with teardown on the bench setup-failure path. This is the other early exit on the same loop.
Current behavior
bashunit::benchmark::parse_annotationsrejects the bad value, the runner exits 1, and the file's teardown hook is skipped.How to reproduce
bench_bad.sh:Expected behavior
The annotation error still aborts the run with a non-zero status, and
tear_down_after_scriptruns for the file whose setup already ran.Where it happens
src/runner/bench.sh:124:parsed_annotations=$(bashunit::benchmark::parse_annotations "$fn_name" "$script") || exit 1bashunit::runner::call_bench_functions, called directly atsrc/runner/bench.sh:84bashunit::runner::run_tear_down_after_scriptonsrc/runner/bench.sh:85is never reachedAcceptance criteria
tests/acceptance/bashunit_bench_test.shfollowing the shape oftest_bench_cleans_up_when_set_up_before_script_fails: a bench file with a malformed annotation whosetear_down_after_scriptreleases a resource, asserted gone withassert_file_not_exists.CHANGELOG.mdgets aFixedentry.Notes for the implementer
call_bench_functionsand let the loop finish the file, instead of exiting from the inner frame.$(...)insideread <<<is discarded, which is why the capture is separate and the failure is explicit. A malformed annotation must not be silently ignored..claude/rules/bash-style.md.make sa,make lint,./bashunit tests/,./bashunit --parallel tests/.