Skip to content

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

Open
weihanglo wants to merge 6 commits intobmwill:masterfrom
weihanglo:compat-test
Open

test(compat): add GNU patch compatibility tests#56
weihanglo wants to merge 6 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.

Preparation for multi-file patches support.
Preparation for multi-file patches support.
Rename patches module to patch_set and Patches struct to PatchSet.
Replace boundary pre-scan with single-pass parse_one.
Terminate iterator on parse error while allowing callers to continue.

bmwill#55 (comment)
bmwill#55 (comment)
bmwill#55 (comment)
bmwill#55 (comment)
We need to track lockfile
because we want to make sure our CI using rayon@1.10.0.
And I don't want to block whoever wants to use latest rayon to run tests.
(Though that doesn't matter as dependent won't respect our lockfile)

For other reasons, see

* <https://blog.rust-lang.org/2023/08/29/committing-lockfiles/>
* <https://doc.rust-lang.org/nightly/cargo/faq.html#why-have-cargolock-in-version-control>
* <https://doc.rust-lang.org/nightly/cargo/reference/rust-version.html>

Most importantly:

> Verifying a minimum-supported Rust version (MSRV)
> that is less than the latest version of a dependency supports

And actually during the course, I found that `windows-link` requires
Rust 1.71. `windows-link` is a transitive dependency of `anstyle`
through `windows-sys`.
Our MSRV is already a lie for windows user when enabling `color`.

``` console
$ cargo generate-lockfile --config 'resolver.incompatible-rust-versions="fallback"'
    Updating crates.io index
     Locking 24 packages to latest Rust 1.70.0 compatible versions
      Adding snapbox v0.6.24 (available: v1.1.0)
      Adding windows-link v0.2.1 (requires Rust 1.71)
```
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.
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