Skip to content

test(compat): add GNU patch compatibility tests#56

Merged
bmwill merged 5 commits intobmwill:masterfrom
weihanglo:compat-test
Apr 11, 2026
Merged

test(compat): add GNU patch compatibility tests#56
bmwill merged 5 commits intobmwill:masterfrom
weihanglo:compat-test

Conversation

@weihanglo
Copy link
Copy Markdown
Contributor

@weihanglo weihanglo commented Apr 10, 2026

Blocked on #55. Please review from 4587314

Tests verify diffy produces results compatible with reference tools.
Here we have GNU patch. In the future we'll have git apply.

We don't run reference tool locally, as user may not have the tool.
To run it, set env CI=1 and run the test.

Please see the module level doc for more.

@weihanglo weihanglo force-pushed the compat-test branch 3 times, most recently from 70cbccf to 4587314 Compare April 10, 2026 05:39
//! Compatibility tests against reference implementations.
//!
//! These tests verify diffy produces results compatible with established tools
//! Focus is on edge cases and ambiguous behavior,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually IMHO we should move most tests to compatible tests, if they are testing against some reference tool's behavior.

@weihanglo weihanglo force-pushed the compat-test branch 2 times, most recently from 1a9aa29 to 872ac63 Compare April 11, 2026 00:18
weihanglo and others added 4 commits April 11, 2026 09:22
Tests verify diffy produces results compatible with reference tools.
Here we have GNU patch. In the future we'll have `git apply`.

We don't run reference tool locally, as user may not have the tool.
To run it, set `env CI=1` and run the test.

Please see the module level doc for more.
The comment claimed diffy "currently misparsed" `\033` in quoted filename
headers, but the test runs unconditionally and passes — diffy already
decodes 3-digit octal escapes correctly. Replace the stale note with a
one-liner confirming the behavior.
junk_between_hunks was placed under the `// Failure cases` divider, but
its doc comment and assertions both document a success: diffy matches
GNU patch by applying the first hunk and ignoring trailing junk. Move
it up alongside the other success cases so the section dividers stay
meaningful.
Previously, `apply_diffy` used `unwrap_or_default()` when reading the
original file for `Modify`, `Delete`, `Rename`, and `Copy` operations.
A missing or unreadable fixture would silently substitute an empty
string, so a broken test fixture could still produce a "successful"
apply against nothing and mask the bug.

Replace the fallback with a panic that names the path, so fixture
problems surface as test failures instead of silent wrong answers.
The `Create` branch already takes the `None` arm and is unaffected.
@bmwill bmwill merged commit ff6dc8b into bmwill:master Apr 11, 2026
8 checks passed
@weihanglo
Copy link
Copy Markdown
Contributor Author

Thanks for the cleanup and the review!

@weihanglo weihanglo deleted the compat-test branch April 11, 2026 15:16
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