Problem
A test can fail an assertion and hit a runtime error — the common 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. The classifier then extracted the message with ${runtime_output#*: } — stripping to the first ": " anywhere in the blob, which lands inside "✗ Failed: Both" — and deleted the newlines:
✗ Error: Both
Both Expected 'a' but got 'b' at f_test.sh:2f_test.sh: line 4: nope: command not found
The reported "error" is the failure text with the diagnostic glued onto the end, on one line.
Expected
The message is the diagnostic, and nothing else:
✗ Error: Both
line 4: nope: command not found
Everything else the test printed is display output and stays there.
Note
_scan_diagnostic_lines already identifies the right line — it requires the ": line N: " prefix precisely so bashunit's own rendering cannot be mistaken for a diagnostic. It then throws that line away and extracts from the whole capture instead.
The unit test test_detect_runtime_error_strips_newlines_from_extracted_message pinned the broken shape ("line 1: foo: command not foundextra"), which is why this survived.
Problem
A test can fail an assertion and hit a runtime error — the common 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. The classifier then extracted the message with${runtime_output#*: }— stripping to the first": "anywhere in the blob, which lands inside"✗ Failed: Both"— and deleted the newlines:The reported "error" is the failure text with the diagnostic glued onto the end, on one line.
Expected
The message is the diagnostic, and nothing else:
Everything else the test printed is display output and stays there.
Note
_scan_diagnostic_linesalready identifies the right line — it requires the": line N: "prefix precisely so bashunit's own rendering cannot be mistaken for a diagnostic. It then throws that line away and extracts from the whole capture instead.The unit test
test_detect_runtime_error_strips_newlines_from_extracted_messagepinned the broken shape ("line 1: foo: command not foundextra"), which is why this survived.