| Q | A |
|---|
| OS | macOS 26.5.2 (arm64) |
| Shell & version | bash 3.2.57 |
| bashunit version | 0.50.0 |
Summary
When a test file fails to source, the test loop skips bashunit::cleanup_script_temp_files. Any bashunit::temp_file the file created at top level before the failure survives the run. The bench loop does call it on the same path, so the two runners disagree.
Smallest member of the family the #1318 fix belongs to: an early continue that drops one step of the cleanup block.
Current behavior
The file is reported as a source failure, and its script temp files stay on disk after the run finishes.
How to reproduce
badsource_test.sh, valid up to the last line:
LEAK="$(bashunit::temp_file leaky)":>"$LEAK"echo"$LEAK">"$CLEANUP_MARKER.path"functiontest_a() { assert_true true; }
if [ 1 -eq 1 ]$ CLEANUP_MARKER=/tmp/bu-bs.marker ./bashunit --no-parallel badsource_test.sh
Tests: 1 failed, 1 total
$ ls "$(cat /tmp/bu-bs.marker.path)"
/var/folders/.../bashunit/tmp/..._leaky.uevuXre
--parallel is not affected: the end-of-run loop at src/runner/discovery.sh:279 sweeps every id, and scripts_ids is appended at src/runner/discovery.sh:66 before any continue.
Expected behavior
The source-failure path sweeps the file's script temp files, the same as every other path out of the loop, and the same as the bench loop already does.
Where it happens
src/runner/discovery.sh:134-136: clean_set_up_and_tear_down_after_script, restore_workdir, continue. No cleanup_script_temp_files.src/runner/bench.sh:49-53: the bench equivalent, which does call it.
Acceptance criteria
Notes for the implementer
- Guard it the way the other paths do:
if ! bashunit::parallel::is_enabled; then bashunit::cleanup_script_temp_files; fi. Under --parallel the end-of-run sweep already owns it, and calling it in the loop would delete a live worker's files. - While here, check whether the source-failure path should also unset the functions a partially sourced file managed to define. That is a separate question. Do not fold it into this fix.
- Bash 3.0+ only. See
.claude/rules/bash-style.md. make sa, make lint, ./bashunit tests/, ./bashunit --parallel tests/.
Summary
When a test file fails to source, the test loop skips
bashunit::cleanup_script_temp_files. Anybashunit::temp_filethe file created at top level before the failure survives the run. The bench loop does call it on the same path, so the two runners disagree.Smallest member of the family the #1318 fix belongs to: an early
continuethat drops one step of the cleanup block.Current behavior
The file is reported as a source failure, and its script temp files stay on disk after the run finishes.
How to reproduce
badsource_test.sh, valid up to the last line:--parallelis not affected: the end-of-run loop atsrc/runner/discovery.sh:279sweeps every id, andscripts_idsis appended atsrc/runner/discovery.sh:66before anycontinue.Expected behavior
The source-failure path sweeps the file's script temp files, the same as every other path out of the loop, and the same as the bench loop already does.
Where it happens
src/runner/discovery.sh:134-136:clean_set_up_and_tear_down_after_script,restore_workdir,continue. Nocleanup_script_temp_files.src/runner/bench.sh:49-53: the bench equivalent, which does call it.Acceptance criteria
--no-parallel.#1137's "exit N, M bytes, no stderr" message keeps its wording.--parallelbehaviour unchanged.CHANGELOG.mdgets aFixedentry.Notes for the implementer
if ! bashunit::parallel::is_enabled; then bashunit::cleanup_script_temp_files; fi. Under--parallelthe end-of-run sweep already owns it, and calling it in the loop would delete a live worker's files..claude/rules/bash-style.md.make sa,make lint,./bashunit tests/,./bashunit --parallel tests/.