From 22770e23819ff00166d90a2ff1907f528a262adb Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Thu, 8 Dec 2022 12:20:43 +0900 Subject: [PATCH] buildRustCrate: fixup integration test mod name Fixes #204051. I have tried this on the reproducer stated in the ticket. ``` [nix-develop]$ $(nix-build -I nixpkgs=/home/shana/programming/nixpkgs --no-out-link)/tests/foo running 1 test test check_module_name ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ``` --- pkgs/build-support/rust/build-rust-crate/lib.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkgs/build-support/rust/build-rust-crate/lib.sh b/pkgs/build-support/rust/build-rust-crate/lib.sh index 7f98701b5409..0181ae432c85 100644 --- a/pkgs/build-support/rust/build-rust-crate/lib.sh +++ b/pkgs/build-support/rust/build-rust-crate/lib.sh @@ -78,6 +78,10 @@ build_bin_test() { build_bin_test_file() { local file="$1" local derived_crate_name="${file//\//_}" + # Make sure to strip the top level `tests` directory: see #204051. Note that + # a forward slash has now become an underscore due to the substitution + # above. + derived_crate_name=${derived_crate_name#"tests_"} derived_crate_name="${derived_crate_name%.rs}" build_bin_test "$derived_crate_name" "$file" }