depot/pkgs/build-support/rust/hooks/cargo-nextest-hook.sh
Luke Granger-Brown 57725ef3ec Squashed 'third_party/nixpkgs/' content from commit 76612b17c0ce
git-subtree-dir: third_party/nixpkgs
git-subtree-split: 76612b17c0ce71689921ca12d9ffdc9c23ce40b2
2024-11-10 23:59:47 +00:00

52 lines
1.2 KiB
Bash

# shellcheck shell=bash disable=SC2154,SC2164
cargoNextestHook() {
echo "Executing cargoNextestHook"
runHook preCheck
if [[ -n "${buildAndTestSubdir-}" ]]; then
pushd "${buildAndTestSubdir}"
fi
local flagsArray=(
"--target" "@rustHostPlatformSpec@"
"--offline"
)
if [[ -z ${dontUseCargoParallelTests-} ]]; then
flagsArray+=("-j" "$NIX_BUILD_CORES")
else
flagsArray+=("-j" "1")
fi
if [ "${cargoCheckType}" != "debug" ]; then
flagsArray+=("--cargo-profile" "${cargoCheckType}")
fi
if [ -n "${cargoCheckNoDefaultFeatures-}" ]; then
flagsArray+=("--no-default-features")
fi
if [ -n "${cargoCheckFeatures-}" ]; then
flagsArray+=("--features=$(concatStringsSep "," cargoCheckFeatures)")
fi
prependToVar checkFlags "--"
concatTo flagsArray cargoTestFlags checkFlags checkFlagsArray
echoCmd 'cargoNextestHook flags' "${flagsArray[@]}"
cargo nextest run "${flagsArray[@]}"
if [[ -n "${buildAndTestSubdir-}" ]]; then
popd
fi
echo "Finished cargoNextestHook"
runHook postCheck
}
if [ -z "${dontCargoCheck-}" ] && [ -z "${checkPhase-}" ]; then
checkPhase=cargoNextestHook
fi