From df778c610b62e693ba4cc4923c2d280db5a97781 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 29 Apr 2024 22:55:08 +0200 Subject: [PATCH 01/20] CI: install GNU patch on MacOS (fixes #66) --- .github/workflows/ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be76d96..ddf2ea1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,9 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable + - name: install GNU patch on MacOS + if: runner.os == 'macOS' + run: brew install gpatch - name: set up PATH on Windows # Needed to use GNU's patch.exe instead of Strawberry Perl patch if: runner.os == 'Windows' @@ -107,6 +110,9 @@ jobs: - name: rust toolchain ~ install uses: dtolnay/rust-toolchain@nightly + - name: install GNU patch on MacOS + if: runner.os == 'macOS' + run: brew install gpatch - name: set up PATH on Windows # Needed to use GNU's patch.exe instead of Strawberry Perl patch if: runner.os == 'Windows' From bf9147733debef0a5caa5930401430290786e8e6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 30 Apr 2024 05:30:32 +0000 Subject: [PATCH 02/20] Update Rust crate unicode-width to 0.1.12 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2244a3b..44d6b6c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -409,9 +409,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85" +checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" [[package]] name = "wait-timeout" diff --git a/Cargo.toml b/Cargo.toml index f219dbb..94a585e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ chrono = "0.4.38" diff = "0.1.13" regex = "1.10.4" same-file = "1.0.6" -unicode-width = "0.1.11" +unicode-width = "0.1.12" [dev-dependencies] pretty_assertions = "1" From 713bd210ab0a84a8223e4f310dc6622385bec7ed Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 30 Apr 2024 23:55:49 +0200 Subject: [PATCH 03/20] CI: Update 'cargo dist' to version 0.13.3 --- .github/workflows/release.yml | 31 ++++++++++++++++++------------- Cargo.toml | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 502a5ff..4c1f4f8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -# Copyright 2022-2023, axodotdev +# Copyright 2022-2024, axodotdev # SPDX-License-Identifier: MIT or Apache-2.0 # # CI that: @@ -6,9 +6,9 @@ # * checks for a Git Tag that looks like a release # * builds artifacts with cargo-dist (archives, installers, hashes) # * uploads those artifacts to temporary workflow zip -# * on success, uploads the artifacts to a Github Release +# * on success, uploads the artifacts to a GitHub Release # -# Note that the Github Release will be created with a generated +# Note that the GitHub Release will be created with a generated # title/body based on your changelogs. name: Release @@ -31,7 +31,7 @@ permissions: # packages versioned/released in lockstep). # # If you push multiple tags at once, separate instances of this workflow will -# spin up, creating an independent announcement for each one. However Github +# spin up, creating an independent announcement for each one. However, GitHub # will hard limit this to 3 tags per commit, as it will assume more tags is a # mistake. # @@ -62,7 +62,7 @@ jobs: # we specify bash to get pipefail; it guards against the `curl` command # failing. otherwise `sh` won't catch that `curl` returned non-0 shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh" # sure would be cool if github gave us proper conditionals... # so here's a doubly-nested ternary-via-truthiness to try to provide the best possible # functionality based on whether this is a pull_request, and whether it's from a fork. @@ -105,10 +105,15 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} BUILD_MANIFEST_NAME: target/distrib/${{ join(matrix.targets, '-') }}-dist-manifest.json steps: + - name: enable windows longpaths + run: | + git config --global core.longpaths true - uses: actions/checkout@v4 with: submodules: recursive - uses: swatinem/rust-cache@v2 + with: + key: ${{ join(matrix.targets, '-') }} - name: Install cargo-dist run: ${{ matrix.install_dist }} # Get the dist-manifest @@ -135,7 +140,7 @@ jobs: run: | # Parse out what we just built and upload it to scratch storage echo "paths<> "$GITHUB_OUTPUT" - jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" cp dist-manifest.json "$BUILD_MANIFEST_NAME" @@ -162,7 +167,7 @@ jobs: submodules: recursive - name: Install cargo-dist shell: bash - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh" # Get all the local artifacts for the global tasks to use (for e.g. checksums) - name: Fetch local artifacts uses: actions/download-artifact@v4 @@ -178,7 +183,7 @@ jobs: # Parse out what we just built and upload it to scratch storage echo "paths<> "$GITHUB_OUTPUT" - jq --raw-output ".artifacts[]?.path | select( . != null )" dist-manifest.json >> "$GITHUB_OUTPUT" + jq --raw-output ".upload_files[]" dist-manifest.json >> "$GITHUB_OUTPUT" echo "EOF" >> "$GITHUB_OUTPUT" cp dist-manifest.json "$BUILD_MANIFEST_NAME" @@ -207,7 +212,7 @@ jobs: with: submodules: recursive - name: Install cargo-dist - run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.12.0/cargo-dist-installer.sh | sh" + run: "curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.13.3/cargo-dist-installer.sh | sh" # Fetch artifacts from scratch-storage - name: Fetch artifacts uses: actions/download-artifact@v4 @@ -215,7 +220,7 @@ jobs: pattern: artifacts-* path: target/distrib/ merge-multiple: true - # This is a harmless no-op for Github Releases, hosting for that happens in "announce" + # This is a harmless no-op for GitHub Releases, hosting for that happens in "announce" - id: host shell: bash run: | @@ -230,7 +235,7 @@ jobs: name: artifacts-dist-manifest path: dist-manifest.json - # Create a Github Release while uploading all files to it + # Create a GitHub Release while uploading all files to it announce: needs: - plan @@ -246,7 +251,7 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - - name: "Download Github Artifacts" + - name: "Download GitHub Artifacts" uses: actions/download-artifact@v4 with: pattern: artifacts-* @@ -256,7 +261,7 @@ jobs: run: | # Remove the granular manifests rm -f artifacts/*-dist-manifest.json - - name: Create Github Release + - name: Create GitHub Release uses: ncipollo/release-action@v1 with: tag: ${{ needs.plan.outputs.tag }} diff --git a/Cargo.toml b/Cargo.toml index 94a585e..b5c638a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ lto = "thin" # Config for 'cargo dist' [workspace.metadata.dist] # The preferred cargo-dist version to use in CI (Cargo.toml SemVer syntax) -cargo-dist-version = "0.12.0" +cargo-dist-version = "0.13.3" # CI backends to support ci = ["github"] # The installers to generate for each app From 767c6f6c4a712f25df3f14ba5538755a8fc81254 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 09:56:50 +0000 Subject: [PATCH 04/20] Update Rust crate libfuzzer-sys to 0.4.7 --- fuzz/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 650e1d4..5debf47 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" cargo-fuzz = true [dependencies] -libfuzzer-sys = "0.4" +libfuzzer-sys = "0.4.7" diffutils = { path = "../" } # Prevent this from interfering with workspaces From 4b70969ff18ad1cb2c290ecdfa977e0937618d54 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 1 May 2024 09:56:55 +0000 Subject: [PATCH 05/20] Update Rust crate pretty_assertions to 1.4.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index b5c638a..4963f29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ same-file = "1.0.6" unicode-width = "0.1.12" [dev-dependencies] -pretty_assertions = "1" +pretty_assertions = "1.4.0" assert_cmd = "2.0.14" predicates = "3.1.0" tempfile = "3.10.1" From 80b993141b377c8651bbb71c8ceee93518855d45 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 19 May 2024 11:59:26 +0200 Subject: [PATCH 06/20] cargo-dist: generate more targets --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4963f29..7a412e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,6 @@ ci = ["github"] # The installers to generate for each app installers = [] # Target platforms to build apps for (Rust target-triple syntax) -targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"] +targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] # Publish jobs to run in CI pr-run-mode = "plan" From d362046ae5f54d78e4a6812d6acae5099f2f99b2 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 19 May 2024 19:09:05 +0200 Subject: [PATCH 07/20] release v0.4.2 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 44d6b6c..64de5f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -122,7 +122,7 @@ checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" [[package]] name = "diffutils" -version = "0.4.1" +version = "0.4.2" dependencies = [ "assert_cmd", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 7a412e6..fa80fc6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "diffutils" -version = "0.4.1" +version = "0.4.2" edition = "2021" description = "A CLI app for generating diff files" license = "MIT OR Apache-2.0" From fa4e0c6097a9ddc1a63f35865781b9c25ad20e1b Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 23 Apr 2024 20:02:34 +0200 Subject: [PATCH 08/20] Make error message consistent with GNU diff's implementation when failing to read input file(s) --- src/main.rs | 33 ++++++++++++++++++++++---- src/params.rs | 55 +++++++++++++++++++++++++++++++++++++++----- tests/integration.rs | 21 ++++++++++++----- 3 files changed, 93 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index f1bd1e2..7e221ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ // files that was distributed with this source code. use crate::params::{parse_params, Format}; +use regex::Regex; use std::env; use std::ffi::OsString; use std::fs; @@ -18,6 +19,22 @@ mod params; mod unified_diff; mod utils; +fn report_failure_to_read_input_file( + executable: &OsString, + filepath: &OsString, + error: &std::io::Error, +) { + // std::io::Error's display trait outputs "{detail} (os error {code})" + // but we want only the {detail} (error string) part + let error_code_re = Regex::new(r"\ \(os\ error\ \d+\)$").unwrap(); + eprintln!( + "{}: {}: {}", + executable.to_string_lossy(), + filepath.to_string_lossy(), + error_code_re.replace(error.to_string().as_str(), ""), + ); +} + // Exit codes are documented at // https://www.gnu.org/software/diffutils/manual/html_node/Invoking-diff.html. // An exit status of 0 means no differences were found, @@ -45,6 +62,7 @@ fn main() -> ExitCode { maybe_report_identical_files(); return ExitCode::SUCCESS; } + // read files fn read_file_contents(filepath: &OsString) -> io::Result> { if filepath == "-" { @@ -54,20 +72,27 @@ fn main() -> ExitCode { fs::read(filepath) } } + let mut io_error = false; let from_content = match read_file_contents(¶ms.from) { Ok(from_content) => from_content, Err(e) => { - eprintln!("Failed to read from-file: {e}"); - return ExitCode::from(2); + report_failure_to_read_input_file(¶ms.executable, ¶ms.from, &e); + io_error = true; + vec![] } }; let to_content = match read_file_contents(¶ms.to) { Ok(to_content) => to_content, Err(e) => { - eprintln!("Failed to read to-file: {e}"); - return ExitCode::from(2); + report_failure_to_read_input_file(¶ms.executable, ¶ms.to, &e); + io_error = true; + vec![] } }; + if io_error { + return ExitCode::from(2); + } + // run diff let result: Vec = match params.format { Format::Normal => normal_diff::diff(&from_content, &to_content, ¶ms), diff --git a/src/params.rs b/src/params.rs index 62ee518..c671180 100644 --- a/src/params.rs +++ b/src/params.rs @@ -14,6 +14,7 @@ pub enum Format { #[derive(Clone, Debug, Eq, PartialEq)] pub struct Params { + pub executable: OsString, pub from: OsString, pub to: OsString, pub format: Format, @@ -27,6 +28,7 @@ pub struct Params { impl Default for Params { fn default() -> Self { Self { + executable: OsString::default(), from: OsString::default(), to: OsString::default(), format: Format::default(), @@ -43,10 +45,13 @@ pub fn parse_params>(opts: I) -> Result ".to_string()); }; - let mut params = Params::default(); + let mut params = Params { + executable, + ..Default::default() + }; let mut from = None; let mut to = None; let mut format = None; @@ -63,7 +68,10 @@ pub fn parse_params>(opts: I) -> Result ", exe.to_string_lossy())); + return Err(format!( + "Usage: {} ", + params.executable.to_string_lossy() + )); } continue; } @@ -155,7 +163,10 @@ pub fn parse_params>(opts: I) -> Result ", exe.to_string_lossy())); + return Err(format!( + "Usage: {} ", + params.executable.to_string_lossy() + )); } } params.from = if let Some(from) = from { @@ -163,14 +174,20 @@ pub fn parse_params>(opts: I) -> Result ", exe.to_string_lossy())); + return Err(format!( + "Usage: {} ", + params.executable.to_string_lossy() + )); }; params.to = if let Some(to) = to { to } else if let Some(param) = opts.next() { param } else { - return Err(format!("Usage: {} ", exe.to_string_lossy())); + return Err(format!( + "Usage: {} ", + params.executable.to_string_lossy() + )); }; // diff DIRECTORY FILE => diff DIRECTORY/FILE FILE @@ -301,6 +318,7 @@ mod tests { fn basics() { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), ..Default::default() @@ -309,6 +327,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), ..Default::default() @@ -325,6 +344,7 @@ mod tests { for arg in ["-e", "--ed"] { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Ed, @@ -342,6 +362,7 @@ mod tests { params.extend(["foo", "bar"]); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Context, @@ -362,6 +383,7 @@ mod tests { params.extend(["foo", "bar"]); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Context, @@ -399,6 +421,7 @@ mod tests { params.extend(["foo", "bar"]); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Unified, @@ -419,6 +442,7 @@ mod tests { params.extend(["foo", "bar"]); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Unified, @@ -452,6 +476,7 @@ mod tests { fn context_count() { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Unified, @@ -466,6 +491,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Unified, @@ -480,6 +506,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Unified, @@ -494,6 +521,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), format: Format::Context, @@ -511,6 +539,7 @@ mod tests { fn report_identical_files() { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), ..Default::default() @@ -519,6 +548,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), report_identical_files: true, @@ -528,6 +558,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), report_identical_files: true, @@ -549,6 +580,7 @@ mod tests { fn brief() { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), ..Default::default() @@ -557,6 +589,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), brief: true, @@ -566,6 +599,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), brief: true, @@ -582,6 +616,7 @@ mod tests { fn expand_tabs() { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), ..Default::default() @@ -591,6 +626,7 @@ mod tests { for option in ["-t", "--expand-tabs"] { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), expand_tabs: true, @@ -608,6 +644,7 @@ mod tests { fn tabsize() { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), ..Default::default() @@ -616,6 +653,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), tabsize: 0, @@ -629,6 +667,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("bar"), tabsize: 42, @@ -686,6 +725,7 @@ mod tests { fn double_dash() { assert_eq!( Ok(Params { + executable: os("diff"), from: os("-g"), to: os("-h"), ..Default::default() @@ -697,6 +737,7 @@ mod tests { fn default_to_stdin() { assert_eq!( Ok(Params { + executable: os("diff"), from: os("foo"), to: os("-"), ..Default::default() @@ -705,6 +746,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("-"), to: os("bar"), ..Default::default() @@ -713,6 +755,7 @@ mod tests { ); assert_eq!( Ok(Params { + executable: os("diff"), from: os("-"), to: os("-"), ..Default::default() diff --git a/tests/integration.rs b/tests/integration.rs index 9d0cfaf..ee8f15c 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -36,21 +36,30 @@ fn cannot_read_files() -> Result<(), Box> { cmd.assert() .code(predicate::eq(2)) .failure() - .stderr(predicate::str::starts_with("Failed to read from-file")); + .stderr(predicate::str::ends_with(format!( + ": {}: No such file or directory\n", + &nopath.as_os_str().to_string_lossy() + ))); let mut cmd = Command::cargo_bin("diffutils")?; cmd.arg(file.path()).arg(&nopath); cmd.assert() .code(predicate::eq(2)) .failure() - .stderr(predicate::str::starts_with("Failed to read to-file")); + .stderr(predicate::str::ends_with(format!( + ": {}: No such file or directory\n", + &nopath.as_os_str().to_string_lossy() + ))); let mut cmd = Command::cargo_bin("diffutils")?; cmd.arg(&nopath).arg(&nopath); - cmd.assert() - .code(predicate::eq(2)) - .failure() - .stderr(predicate::str::starts_with("Failed to read from-file")); + cmd.assert().code(predicate::eq(2)).failure().stderr( + predicate::str::contains(format!( + ": {}: No such file or directory\n", + &nopath.as_os_str().to_string_lossy() + )) + .count(2), + ); Ok(()) } From 8a3a977d2caae6002f945915d48165ec3534184a Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Tue, 23 Apr 2024 22:29:02 +0200 Subject: [PATCH 09/20] Update the expected error message for Windows --- tests/integration.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/integration.rs b/tests/integration.rs index ee8f15c..f8ad515 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -31,13 +31,18 @@ fn cannot_read_files() -> Result<(), Box> { let nopath = nofile.into_temp_path(); std::fs::remove_file(&nopath)?; + #[cfg(not(windows))] + let error_message = "No such file or directory"; + #[cfg(windows)] + let error_message = "The system cannot find the file specified."; + let mut cmd = Command::cargo_bin("diffutils")?; cmd.arg(&nopath).arg(file.path()); cmd.assert() .code(predicate::eq(2)) .failure() .stderr(predicate::str::ends_with(format!( - ": {}: No such file or directory\n", + ": {}: {error_message}\n", &nopath.as_os_str().to_string_lossy() ))); @@ -47,7 +52,7 @@ fn cannot_read_files() -> Result<(), Box> { .code(predicate::eq(2)) .failure() .stderr(predicate::str::ends_with(format!( - ": {}: No such file or directory\n", + ": {}: {error_message}\n", &nopath.as_os_str().to_string_lossy() ))); @@ -55,7 +60,7 @@ fn cannot_read_files() -> Result<(), Box> { cmd.arg(&nopath).arg(&nopath); cmd.assert().code(predicate::eq(2)).failure().stderr( predicate::str::contains(format!( - ": {}: No such file or directory\n", + ": {}: {error_message}\n", &nopath.as_os_str().to_string_lossy() )) .count(2), From eee6f499209cba06255bcb589638dd553dd00ac9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 17:06:50 +0000 Subject: [PATCH 10/20] Update Rust crate unicode-width to v0.1.13 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64de5f1..fe430aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -409,9 +409,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "wait-timeout" From e98b5e179ed40c08f0228813d74562406cc55d6b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 9 Jun 2024 13:30:51 +0000 Subject: [PATCH 11/20] Update Rust crate regex to v1.10.5 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fe430aa..e0cc642 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,9 +303,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", From c9a756eb43c08f2e4f5f6aa297a0da3e6a26f75c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:28:54 +0000 Subject: [PATCH 12/20] Update Rust crate assert_cmd to v2.0.15 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0cc642..d8abd7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,9 +34,9 @@ checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "assert_cmd" -version = "2.0.14" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed72493ac66d5804837f480ab3766c72bdfab91a65e565fc54fa9e42db0073a8" +checksum = "bc65048dd435533bb1baf2ed9956b9a278fbfdcf90301b39ee117f06c0199d37" dependencies = [ "anstyle", "bstr", From e9a814161884b987bd69ccea3f4e4769bd5fe8e8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:59:30 +0000 Subject: [PATCH 13/20] Update Rust crate predicates to v3.1.2 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0cc642..3763a14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -245,9 +245,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "predicates" -version = "3.1.0" +version = "3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b87bfd4605926cdfefc1c3b5f8fe560e3feca9d5552cf68c466d3d8236c7e8" +checksum = "7e9086cc7640c29a356d1a29fd134380bee9d8f79a17410aa76e7ad295f42c97" dependencies = [ "anstyle", "difflib", From e55ee893ddb86a6085ce0c5c8a258c31d493c1f3 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 16:27:14 +0000 Subject: [PATCH 14/20] Update Rust crate regex to v1.10.6 --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ba88a17..4875ac4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,9 +303,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", From eea6b62b20573d6b32c14498c43f062cb7a66cdd Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 22:18:35 +0000 Subject: [PATCH 15/20] Update Rust crate tempfile to v3.11.0 --- Cargo.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4875ac4..2f3062a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -385,12 +385,13 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.10.1" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", "windows-sys", ] From 67ef43083aa12a0978017dc810674a1220e4170a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 6 Aug 2024 23:23:06 +0000 Subject: [PATCH 16/20] Update Rust crate tempfile to v3.12.0 --- Cargo.lock | 58 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2f3062a..0fda722 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -148,7 +148,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -340,7 +340,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -385,15 +385,15 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.11.0" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fcd239983515c23a32fb82099f97d0b11b8c72f654ed659363a95c3dad7a53" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", "once_cell", "rustix", - "windows-sys", + "windows-sys 0.59.0", ] [[package]] @@ -526,15 +526,25 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + [[package]] name = "windows-targets" -version = "0.52.2" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98532992affa02e52709d5b4d145a3668ae10d9081eea4a7f26f719a8476f71" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", "windows_i686_gnu", + "windows_i686_gnullvm", "windows_i686_msvc", "windows_x86_64_gnu", "windows_x86_64_gnullvm", @@ -543,45 +553,51 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7269c1442e75af9fa59290383f7665b828efc76c429cc0b7f2ecb33cf51ebae" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f70ab2cebf332b7ecbdd98900c2da5298a8c862472fb35c75fc297eabb9d89b8" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" -version = "0.52.1" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "679f235acf6b1639408c0f6db295697a19d103b0cdc88146aa1b992c580c647d" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" -version = "0.52.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3480ac194b55ae274a7e135c21645656825da4a7f5b6e9286291b2113c94a78b" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" -version = "0.52.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42c46bab241c121402d1cb47d028ea3680ee2f359dcc287482dcf7fdddc73363" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc885a4332ee1afb9a1bacf11514801011725570d35675abc229ce7e3afe4d20" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" -version = "0.52.1" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e440c60457f84b0bee09208e62acc7ade264b38c4453f6312b8c9ab1613e73c" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "yansi" From 12b205e655f47b766e9c89ed17a7afc78566f2e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 03:18:54 +0000 Subject: [PATCH 17/20] Update Rust crate assert_cmd to v2.0.16 --- Cargo.lock | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fda722..974fba9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -34,13 +34,14 @@ checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc" [[package]] name = "assert_cmd" -version = "2.0.15" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc65048dd435533bb1baf2ed9956b9a278fbfdcf90301b39ee117f06c0199d37" +checksum = "dc1835b7f27878de8525dc71410b5a31cdcc5f230aed5ba5df968e09c201b23d" dependencies = [ "anstyle", "bstr", "doc-comment", + "libc", "predicates", "predicates-core", "predicates-tree", From dbabf399d5632a9a34463b8a10bedf5c6cb14a39 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Sat, 6 Apr 2024 23:10:42 +0200 Subject: [PATCH 18/20] Use the instrumentation-based code coverage implementation --- .github/workflows/ci.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddf2ea1..6f0e5ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,6 +110,7 @@ jobs: - name: rust toolchain ~ install uses: dtolnay/rust-toolchain@nightly + - run: rustup component add llvm-tools-preview - name: install GNU patch on MacOS if: runner.os == 'macOS' run: brew install gpatch @@ -122,8 +123,9 @@ jobs: env: CARGO_INCREMENTAL: "0" RUSTC_WRAPPER: "" - RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" + RUSTFLAGS: "-Cinstrument-coverage -Zcoverage-options=branch -Ccodegen-units=1 -Copt-level=0 -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort" RUSTDOCFLAGS: "-Cpanic=abort" + LLVM_PROFILE_FILE: "diffutils-%p-%m.profraw" - name: "`grcov` ~ install" id: build_grcov shell: bash @@ -151,9 +153,9 @@ jobs: COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info" mkdir -p "${COVERAGE_REPORT_DIR}" # display coverage files - grcov . --output-type files --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | sort --unique + grcov . --output-type files --binary-path "${COVERAGE_REPORT_DIR}" | sort --unique # generate coverage report - grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "vendor/*" --ignore "/*" --ignore "[a-zA-Z]:/*" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" + grcov . --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --binary-path "${COVERAGE_REPORT_DIR}" --branch echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT - name: Upload coverage results (to Codecov.io) uses: codecov/codecov-action@v4 From 2a899a9fc70dec10a703e9001a2370319f3b82e2 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Fri, 6 Sep 2024 09:27:53 +0200 Subject: [PATCH 19/20] Fix clippy warnings in tests from needless_borrows_for_generic_args lint --- src/context_diff.rs | 40 ++++++++++++++++++------------------ src/ed_diff.rs | 36 ++++++++++++++++---------------- src/normal_diff.rs | 48 +++++++++++++++++++++---------------------- src/unified_diff.rs | 50 ++++++++++++++++++++++----------------------- 4 files changed, 87 insertions(+), 87 deletions(-) diff --git a/src/context_diff.rs b/src/context_diff.rs index e276ce5..873fc3d 100644 --- a/src/context_diff.rs +++ b/src/context_diff.rs @@ -439,26 +439,26 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/ab.diff")) + File::create(format!("{target}/ab.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alef")).unwrap(); + let mut fa = File::create(format!("{target}/alef")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/bet")).unwrap(); + let mut fb = File::create(format!("{target}/bet")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") .arg("--context") - .stdin(File::open(&format!("{target}/ab.diff")).unwrap()) + .stdin(File::open(format!("{target}/ab.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alef")).unwrap(); + let alef = fs::read(format!("{target}/alef")).unwrap(); assert_eq!(alef, bet); } } @@ -520,26 +520,26 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/ab_.diff")) + File::create(format!("{target}/ab_.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alef_")).unwrap(); + let mut fa = File::create(format!("{target}/alef_")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/bet_")).unwrap(); + let mut fb = File::create(format!("{target}/bet_")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") .arg("--context") - .stdin(File::open(&format!("{target}/ab_.diff")).unwrap()) + .stdin(File::open(format!("{target}/ab_.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alef_")).unwrap(); + let alef = fs::read(format!("{target}/alef_")).unwrap(); assert_eq!(alef, bet); } } @@ -604,26 +604,26 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/abx.diff")) + File::create(format!("{target}/abx.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alefx")).unwrap(); + let mut fa = File::create(format!("{target}/alefx")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/betx")).unwrap(); + let mut fb = File::create(format!("{target}/betx")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") .arg("--context") - .stdin(File::open(&format!("{target}/abx.diff")).unwrap()) + .stdin(File::open(format!("{target}/abx.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alefx")).unwrap(); + let alef = fs::read(format!("{target}/alefx")).unwrap(); assert_eq!(alef, bet); } } @@ -691,26 +691,26 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/abr.diff")) + File::create(format!("{target}/abr.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alefr")).unwrap(); + let mut fa = File::create(format!("{target}/alefr")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/betr")).unwrap(); + let mut fb = File::create(format!("{target}/betr")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") .arg("--context") - .stdin(File::open(&format!("{target}/abr.diff")).unwrap()) + .stdin(File::open(format!("{target}/abr.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alefr")).unwrap(); + let alef = fs::read(format!("{target}/alefr")).unwrap(); assert_eq!(alef, bet); } } diff --git a/src/ed_diff.rs b/src/ed_diff.rs index 304a26f..b8cdbc5 100644 --- a/src/ed_diff.rs +++ b/src/ed_diff.rs @@ -225,13 +225,13 @@ mod tests { // This test diff is intentionally reversed. // We want it to turn the alef into bet. let diff = diff_w(&alef, &bet, &format!("{target}/alef")).unwrap(); - File::create(&format!("{target}/ab.ed")) + File::create(format!("{target}/ab.ed")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alef")).unwrap(); + let mut fa = File::create(format!("{target}/alef")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/bet")).unwrap(); + let mut fb = File::create(format!("{target}/bet")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; @@ -239,14 +239,14 @@ mod tests { { use std::process::Command; let output = Command::new("ed") - .arg(&format!("{target}/alef")) - .stdin(File::open(&format!("{target}/ab.ed")).unwrap()) + .arg(format!("{target}/alef")) + .stdin(File::open(format!("{target}/ab.ed")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = std::fs::read(&format!("{target}/alef")).unwrap(); + let alef = std::fs::read(format!("{target}/alef")).unwrap(); assert_eq!(alef, bet); } } @@ -299,13 +299,13 @@ mod tests { // This test diff is intentionally reversed. // We want it to turn the alef into bet. let diff = diff_w(&alef, &bet, &format!("{target}/alef_")).unwrap(); - File::create(&format!("{target}/ab_.ed")) + File::create(format!("{target}/ab_.ed")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alef_")).unwrap(); + let mut fa = File::create(format!("{target}/alef_")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/bet_")).unwrap(); + let mut fb = File::create(format!("{target}/bet_")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; @@ -313,14 +313,14 @@ mod tests { { use std::process::Command; let output = Command::new("ed") - .arg(&format!("{target}/alef_")) - .stdin(File::open(&format!("{target}/ab_.ed")).unwrap()) + .arg(format!("{target}/alef_")) + .stdin(File::open(format!("{target}/ab_.ed")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = std::fs::read(&format!("{target}/alef_")).unwrap(); + let alef = std::fs::read(format!("{target}/alef_")).unwrap(); assert_eq!(alef, bet); } } @@ -379,13 +379,13 @@ mod tests { // This test diff is intentionally reversed. // We want it to turn the alef into bet. let diff = diff_w(&alef, &bet, &format!("{target}/alefr")).unwrap(); - File::create(&format!("{target}/abr.ed")) + File::create(format!("{target}/abr.ed")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alefr")).unwrap(); + let mut fa = File::create(format!("{target}/alefr")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/betr")).unwrap(); + let mut fb = File::create(format!("{target}/betr")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; @@ -393,14 +393,14 @@ mod tests { { use std::process::Command; let output = Command::new("ed") - .arg(&format!("{target}/alefr")) - .stdin(File::open(&format!("{target}/abr.ed")).unwrap()) + .arg(format!("{target}/alefr")) + .stdin(File::open(format!("{target}/abr.ed")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = std::fs::read(&format!("{target}/alefr")).unwrap(); + let alef = std::fs::read(format!("{target}/alefr")).unwrap(); assert_eq!(alef, bet); } } diff --git a/src/normal_diff.rs b/src/normal_diff.rs index d6f8297..002cd01 100644 --- a/src/normal_diff.rs +++ b/src/normal_diff.rs @@ -275,26 +275,26 @@ mod tests { // This test diff is intentionally reversed. // We want it to turn the alef into bet. let diff = diff(&alef, &bet, &Params::default()); - File::create(&format!("{target}/ab.diff")) + File::create(format!("{target}/ab.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alef")).unwrap(); + let mut fa = File::create(format!("{target}/alef")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/bet")).unwrap(); + let mut fb = File::create(format!("{target}/bet")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") - .arg(&format!("{target}/alef")) - .stdin(File::open(&format!("{target}/ab.diff")).unwrap()) + .arg(format!("{target}/alef")) + .stdin(File::open(format!("{target}/ab.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alef")).unwrap(); + let alef = fs::read(format!("{target}/alef")).unwrap(); assert_eq!(alef, bet); } } @@ -367,27 +367,27 @@ mod tests { // This test diff is intentionally reversed. // We want it to turn the alef into bet. let diff = diff(&alef, &bet, &Params::default()); - File::create(&format!("{target}/abn.diff")) + File::create(format!("{target}/abn.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alefn")).unwrap(); + let mut fa = File::create(format!("{target}/alefn")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/betn")).unwrap(); + let mut fb = File::create(format!("{target}/betn")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") .arg("--normal") - .arg(&format!("{target}/alefn")) - .stdin(File::open(&format!("{target}/abn.diff")).unwrap()) + .arg(format!("{target}/alefn")) + .stdin(File::open(format!("{target}/abn.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alefn")).unwrap(); + let alef = fs::read(format!("{target}/alefn")).unwrap(); assert_eq!(alef, bet); } } @@ -441,26 +441,26 @@ mod tests { // This test diff is intentionally reversed. // We want it to turn the alef into bet. let diff = diff(&alef, &bet, &Params::default()); - File::create(&format!("{target}/ab_.diff")) + File::create(format!("{target}/ab_.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alef_")).unwrap(); + let mut fa = File::create(format!("{target}/alef_")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/bet_")).unwrap(); + let mut fb = File::create(format!("{target}/bet_")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") - .arg(&format!("{target}/alef_")) - .stdin(File::open(&format!("{target}/ab_.diff")).unwrap()) + .arg(format!("{target}/alef_")) + .stdin(File::open(format!("{target}/ab_.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alef_")).unwrap(); + let alef = fs::read(format!("{target}/alef_")).unwrap(); assert_eq!(alef, bet); } } @@ -519,26 +519,26 @@ mod tests { // This test diff is intentionally reversed. // We want it to turn the alef into bet. let diff = diff(&alef, &bet, &Params::default()); - File::create(&format!("{target}/abr.diff")) + File::create(format!("{target}/abr.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alefr")).unwrap(); + let mut fa = File::create(format!("{target}/alefr")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/betr")).unwrap(); + let mut fb = File::create(format!("{target}/betr")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") - .arg(&format!("{target}/alefr")) - .stdin(File::open(&format!("{target}/abr.diff")).unwrap()) + .arg(format!("{target}/alefr")) + .stdin(File::open(format!("{target}/abr.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alefr")).unwrap(); + let alef = fs::read(format!("{target}/alefr")).unwrap(); assert_eq!(alef, bet); } } diff --git a/src/unified_diff.rs b/src/unified_diff.rs index 11299d7..0f504a8 100644 --- a/src/unified_diff.rs +++ b/src/unified_diff.rs @@ -466,13 +466,13 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/ab.diff")) + File::create(format!("{target}/ab.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alef")).unwrap(); + let mut fa = File::create(format!("{target}/alef")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/bet")).unwrap(); + let mut fb = File::create(format!("{target}/bet")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; @@ -494,13 +494,13 @@ mod tests { let output = Command::new("patch") .arg("-p0") - .stdin(File::open(&format!("{target}/ab.diff")).unwrap()) + .stdin(File::open(format!("{target}/ab.diff")).unwrap()) .output() .unwrap(); println!("{}", String::from_utf8_lossy(&output.stdout)); println!("{}", String::from_utf8_lossy(&output.stderr)); assert!(output.status.success(), "{output:?}"); - let alef = fs::read(&format!("{target}/alef")).unwrap(); + let alef = fs::read(format!("{target}/alef")).unwrap(); assert_eq!(alef, bet); } } @@ -582,25 +582,25 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/abn.diff")) + File::create(format!("{target}/abn.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alefn")).unwrap(); + let mut fa = File::create(format!("{target}/alefn")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/betn")).unwrap(); + let mut fb = File::create(format!("{target}/betn")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") - .stdin(File::open(&format!("{target}/abn.diff")).unwrap()) + .stdin(File::open(format!("{target}/abn.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alefn")).unwrap(); + let alef = fs::read(format!("{target}/alefn")).unwrap(); assert_eq!(alef, bet); } } @@ -678,25 +678,25 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/ab_.diff")) + File::create(format!("{target}/ab_.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alef_")).unwrap(); + let mut fa = File::create(format!("{target}/alef_")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/bet_")).unwrap(); + let mut fb = File::create(format!("{target}/bet_")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") - .stdin(File::open(&format!("{target}/ab_.diff")).unwrap()) + .stdin(File::open(format!("{target}/ab_.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alef_")).unwrap(); + let alef = fs::read(format!("{target}/alef_")).unwrap(); assert_eq!(alef, bet); } } @@ -759,25 +759,25 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/abx.diff")) + File::create(format!("{target}/abx.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alefx")).unwrap(); + let mut fa = File::create(format!("{target}/alefx")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/betx")).unwrap(); + let mut fb = File::create(format!("{target}/betx")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") - .stdin(File::open(&format!("{target}/abx.diff")).unwrap()) + .stdin(File::open(format!("{target}/abx.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alefx")).unwrap(); + let alef = fs::read(format!("{target}/alefx")).unwrap(); assert_eq!(alef, bet); } } @@ -845,25 +845,25 @@ mod tests { ..Default::default() }, ); - File::create(&format!("{target}/abr.diff")) + File::create(format!("{target}/abr.diff")) .unwrap() .write_all(&diff) .unwrap(); - let mut fa = File::create(&format!("{target}/alefr")).unwrap(); + let mut fa = File::create(format!("{target}/alefr")).unwrap(); fa.write_all(&alef[..]).unwrap(); - let mut fb = File::create(&format!("{target}/betr")).unwrap(); + let mut fb = File::create(format!("{target}/betr")).unwrap(); fb.write_all(&bet[..]).unwrap(); let _ = fa; let _ = fb; let output = Command::new("patch") .arg("-p0") - .stdin(File::open(&format!("{target}/abr.diff")).unwrap()) + .stdin(File::open(format!("{target}/abr.diff")).unwrap()) .output() .unwrap(); assert!(output.status.success(), "{output:?}"); //println!("{}", String::from_utf8_lossy(&output.stdout)); //println!("{}", String::from_utf8_lossy(&output.stderr)); - let alef = fs::read(&format!("{target}/alefr")).unwrap(); + let alef = fs::read(format!("{target}/alefr")).unwrap(); assert_eq!(alef, bet); } } From 9db1eab1d03c8941db94913e53c087de031793fd Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Thu, 12 Sep 2024 10:10:47 +0200 Subject: [PATCH 20/20] Revert "cargo-dist: generate more targets" This reverts commit 80b993141b377c8651bbb71c8ceee93518855d45. --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fa80fc6..761e703 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,6 @@ ci = ["github"] # The installers to generate for each app installers = [] # Target platforms to build apps for (Rust target-triple syntax) -targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-pc-windows-msvc"] +targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"] # Publish jobs to run in CI pr-run-mode = "plan"