Skip to content

fix(runner): keep the tear_down blank line out of machine output - #1298

Merged
Chemaclass merged 2 commits into
mainfrom
fix/junit-blank-line-tear-down-after-script
Aug 17, 2026
Merged

fix(runner): keep the tear_down blank line out of machine output#1298
Chemaclass merged 2 commits into
mainfrom
fix/junit-blank-line-tear-down-after-script

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1297

--output promises stdout is the document. A file with a tear_down_after_script wrote a blank line there first, so the XML declaration was no longer at byte 0:

$ bashunit --no-parallel --output junit tests/ | od -c | head -1
0000000  \n   <   ?   x   m   l       v   e   r   s   i   o   n   =   "
ExpatError: XML or text declaration not at start of entity

The hook did not have to fail — an ordinary tear_down_after_script() { :; } was enough, which makes this ordinary usage rather than an edge case. --parallel skipped the line entirely, so the modes also disagreed.

💡 Changes

  • The blank line after tear_down_after_script now carries the same machine-format guards its sibling path already had. tap stays excluded on purpose: it streams line by line, so a blank line between files is valid there and its snapshots record it
  • --output json carried the same stray byte and only parsed because JSON tolerates leading whitespace; it is gone from that stream too

🔍 How it was found

Extending the sweep from #1295 to assert the document contract rather than the console summary: every pathological fixture × {sequential, parallel} × {json, junit}, each one actually parsed. Two further unrelated cases from that table are filed separately.

hooks.sh prints this blank line from two sibling paths. The early-return one
guards on is_json_output_enabled and is_junit_output_enabled; the path taken
when tear_down_after_script exists and ran omitted both, so the line landed
on stdout ahead of the document.

XML wants its declaration at byte 0, so an ordinary tear_down_after_script --
the hook did not have to fail -- made --output junit unparseable. JSON carried
the same stray byte but tolerates leading whitespace. --parallel skipped the
line entirely, so the two modes disagreed.

tap stays excluded on purpose: it streams line by line.

Closes #1297
@Chemaclass Chemaclass added the bug Something isn't working label Aug 16, 2026
@Chemaclass Chemaclass self-assigned this Aug 16, 2026
…tear-down-after-script

# Conflicts:
#	CHANGELOG.md
#	tests/acceptance/bashunit_output_stdout_test.sh
@Chemaclass
Chemaclass merged commit 267baa6 into main Aug 17, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/junit-blank-line-tear-down-after-script branch August 17, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant