test(compat): add GNU patch compatibility tests#56
Merged
bmwill merged 5 commits intobmwill:masterfrom Apr 11, 2026
Merged
Conversation
70cbccf to
4587314
Compare
weihanglo
commented
Apr 10, 2026
| //! Compatibility tests against reference implementations. | ||
| //! | ||
| //! These tests verify diffy produces results compatible with established tools | ||
| //! Focus is on edge cases and ambiguous behavior, |
Contributor
Author
There was a problem hiding this comment.
Actually IMHO we should move most tests to compatible tests, if they are testing against some reference tool's behavior.
1a9aa29 to
872ac63
Compare
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.
Contributor
Author
|
Thanks for the cleanup and the review! |
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.
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=1and run the test.Please see the module level doc for more.