2019-07-17 19:36:47 +01:00
|
|
|
# Setup hook for pytest
|
|
|
|
echo "Sourcing pytest-check-hook"
|
|
|
|
|
|
|
|
declare -ar disabledTests
|
|
|
|
|
|
|
|
function _concatSep {
|
|
|
|
local result
|
|
|
|
local sep="$1"
|
|
|
|
local -n arr=$2
|
|
|
|
for index in ${!arr[*]}; do
|
|
|
|
if [ $index -eq 0 ]; then
|
|
|
|
result="${arr[index]}"
|
|
|
|
else
|
|
|
|
result+=" $sep ${arr[index]}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "$result"
|
|
|
|
}
|
|
|
|
|
|
|
|
function _pytestComputeDisabledTestsString () {
|
|
|
|
declare -a tests
|
|
|
|
local tests=($1)
|
|
|
|
local prefix="not "
|
|
|
|
prefixed=( "${tests[@]/#/$prefix}" )
|
|
|
|
result=$(_concatSep "and" prefixed)
|
|
|
|
echo "$result"
|
|
|
|
}
|
|
|
|
|
|
|
|
function pytestCheckPhase() {
|
|
|
|
echo "Executing pytestCheckPhase"
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
# Compose arguments
|
|
|
|
args=" -m pytest"
|
|
|
|
if [ -n "$disabledTests" ]; then
|
|
|
|
disabledTestsString=$(_pytestComputeDisabledTestsString "${disabledTests[@]}")
|
|
|
|
args+=" -k \""$disabledTestsString"\""
|
|
|
|
fi
|
|
|
|
args+=" ${pytestFlagsArray[@]}"
|
|
|
|
eval "@pythonCheckInterpreter@ $args"
|
|
|
|
|
|
|
|
runHook postCheck
|
|
|
|
echo "Finished executing pytestCheckPhase"
|
|
|
|
}
|
|
|
|
|
2019-10-31 16:50:15 +00:00
|
|
|
if [ -z "${dontUsePytestCheck-}" ] && [ -z "$installCheckPhase" ]; then
|
2019-07-17 19:36:47 +01:00
|
|
|
echo "Using pytestCheckPhase"
|
|
|
|
preDistPhases+=" pytestCheckPhase"
|
|
|
|
fi
|