diff options
author | figsoda <figsoda@pm.me> | 2022-11-28 16:59:52 -0500 |
---|---|---|
committer | figsoda <figsoda@pm.me> | 2022-11-28 16:59:52 -0500 |
commit | 0643540f97995e785b5e1d9b62be6876da3d2d20 (patch) | |
tree | d3a5df9f7a33f97c44e1c51fa629b9ddc876e6df /pkgs/build-support | |
parent | 11e329ae8c251cabb38f4b00ec33607e74c188e9 (diff) |
rustPlatform.cargoNextestHook: init
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/rust/hooks/cargo-nextest-hook.sh | 54 | ||||
-rw-r--r-- | pkgs/build-support/rust/hooks/default.nix | 10 |
2 files changed, 64 insertions, 0 deletions
diff --git a/pkgs/build-support/rust/hooks/cargo-nextest-hook.sh b/pkgs/build-support/rust/hooks/cargo-nextest-hook.sh new file mode 100644 index 0000000000000..de85683ead2ac --- /dev/null +++ b/pkgs/build-support/rust/hooks/cargo-nextest-hook.sh @@ -0,0 +1,54 @@ +declare -a checkFlags +declare -a cargoTestFlags + +cargoNextestHook() { + echo "Executing cargoNextestHook" + + runHook preCheck + + if [[ -n "${buildAndTestSubdir-}" ]]; then + pushd "${buildAndTestSubdir}" + fi + + if [[ -z ${dontUseCargoParallelTests-} ]]; then + threads=$NIX_BUILD_CORES + else + threads=1 + fi + + if [ "${cargoCheckType}" != "debug" ]; then + cargoCheckProfileFlag="--${cargoCheckType}" + fi + + if [ -n "${cargoCheckNoDefaultFeatures-}" ]; then + cargoCheckNoDefaultFeaturesFlag=--no-default-features + fi + + if [ -n "${cargoCheckFeatures-}" ]; then + cargoCheckFeaturesFlag="--features=${cargoCheckFeatures// /,}" + fi + + argstr="${cargoCheckProfileFlag} ${cargoCheckNoDefaultFeaturesFlag} ${cargoCheckFeaturesFlag} + --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}" + + ( + set -x + cargo nextest run \ + -j ${threads} \ + ${argstr} -- \ + ${checkFlags} \ + ${checkFlagsArray+"${checkFlagsArray[@]}"} + ) + + if [[ -n "${buildAndTestSubdir-}" ]]; then + popd + fi + + echo "Finished cargoNextestHook" + + runHook postCheck +} + +if [ -z "${dontCargoCheck-}" ] && [ -z "${checkPhase-}" ]; then + checkPhase=cargoNextestHook +fi diff --git a/pkgs/build-support/rust/hooks/default.nix b/pkgs/build-support/rust/hooks/default.nix index 6ee122adb52a1..b9bbac3719859 100644 --- a/pkgs/build-support/rust/hooks/default.nix +++ b/pkgs/build-support/rust/hooks/default.nix @@ -1,6 +1,7 @@ { buildPackages , callPackage , cargo +, cargo-nextest , clang , lib , makeSetupHook @@ -55,6 +56,15 @@ in { }; } ./cargo-install-hook.sh) {}; + cargoNextestHook = callPackage ({ }: + makeSetupHook { + name = "cargo-nextest-hook.sh"; + deps = [ cargo cargo-nextest ]; + substitutions = { + inherit rustTargetPlatformSpec; + }; + } ./cargo-nextest-hook.sh) {}; + cargoSetupHook = callPackage ({ }: makeSetupHook { name = "cargo-setup-hook.sh"; |