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
```
This commit is contained in:
Mateusz Kowalczyk 2022-12-08 12:20:43 +09:00 committed by Winter
parent 5fb9ccbd5b
commit 22770e2381

View File

@ -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"
}