mirror of
https://github.com/uutils/diffutils.git
synced 2026-06-10 15:48:59 -07:00
1254f146f8f12adf1152dac2fdea6d8992f66163
macOS' /usr/bin/patch and GNU patch have very subtle incompatibilities that cause only some "more advanced" tests to fail in obscure and very time-consuming ways - while other tests pass. In some cases (depending on test threads racing), the lack of newlines in some test data even causes the whole test suite to stall. This fix runs `patch -version` (only once), makes sure the output starts with "GNU patch" and shows a meaningful assert message when not. It also looks for `gpatch` instead of `patch` on macOS and shows a meaningful assert message if either is missing. Fixes: #225 This also provides faster and better feedback when `ed` is missing (see #39) and implements a portable and basic check. Last but not least, this new code is generic enough to support the validation of any other test dependency in the future.
The goal of this package is to be a drop-in replacement for the diffutils commands (diff, cmp, diff3, sdiff) in Rust.
Based on the incomplete diff generator in https://github.com/rust-lang/rust/blob/master/src/tools/compiletest/src/runtest.rs, and made to be compatible with GNU's diff and patch tools.
Installation
Ensure you have Rust installed on your system. You can install Rust through rustup.
Clone the repository and build the project using Cargo:
git clone https://github.com/uutils/diffutils.git
cd diffutils
cargo build --release
Example
cat <<EOF >fruits_old.txt
Apple
Banana
Cherry
EOF
cat <<EOF >fruits_new.txt
Apple
Fig
Cherry
EOF
$ cargo run -- -u fruits_old.txt fruits_new.txt
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `target/debug/diffutils -u fruits_old.txt fruits_new.txt`
--- fruits_old.txt
+++ fruits_new.txt
@@ -1,3 +1,3 @@
Apple
-Banana
+Fig
Cherry
License
This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.
Description
Languages
Rust
96.3%
Shell
1.9%
Python
1.8%