From a088f828dc4da911730d003a0248dc6a1ce9f5fc Mon Sep 17 00:00:00 2001 From: "Sergey \"Shnatsel\" Davidoff" Date: Sun, 18 Feb 2024 21:36:37 +0000 Subject: [PATCH] Use a separate project for the custom rustc path tests. Fixes intermittent test failures due to race conditions --- .../tests/fixtures/custom_rustc_path/Cargo.toml | 7 +++++++ .../build_dep_of_runtime_dep/Cargo.toml | 8 ++++++++ .../build_dep_of_runtime_dep/src/lib.rs | 8 ++++++++ .../fixtures/custom_rustc_path/runtime_dep/Cargo.toml | 9 +++++++++ .../fixtures/custom_rustc_path/runtime_dep/src/lib.rs | 8 ++++++++ .../custom_rustc_path/top_level_crate/Cargo.toml | 9 +++++++++ .../custom_rustc_path/top_level_crate/src/main.rs | 3 +++ cargo-auditable/tests/it.rs | 2 +- 8 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 cargo-auditable/tests/fixtures/custom_rustc_path/Cargo.toml create mode 100644 cargo-auditable/tests/fixtures/custom_rustc_path/build_dep_of_runtime_dep/Cargo.toml create mode 100644 cargo-auditable/tests/fixtures/custom_rustc_path/build_dep_of_runtime_dep/src/lib.rs create mode 100644 cargo-auditable/tests/fixtures/custom_rustc_path/runtime_dep/Cargo.toml create mode 100644 cargo-auditable/tests/fixtures/custom_rustc_path/runtime_dep/src/lib.rs create mode 100644 cargo-auditable/tests/fixtures/custom_rustc_path/top_level_crate/Cargo.toml create mode 100644 cargo-auditable/tests/fixtures/custom_rustc_path/top_level_crate/src/main.rs diff --git a/cargo-auditable/tests/fixtures/custom_rustc_path/Cargo.toml b/cargo-auditable/tests/fixtures/custom_rustc_path/Cargo.toml new file mode 100644 index 0000000..0cbde27 --- /dev/null +++ b/cargo-auditable/tests/fixtures/custom_rustc_path/Cargo.toml @@ -0,0 +1,7 @@ +[workspace] + +members = [ + "top_level_crate", + "runtime_dep", + "build_dep_of_runtime_dep", +] diff --git a/cargo-auditable/tests/fixtures/custom_rustc_path/build_dep_of_runtime_dep/Cargo.toml b/cargo-auditable/tests/fixtures/custom_rustc_path/build_dep_of_runtime_dep/Cargo.toml new file mode 100644 index 0000000..44d3020 --- /dev/null +++ b/cargo-auditable/tests/fixtures/custom_rustc_path/build_dep_of_runtime_dep/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "build_dep_of_runtime_dep" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/cargo-auditable/tests/fixtures/custom_rustc_path/build_dep_of_runtime_dep/src/lib.rs b/cargo-auditable/tests/fixtures/custom_rustc_path/build_dep_of_runtime_dep/src/lib.rs new file mode 100644 index 0000000..1b4a90c --- /dev/null +++ b/cargo-auditable/tests/fixtures/custom_rustc_path/build_dep_of_runtime_dep/src/lib.rs @@ -0,0 +1,8 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + let result = 2 + 2; + assert_eq!(result, 4); + } +} diff --git a/cargo-auditable/tests/fixtures/custom_rustc_path/runtime_dep/Cargo.toml b/cargo-auditable/tests/fixtures/custom_rustc_path/runtime_dep/Cargo.toml new file mode 100644 index 0000000..f7d5453 --- /dev/null +++ b/cargo-auditable/tests/fixtures/custom_rustc_path/runtime_dep/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "runtime_dep" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[build-dependencies] +build_dep_of_runtime_dep = {path = "../build_dep_of_runtime_dep"} diff --git a/cargo-auditable/tests/fixtures/custom_rustc_path/runtime_dep/src/lib.rs b/cargo-auditable/tests/fixtures/custom_rustc_path/runtime_dep/src/lib.rs new file mode 100644 index 0000000..1b4a90c --- /dev/null +++ b/cargo-auditable/tests/fixtures/custom_rustc_path/runtime_dep/src/lib.rs @@ -0,0 +1,8 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + let result = 2 + 2; + assert_eq!(result, 4); + } +} diff --git a/cargo-auditable/tests/fixtures/custom_rustc_path/top_level_crate/Cargo.toml b/cargo-auditable/tests/fixtures/custom_rustc_path/top_level_crate/Cargo.toml new file mode 100644 index 0000000..58891a6 --- /dev/null +++ b/cargo-auditable/tests/fixtures/custom_rustc_path/top_level_crate/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "top_level_crate" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +runtime_dep = {path = "../runtime_dep"} diff --git a/cargo-auditable/tests/fixtures/custom_rustc_path/top_level_crate/src/main.rs b/cargo-auditable/tests/fixtures/custom_rustc_path/top_level_crate/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/cargo-auditable/tests/fixtures/custom_rustc_path/top_level_crate/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/cargo-auditable/tests/it.rs b/cargo-auditable/tests/it.rs index 2465bbf..f3ec822 100644 --- a/cargo-auditable/tests/it.rs +++ b/cargo-auditable/tests/it.rs @@ -366,7 +366,7 @@ fn test_runtime_then_build_dep() { fn test_custom_rustc_path() { // Path to workspace fixture Cargo.toml. See that file for overview of workspace members and their dependencies. let workspace_cargo_toml = PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("tests/fixtures/runtime_then_build_dep/Cargo.toml"); + .join("tests/fixtures/custom_rustc_path/Cargo.toml"); // locate rustc let rustc_path = which::which("rustc").unwrap(); // Run in workspace root with a custom path to rustc