1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-21 17:01:10 +03:00
nixpkgs/pkgs/development/interpreters/python/hooks/pytest-check-hook.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1 KiB
Bash
Raw Normal View History

# Setup hook for pytest
echo "Sourcing pytest-check-hook"
declare -ar disabledTests
declare -a disabledTestPaths
function pytestCheckPhase() {
echo "Executing pytestCheckPhase"
runHook preCheck
# Compose arguments
args=" -m pytest"
if [ -n "$disabledTests" ]; then
disabledTestsString="not $(concatStringsSep " and not " disabledTests)"
2024-09-10 23:15:40 +08:00
args+=" -k \""$disabledTestsString"\""
fi
if [ -n "${disabledTestPaths-}" ]; then
eval "disabledTestPaths=($disabledTestPaths)"
fi
for path in ${disabledTestPaths[@]}; do
2024-09-10 23:15:40 +08:00
if [ ! -e "$path" ]; then
echo "Disabled tests path \"$path\" does not exist. Aborting"
exit 1
fi
args+=" --ignore=\"$path\""
done
args+=" ${pytestFlagsArray[@]}"
eval "@pythonCheckInterpreter@ $args"
runHook postCheck
echo "Finished executing pytestCheckPhase"
}
if [ -z "${dontUsePytestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then
echo "Using pytestCheckPhase"
appendToVar preDistPhases pytestCheckPhase
fi