Skip to content

fix(runner): report only the diagnostic when a test also fails an assertion - #1268

Merged
Chemaclass merged 1 commit into
mainfrom
fix/1267-error-message-leak
Aug 15, 2026
Merged

fix(runner): report only the diagnostic when a test also fails an assertion#1268
Chemaclass merged 1 commit into
mainfrom
fix/1267-error-message-leak

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 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 the bashunit:: prefix) both returns nothing and is a command 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

  • The reported error is now the diagnostic alone. Extraction used ${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
  • Extract from the matched line instead. _scan_diagnostic_lines already 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
  • The unit test that pinned the broken shape ("command not foundextra") now states the real contract, and asserts the display output is left untouched

…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
@Chemaclass Chemaclass added the bug Something isn't working label Aug 15, 2026
@Chemaclass Chemaclass self-assigned this Aug 15, 2026
@Chemaclass
Chemaclass merged commit b14ff05 into main Aug 15, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the fix/1267-error-message-leak branch August 15, 2026 09:37
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