Skip to content

WIP: test(corpus): diff3 golden corpus + sdiff expansion for #1127 P1 - #1440

Merged
caomengxuan666 merged 1 commit into
mainfrom
corpus/diff3-sdiff-1127
Oct 29, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
corpus/diff3-sdiff-1127

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #1127

Closes the P1 verification remainder of #1127: the diff3 option surface (-E/--easy-only etc.) is fully implemented, but diff3 had no differential corpus (EXEMPT.md "Not yet covered", absent from baseline.json) and sdiff had exactly one corpus case.

What this adds

  • 26 diff3 cases (tests/differential/corpus/diff3/): base 3-file shapes (identical, one-side changes, both-same change, delete-vs-edit overlap, empty orig) plus the implemented option surface — -A/--show-all, -E/--show-overlap, -3/--easy-only, -x/--overlap-only, -X/--overlap-bracket (a shape GNU never brackets on, pinned as such), -e/--ed, -i, -m/--merge, -T/--initial-tab, -L/--label ×3, --diff-program, --strip-trailing-cr.
  • 19 new sdiff cases (1 → 20 total): -l, -s, -w, -i, -b, -W/--ignore-all-space, -B (both the -s face and the display face), -I, -t, -E (--ignore-tab-expansion), --strip-trailing-cr, -d, -a, and -o auto-merge outcomes (scripted-stdin equivalence + the identical-input case).
  • Registration: 45 new baseline.json entries (purely additive), 4 whitelist.txt entries, and diff3 removed from EXEMPT.md (72/169 commands now differentially tested). No master-cases.json entries: that mechanism is coreutils-stdin-only (master-oracle.py builds GNU coreutils master; diffutils cases would fail there).

Oracle & verification

  • Oracle: local GNU diffutils 3.10 (diff3 --version / sdiff --version), matching the repo's pinned expectation. Expected behavior is always GNU's; no applet code is touched.
  • Every case was executed against the oracle with runner-identical semantics, and the whole set was smoke-tested through runner.sh itself (GNU-vs-GNU): diff3 26/26 PASS, sdiff 21/21 PASS (incl. the pre-existing regression case).
  • Honest boundary: no workflow currently runs runner.sh over the corpus (build-winuxcmd.yml is MSVC build + ctest; gnu-master-differential.yml covers master-cases only), so the first true two-sided run happens on a Windows/WSL runner pass. The four KNOWN_DIFF registrations below are mechanism-certain predictions from GNU probes + source reading, recorded exactly via the repo's whitelist/baseline mechanism.

Known divergences recorded (not fixed here)

  1. sdiff -o exit status (real bug): GNU exits 1 after a completed -o merge of differing files; WinuxCmd's -o path returns 0 unconditionally, and the unit test sdiff_output_file_auto_merges_non_interactively pins 0 under a comment claiming GNU parity — GNU 3.10 contradicts it. Cases 18/19 whitelisted (behavior:); merged-file bytes agree.
  2. sdiff -o interactivity (by design): issue 📋 后续工作计划:diff3/sdiff 对齐、help 覆盖修复、测试框架、性能轮 #1127 P1 itself specified non-interactive auto-merge; GNU prompts (%) and reads stdin (EOF → exit 2, truncated output file). Same family as the pre-existing regressions/30-sdiff-output-file.case whitelist entry.
  3. sdiff -B display: GNU keeps ignored blank-line hunks in the display as )-gutter artifact rows with shifted pairing; WinuxCmd drops ignored hunks before display. Case 11 whitelisted (behavior:); the -B -s face (case 10) agrees.
  4. sdiff --strip-trailing-cr display: GNU strips CR on input (display is CR-free); WinuxCmd strips CR for comparison only and displays the right file's original CR-carrying lines → CRLF-only display difference. Case 15 whitelisted (format:); exit statuses agree.

Positive note: GNU -X never emits bracket markers on any probed conflict shape (output ≡ -x, exit 0), and WinuxCmd's wiring (overlap-only without the flagging mode) matches — case 15 pins this.

diff3 had no differential corpus (EXEMPT.md 'Not yet covered', absent
from baseline.json); sdiff had exactly one case. Add 26 diff3 cases
covering the full implemented option surface (-A/-E/-3/-x/-X/-e/-i/-m/
-T/-L x3/--diff-program/--strip-trailing-cr plus the base 3-file
shapes) and 19 sdiff cases (-l/-s/-w/-i/-b/-W/-B/-I/-t/-E/--strip-
trailing-cr/-d/-a and -o auto-merge outcomes).

Expected behavior is GNU diffutils 3.10 (local oracle, matching the
repo's pinned expectation); every case was dry-run against the oracle
and smoke-tested through runner.sh (GNU-vs-GNU, all PASS).

Four sdiff cases are registered KNOWN_DIFF with whitelist entries for
mechanism-certain display/status divergences (GNU -B display
artifacts, CR-in-display under --strip-trailing-cr, and the -o
prompt/exit-status face of the by-design non-interactive auto-merge);
the merged-file bytes of the -o cases agree with GNU given the
scripted stdin choices. diff3 leaves EXEMPT.md.
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 29, 2026 19:16
@caomengxuan666
caomengxuan666 merged commit 18fd752 into main Oct 29, 2026
8 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 29, 2026
…hed literally, not as a regex

The recorded PASS for corpus/sdiff/12-ignore-matching-lines came
from #1440's GNU-vs-GNU validation; the first true two-sided runs
(the two byte-identical result sets harvested in wave-1d) show
the subject's exit code differing from GNU's, deterministically.

Case: f1 = keep/skip-1/end, f2 = keep/skip-2/end, run as
`sdiff -I ^skip- f1.txt f2.txt`. GNU diffutils 3.10 exits 0: the
regular expression ^skip- matches both changed lines, so the
only change is ignored and the pair displays as a common row.
The applet exits 1. Mechanism: the hunk-drop predicate
diff_engine::make_blank_or_matching_predicate
(src/commands/diff_engine.h) tests each changed line with
std::string::find - a literal substring search - so the needle
"^skip-", caret included, never occurs in "skip-1"/"skip-2";
drop_ignored_hunks keeps the DEL/INS hunk and the exit branch
in src/commands/sdiff.cpp sees a non-KEEP edit. GNU's -I takes a
regular expression; any RE metacharacter (^, ., [...], ...)
fails the same way, while plain substring patterns accidentally
work. The same predicate backs diff -I (src/commands/diff.cpp),
so the defect is shared there.

This is a product bug, filed as a finding with a minimal
reproducer in the wave-1e report for the main session to open
an issue from; the applet is deliberately not fixed in this PR.
It is a sibling of the -o exit-status bug (#1441), not the same
mechanism: that one is the -o path's unconditional return 0,
this one is the display path's literal-match predicate.

Recording the observed bucket keeps the gate honest without
hiding anything: runner.sh still fails this case on every run
until the applet is fixed. Same treatment wave-1b applied to
cmp/14.

Refs #1127
@caomengxuan666
caomengxuan666 deleted the corpus/diff3-sdiff-1127 branch October 30, 2026 01:42
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.

1 participant