about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2022-12-08 12:20:43 +0900
committerWinter <winter@winter.cafe>2023-01-14 14:18:09 -0500
commit22770e23819ff00166d90a2ff1907f528a262adb (patch)
tree1d6c779e21fbeb1cb9cc9b38cfcfce8538678d06 /pkgs/build-support
parent5fb9ccbd5bf373994d1e0bc45e0e0cfae27465bf (diff)
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
```
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/rust/build-rust-crate/lib.sh4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkgs/build-support/rust/build-rust-crate/lib.sh b/pkgs/build-support/rust/build-rust-crate/lib.sh
index 7f98701b5409c..0181ae432c85b 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"
 }