2019-07-17 20:36:47 +02:00
|
|
|
# Setup hook for pytest
|
|
|
|
echo "Sourcing pytest-check-hook"
|
|
|
|
|
|
|
|
declare -ar disabledTests
|
2021-02-19 09:58:39 -05:00
|
|
|
declare -a disabledTestPaths
|
2019-07-17 20:36:47 +02:00
|
|
|
|
|
|
|
function pytestCheckPhase() {
|
|
|
|
echo "Executing pytestCheckPhase"
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
# Compose arguments
|
|
|
|
args=" -m pytest"
|
|
|
|
if [ -n "$disabledTests" ]; then
|
2024-11-30 16:38:02 +01:00
|
|
|
disabledTestsString="not $(concatStringsSep " and not " disabledTests)"
|
2024-09-10 23:15:40 +08:00
|
|
|
args+=" -k \""$disabledTestsString"\""
|
2019-07-17 20:36:47 +02:00
|
|
|
fi
|
2021-02-19 09:58:39 -05:00
|
|
|
|
|
|
|
if [ -n "${disabledTestPaths-}" ]; then
|
|
|
|
eval "disabledTestPaths=($disabledTestPaths)"
|
|
|
|
fi
|
|
|
|
|
2021-02-14 23:54:55 +01:00
|
|
|
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\""
|
2021-01-06 00:32:27 +01:00
|
|
|
done
|
2019-07-17 20:36:47 +02:00
|
|
|
args+=" ${pytestFlagsArray[@]}"
|
|
|
|
eval "@pythonCheckInterpreter@ $args"
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
echo "Finished executing pytestCheckPhase"
|
|
|
|
}
|
|
|
|
|
2019-10-31 17:59:18 +00:00
|
|
|
if [ -z "${dontUsePytestCheck-}" ] && [ -z "${installCheckPhase-}" ]; then
|
2019-07-17 20:36:47 +02:00
|
|
|
echo "Using pytestCheckPhase"
|
2024-09-03 04:14:28 +08:00
|
|
|
appendToVar preDistPhases pytestCheckPhase
|
2019-07-17 20:36:47 +02:00
|
|
|
fi
|