Repository navigation
WIP: test(corpus): diff3 golden corpus + sdiff expansion for #1127 P1 - #1440
Merged
Merged
Conversation
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
marked this pull request as ready for review
October 29, 2026 19:16
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
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.
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
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.-l,-s,-w,-i,-b,-W/--ignore-all-space,-B(both the-sface and the display face),-I,-t,-E(--ignore-tab-expansion),--strip-trailing-cr,-d,-a, and-oauto-merge outcomes (scripted-stdin equivalence + the identical-input case).baseline.jsonentries (purely additive), 4whitelist.txtentries, and diff3 removed from EXEMPT.md (72/169 commands now differentially tested). Nomaster-cases.jsonentries: that mechanism is coreutils-stdin-only (master-oracle.pybuilds GNU coreutils master; diffutils cases would fail there).Oracle & verification
diff3 --version/sdiff --version), matching the repo's pinned expectation. Expected behavior is always GNU's; no applet code is touched.runner.shitself (GNU-vs-GNU): diff3 26/26 PASS, sdiff 21/21 PASS (incl. the pre-existing regression case).runner.shover 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)
sdiff -oexit status (real bug): GNU exits 1 after a completed-omerge of differing files; WinuxCmd's-opath returns 0 unconditionally, and the unit testsdiff_output_file_auto_merges_non_interactivelypins 0 under a comment claiming GNU parity — GNU 3.10 contradicts it. Cases 18/19 whitelisted (behavior:); merged-file bytes agree.sdiff -ointeractivity (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-existingregressions/30-sdiff-output-file.casewhitelist entry.sdiff -Bdisplay: 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 -sface (case 10) agrees.sdiff --strip-trailing-crdisplay: 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
-Xnever 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.