Merge pull request #114819 from cheriimoya/staging
buildRustPackage: Add cargoTestFlags
This commit is contained in:
commit
f14c5a6d92
@ -72,8 +72,8 @@ For `cargoHash` you can use:
|
|||||||
Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html)
|
Per the instructions in the [Cargo Book](https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html)
|
||||||
best practices guide, Rust applications should always commit the `Cargo.lock`
|
best practices guide, Rust applications should always commit the `Cargo.lock`
|
||||||
file in git to ensure a reproducible build. However, a few packages do not, and
|
file in git to ensure a reproducible build. However, a few packages do not, and
|
||||||
Nix depends on this file, so if it missing you can use `cargoPatches` to apply
|
Nix depends on this file, so if it is missing you can use `cargoPatches` to
|
||||||
it in the `patchPhase`. Consider sending a PR upstream with a note to the
|
apply it in the `patchPhase`. Consider sending a PR upstream with a note to the
|
||||||
maintainer describing why it's important to include in the application.
|
maintainer describing why it's important to include in the application.
|
||||||
|
|
||||||
The fetcher will verify that the `Cargo.lock` file is in sync with the `src`
|
The fetcher will verify that the `Cargo.lock` file is in sync with the `src`
|
||||||
@ -146,6 +146,8 @@ where they are known to differ. But there are ways to customize the argument:
|
|||||||
rustc.platform = { foo = ""; bar = ""; };
|
rustc.platform = { foo = ""; bar = ""; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
will result in:
|
will result in:
|
||||||
```shell
|
```shell
|
||||||
--target /nix/store/asdfasdfsadf-thumb-crazy.json # contains {"foo":"","bar":""}
|
--target /nix/store/asdfasdfsadf-thumb-crazy.json # contains {"foo":"","bar":""}
|
||||||
@ -156,7 +158,7 @@ path) can be passed directly to `buildRustPackage`:
|
|||||||
|
|
||||||
```nix
|
```nix
|
||||||
pkgs.rustPlatform.buildRustPackage {
|
pkgs.rustPlatform.buildRustPackage {
|
||||||
(...)
|
/* ... */
|
||||||
target = "x86_64-fortanix-unknown-sgx";
|
target = "x86_64-fortanix-unknown-sgx";
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -191,6 +193,13 @@ rustPlatform.buildRustPackage {
|
|||||||
Please note that the code will be compiled twice here: once in `release` mode
|
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`.
|
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
|
#### Tests relying on the structure of the `target/` directory
|
||||||
|
|
||||||
Some tests may rely on the structure of the `target/` directory. Those tests
|
Some tests may rely on the structure of the `target/` directory. Those tests
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
declare -a checkFlags
|
declare -a checkFlags
|
||||||
|
declare -a cargoTestFlags
|
||||||
|
|
||||||
cargoCheckHook() {
|
cargoCheckHook() {
|
||||||
echo "Executing cargoCheckHook"
|
echo "Executing cargoCheckHook"
|
||||||
@ -15,7 +16,7 @@ cargoCheckHook() {
|
|||||||
threads=1
|
threads=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
argstr="--${cargoCheckType} --target @rustTargetPlatformSpec@ --frozen";
|
argstr="--${cargoCheckType} --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}";
|
||||||
|
|
||||||
(
|
(
|
||||||
set -x
|
set -x
|
||||||
|
Loading…
x
Reference in New Issue
Block a user