abcxyz / abc

Apache License 2.0
12 stars 3 forks source link

Remove text avalanche on golden test failure #506

Closed drevell closed 7 months ago

drevell commented 7 months ago

Before now, if a golden-test verify detected a diff between the actual vs expected output, it would print the entire file that didn't match, even if the diff was only one character. The diff could be thousands of lines, and you'd have to scroll forever to attempt to find the name of the failing test.

Alternative considered but not chosen: just format the diff better. The diffmatchpatch library can't really do this natively, so we'd have to pull in another library just to format the diff better. I didn't choose this option this because the diffmatchpatch library didn't seem so great in the first place, and the extra library we'd need to create a reasonable-looking diff would be even more janky (github.com/mrk21/go-diff-fmt).

What I chose to do: just run diff. We already depend on a unixy environment, and we already exec git, so there's not much downside to just execing diff. We get nice looking colorized unified diffs, which are concise and familiar to most developers.