buildRustPackage: Add cargoTestFlags

This makes it possible to pass flags to `cargo test`, which is needed if
a crate is compiled with custom feature flags.
This commit is contained in:
Max Hausch 2021-02-24 09:32:22 +01:00
parent fa62f37160
commit ebe3ae4d4d
No known key found for this signature in database
GPG Key ID: 087D299FD45B9ED0
2 changed files with 9 additions and 1 deletions

View File

@ -193,6 +193,13 @@ rustPlatform.buildRustPackage {
Please note that the code will be compiled twice here: once in `release` mode
for the `buildPhase`, and again in `debug` mode for the `checkPhase`.
Test flags, e.g., `--features xxx/yyy`, can be passed to `cargo test` via the
`cargoTestFlags` attribute.
Another attribute, called `checkFlags`, is used to pass arguments to the test
binary itself, as stated
(here)[https://doc.rust-lang.org/cargo/commands/cargo-test.html].
#### Tests relying on the structure of the `target/` directory
Some tests may rely on the structure of the `target/` directory. Those tests

View File

@ -1,4 +1,5 @@
declare -a checkFlags
declare -a cargoTestFlags
cargoCheckHook() {
echo "Executing cargoCheckHook"
@ -15,7 +16,7 @@ cargoCheckHook() {
threads=1
fi
argstr="--${cargoCheckType} --target @rustTargetPlatformSpec@ --frozen";
argstr="--${cargoCheckType} --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}";
(
set -x