fix(output): keep the console blank line out of json and junit - #1244
Merged
Conversation
`bashunit --output junit` produced XML no parser accepts: the first byte was a newline, so the declaration was not first. Sequential is the default, and only the parallel path was correct -- which is also the only path the existing guard test covers. run_tear_down_after_script prints a blank line between a file's tests and the next when the file has no tear_down_after_script hook. It was guarded against --simple, --failures-only, --no-progress and --parallel, but not against a machine --output, and both documents are written at the end of the run. The json document gained the same leading blank line, unnoticed because JSON tolerates leading whitespace, so `jq` accepted it and the test that only checks it parses stayed green. Name json and junit rather than using is_machine_output_enabled, which also covers tap: TAP streams line by line, so a blank line between files is valid there and is what its snapshots record. Closes #1243
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Related #1243
The document's first byte is a newline. Only the parallel path was correct — and parallel is not the default — so the plain documented command was the broken one.
run_tear_down_after_scriptprints a blank line between files, guarded against--simple,--failures-only,--no-progressand--parallel, but not against a machine--output.--output jsongained the same leading blank line, unnoticed because JSON tolerates leading whitespace:jqaccepted it, and the existing test only checks that it parses.💡 Changes
jsonandjunit, naming those two formats rather than usingis_machine_output_enabled— that also coverstap, where a blank line between files is valid, streams fine and is recorded in its snapshots--parallel(the path that already worked)xmllint, since asserting the first line is not the same as asserting a parser accepts the documentHuman output is unchanged: the blank line still separates files. Verified separately that escaping was never the problem —
<,&,",]]>and backslashes, tabs and unicode all round-trip correctly in both formats, and the on-disk--report-junit/--report-jsonwriters were unaffected.