From 5317a27244fc428335c4e7a1d066ae0f65f0d496 Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Mon, 25 Mar 2024 21:58:58 +0000 Subject: [PATCH 1/2] Fix tests on Rust 1.77 --- cargo-auditable/tests/it.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cargo-auditable/tests/it.rs b/cargo-auditable/tests/it.rs index 24e58e2..84231aa 100644 --- a/cargo-auditable/tests/it.rs +++ b/cargo-auditable/tests/it.rs @@ -110,11 +110,28 @@ where binaries }) .for_each(|(package, binary)| { - bins.entry(package).or_insert(Vec::new()).push(binary); + bins.entry(pkgid_to_bin_name(&package)) + .or_insert(Vec::new()) + .push(binary); }); bins } +fn pkgid_to_bin_name(pkgid: &str) -> String { + // the input is string in the format such as + // "path+file:///home/shnatsel/Code/cargo-auditable/cargo-auditable/tests/fixtures/lib_and_bin_crate#0.1.0" + // (for full docs see `cargo pkgid`) + // and we need just the crate name, e.g. "lib_and_bin_crate" + pkgid + .rsplit_once(std::path::MAIN_SEPARATOR) + .unwrap() + .1 + .split_once('#') + .unwrap() + .0 + .to_owned() +} + fn ensure_build_succeeded(output: &Output) { if !output.status.success() { let stderr = std::io::stderr(); From 2ac59f87d00e17a6e651268aa51e68e1c37a0edf Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Mon, 25 Mar 2024 22:02:20 +0000 Subject: [PATCH 2/2] Fix Windows --- cargo-auditable/tests/it.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cargo-auditable/tests/it.rs b/cargo-auditable/tests/it.rs index 84231aa..ea463a4 100644 --- a/cargo-auditable/tests/it.rs +++ b/cargo-auditable/tests/it.rs @@ -121,9 +121,10 @@ fn pkgid_to_bin_name(pkgid: &str) -> String { // the input is string in the format such as // "path+file:///home/shnatsel/Code/cargo-auditable/cargo-auditable/tests/fixtures/lib_and_bin_crate#0.1.0" // (for full docs see `cargo pkgid`) - // and we need just the crate name, e.g. "lib_and_bin_crate" + // and we need just the crate name, e.g. "lib_and_bin_crate". + // Weirdly it doesn't use OS path separator, it always uses '/' pkgid - .rsplit_once(std::path::MAIN_SEPARATOR) + .rsplit_once('/') .unwrap() .1 .split_once('#')