Skip to content

feat(diff): audit batch - --minimal, CLI matrix bashtest, bzl attrs, coverage - #228

Merged
helly25 merged 6 commits into
mainfrom
diff-audit-fixes
Jul 4, 2026
Merged

feat(diff): audit batch - --minimal, CLI matrix bashtest, bzl attrs, coverage#228
helly25 merged 6 commits into
mainfrom
diff-audit-fixes

Conversation

@helly25

@helly25 helly25 commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Single-PR batch closing everything found in the diff audit ("anything missing? full help? enough tests?"), chunked into commits:

  1. feat: --minimal disables the myers cost capDiffOptions::minimal / --minimal guarantee minimal myers diffs (GNU diff --minimal analog); 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.
  2. test: bashtest for the CLI surface — covers what unit tests can't: flag parsing of every algorithm × format combo, the --algorithm=unified alias (unified output; dies with a clear message combined with another format), --width plumbing, exit-code contract, and that --help names every algorithm and format.
  3. 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.
  4. test: close side-by-side coverage gapsFormatsIgnoreBlankLines loops all four formats; direct × side-by-side pinned by unit test and golden.
  5. 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 --width plumbing end to end.
  6. docs — README --minimal mention, CHANGELOG entry.

Deliberately not done (noted in CHANGELOG): max_diff_chunk_length and time_format stay library-only; the bzl fail() 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).
  • All pre-commit hooks (incl. trunk fmt) green locally; pushed once to spare the overloaded CI.

helly25 added 6 commits July 4, 2026 17:42
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.
@helly25
helly25 requested a review from Fab-Cat July 4, 2026 16:57
@helly25
helly25 merged commit fe35e56 into main Jul 4, 2026
4 of 8 checks passed
@helly25
helly25 deleted the diff-audit-fixes branch July 4, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants