fix(runner): report only the diagnostic when a test also fails an assertion - #1268
Merged
Conversation
…ertion
bashunit renders a failure inside the capture subshell, so its own
`✗ Failed: <name>` text sits in the captured output ahead of any shell
diagnostic. Extracting the error with `${runtime_output#*: }` stripped to the
first ": " anywhere in that blob -- which lands inside our own rendering --
and then deleted the newlines, so a test that both failed an assertion and hit
a runtime error reported the failure text with the diagnostic glued on:
Both Expected 'a' but got 'b' at f.sh:2f.sh: line 4: nope: command not found
`_scan_diagnostic_lines` already finds the right line: it requires the
": line N: " prefix precisely so our rendering cannot be mistaken for a
diagnostic. It then discarded that line and read the whole capture instead.
Extract from the matched line, which is single by construction.
The old unit test pinned the broken shape, asserting the glued
"command not foundextra"; it now states the real contract, and the untouched
display output is asserted alongside it.
Closes #1267
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 #1267
A test can fail an assertion and hit a shell error — the everyday case being a mistyped helper, where
temp_file(missing thebashunit::prefix) both returns nothing and is acommand not found. bashunit renders the failure inside the capture subshell, so its own✗ Failed: <name>text sits in the captured output ahead of the shell's diagnostic.💡 Changes
${runtime_output#*: }over the whole capture, stripping to the first": "anywhere — which lands inside our own rendering — and then deleted the newlines, gluing the failure text and the diagnostic into one line_scan_diagnostic_linesalready identifies it, requiring the": line N: "prefix precisely so our own output cannot be mistaken for a diagnostic; it just threw that line away afterwards"command not foundextra") now states the real contract, and asserts the display output is left untouched