🤔 Background
Under --parallel, a failing set_up_before_script is written into the report twice. The console summary of the very same run says once, and the console is right.
$ bashunit --parallel --report-json r.json tests/✗ Error: Set up before scriptTests: 1 failed, 1 total <- console
$ jq '.summary, (.tests|length)' r.json{ "total": 2, "failed": 2, ... } <- report2Sequentially the same fixture reports total: 1, failed: 1. Also hits a failing tear_down_after_script and a file that fails to source, and it applies to every writer that reads those arrays — JSON, JUnit, HTML, Markdown — so a CI dashboard shows inflated failure counts and duplicate test entries.
💡 Cause
A file-level hook failure is recorded by the parent, not by a worker (bashunit::runner::record_file_hook_failure, src/runner/hooks.sh). bashunit::reports::add_test fills the report arrays for every caller, and additionally spools the row when --parallel is on. The parent's row therefore exists in both places, and bashunit::reports::load_spooled appends the spool to the arrays it is already in.
The comment on add_test states "the parent never reaches this path for a real parallel test, so replaying the spool cannot double-count" — that holds for test bodies, which do run in workers, but not for file-level hooks.
load_spooled should replace the arrays rather than append: the spool is the complete record of a parallel run, since workers and the parent both write to it.
💡 Found by
Extending the sweep from #1297/#1299 from document validity to document content: comparing the JSON summary of each pathological fixture between sequential and --parallel. Three of eleven fixtures disagreed, all in the same direction.
🤔 Background
Under
--parallel, a failingset_up_before_scriptis written into the report twice. The console summary of the very same run says once, and the console is right.Sequentially the same fixture reports
total: 1, failed: 1. Also hits a failingtear_down_after_scriptand a file that fails to source, and it applies to every writer that reads those arrays — JSON, JUnit, HTML, Markdown — so a CI dashboard shows inflated failure counts and duplicate test entries.💡 Cause
A file-level hook failure is recorded by the parent, not by a worker (
bashunit::runner::record_file_hook_failure,src/runner/hooks.sh).bashunit::reports::add_testfills the report arrays for every caller, and additionally spools the row when--parallelis on. The parent's row therefore exists in both places, andbashunit::reports::load_spooledappends the spool to the arrays it is already in.The comment on
add_teststates "the parent never reaches this path for a real parallel test, so replaying the spool cannot double-count" — that holds for test bodies, which do run in workers, but not for file-level hooks.load_spooledshould replace the arrays rather than append: the spool is the complete record of a parallel run, since workers and the parent both write to it.💡 Found by
Extending the sweep from #1297/#1299 from document validity to document content: comparing the JSON summary of each pathological fixture between sequential and
--parallel. Three of eleven fixtures disagreed, all in the same direction.