feat(console): unified diff for multiline assert_equals/assert_same failures#790
Merged
Conversation
assert_equals/assert_same failures with multiline expected or actual values now render a git word-diff below the Expected/but got header (inline values truncated to their first line + ellipsis while the diff is shown), making command-output/file-content differences readable. Extracts the snapshot-failure diff block into a shared bashunit::console_results::render_diff helper (now color-aware: honors --no-color instead of always colorizing). Single-line failures and machine reports (JUnit/TAP/JSON) are byte-identical. Requires git (graceful plain fallback); opt out with BASHUNIT_NO_DIFF=true. Closes #777
CI copies .env.example to .env, whose empty BASHUNIT_NO_DIFF= line was sourced with allexport and clobbered the inherited BASHUNIT_NO_DIFF=true, re-enabling the diff. Pass --skip-env-file (as the other spawned-bashunit acceptance tests do) so the test env is deterministic.
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 #777
For multiline strings (command output, file contents),
assert_equals/assert_samefailures print two quoted blobs and you hunt for the difference by eye. Snapshot failures already render agit diff— this reuses that machinery for assert failures.💡 Changes
assert_equals/assert_samefailures now render a git word-diff below the header, truncating the inline values to their first line while the diff is shownrender_diffhelper, now color-aware (honors--no-colorinstead of always colorizing)BASHUNIT_NO_DIFF=true