feat(diff): audit batch - --minimal, CLI matrix bashtest, bzl attrs, coverage - #228
Merged
Conversation
DiffOptions::minimal / --minimal guarantee minimal myers diffs by disabling the max(64, sqrt(L+R)) cost cap (like GNU diff --minimal), at the price of O((L+R)*D) worst case time on highly divergent inputs. No effect on the other algorithms. Also refreshes the stale usage message: it now names all four output formats and the algorithm selection (side-by-side was missing), and fixes the '<old/lef>' typo. The new MyersMinimalOption test pins that the flag changes the result on a fixed noisy input (strictly fewer edits) and that both variants still apply cleanly.
Covers what unit tests cannot: flag parsing for every algorithm x format combination, the deprecated '--algorithm=unified' alias (selects unified output; dies with a clear message when combined with another format), --width plumbing, the exit code contract for equal files, and that the usage/help text names every algorithm and format.
The CLI bashtest now iterates every algorithm x format combination against checked-in expected outputs on the Myers paper example (ABCABBA/CBABAC), where the engines legitimately differ: myers minimal (5 edits), naive greedy resync (7), direct positional pairing. A combination without an expected file fails the test naming it, so an engine or format added without coverage - or an unsupported combination - is spotted immediately. Also pins that --minimal changes the myers result on this input.
FormatsIgnoreBlankLines now loops all four formats (the loop predates the side-by-side format); a new unit test pins direct x side-by-side (one '|' row per positional pair); and the direct_formats golden matrix gains the side-by-side golden (wired via BUILD in the follow-up commit).
The diff binary supported --width (side-by-side) and --skip_left_deletions, but the bazel diff_test rule and the in-repo diff_test_test macro could not pass them. Both gain the attributes (width = -1 keeps the tool default). New goldens pin the plumbing end to end: abc_axc side-by-side at width 40, and the direct_formats matrix now includes its side-by-side golden.
Fab-Cat
approved these changes
Jul 4, 2026
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.
Summary
Single-PR batch closing everything found in the diff audit ("anything missing? full help? enough tests?"), chunked into commits:
feat: --minimal disables the myers cost cap—DiffOptions::minimal/--minimalguarantee minimal myers diffs (GNUdiff --minimalanalog); previously the sqrt cost cap silently traded minimality on divergent inputs with no opt-out. Also fixes the stale usage message (side-by-side and the algorithm list were missing, plus the<old/lef>typo). Unit test pins that the flag strictly reduces edits on a fixed noisy input and both variants still apply.test: bashtest for the CLI surface— covers what unit tests can't: flag parsing of every algorithm × format combo, the--algorithm=unifiedalias (unified output; dies with a clear message combined with another format),--widthplumbing, exit-code contract, and that--helpnames every algorithm and format.test: full engine × format matrix with per-engine expected outputs— the bashtest iterates all algorithms × all formats against checked-in expected outputs on the Myers-paper pair (ABCABBA/CBABAC) where every engine legitimately differs (myers 5 edits minimal, naive 7 greedy, direct positional). A combination without an expected file fails by name — untested or unsupported cells are impossible to miss, and new engines/formats must bring expectations.test: close side-by-side coverage gaps—FormatsIgnoreBlankLinesloops all four formats; direct × side-by-side pinned by unit test and golden.feat: width and skip_left_deletions in the diff_test bzl rule— the binary supported both, the bazel rule couldn't pass them; goldens pin the--widthplumbing end to end.docs— README--minimalmention, CHANGELOG entry.Deliberately not done (noted in CHANGELOG):
max_diff_chunk_lengthandtime_formatstay library-only; the bzlfail()for the alias is load-time-only and stays untested; ed-script/RCS formats remain unimplemented.Test plan
bazel test //...— 98/98 pass locally (incl. the new bashtest: 8 functions, 12-cell matrix).