anvil-editor: init at 0.4
[NixPkgs.git] / pkgs / build-support / rust / hooks / cargo-nextest-hook.sh
blob4719d1bad8ae92a936d5463ce4696a82fdeec6e6
1 # shellcheck shell=bash disable=SC2154,SC2164
3 cargoNextestHook() {
4 echo "Executing cargoNextestHook"
6 runHook preCheck
8 if [[ -n "${buildAndTestSubdir-}" ]]; then
9 pushd "${buildAndTestSubdir}"
12 local flagsArray=(
13 "--target" "@rustHostPlatformSpec@"
14 "--offline"
17 if [[ -z ${dontUseCargoParallelTests-} ]]; then
18 flagsArray+=("-j" "$NIX_BUILD_CORES")
19 else
20 flagsArray+=("-j" "1")
23 if [ "${cargoCheckType}" != "debug" ]; then
24 flagsArray+=("--cargo-profile" "${cargoCheckType}")
27 if [ -n "${cargoCheckNoDefaultFeatures-}" ]; then
28 flagsArray+=("--no-default-features")
31 if [ -n "${cargoCheckFeatures-}" ]; then
32 flagsArray+=("--features=$(concatStringsSep "," cargoCheckFeatures)")
35 prependToVar checkFlags "--"
36 concatTo flagsArray cargoTestFlags checkFlags checkFlagsArray
38 echoCmd 'cargoNextestHook flags' "${flagsArray[@]}"
39 cargo nextest run "${flagsArray[@]}"
41 if [[ -n "${buildAndTestSubdir-}" ]]; then
42 popd
45 echo "Finished cargoNextestHook"
47 runHook postCheck
50 if [ -z "${dontCargoCheck-}" ] && [ -z "${checkPhase-}" ]; then
51 checkPhase=cargoNextestHook