stdenv: support multi-char separators in concatStringsSep
One prominent use-case for this is pytestCheckHook. This will help making it work with structuredAttrs in the future.
This commit is contained in:
@@ -4,29 +4,6 @@ echo "Sourcing pytest-check-hook"
|
||||
declare -ar disabledTests
|
||||
declare -a disabledTestPaths
|
||||
|
||||
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
|
||||
@@ -34,7 +11,7 @@ function pytestCheckPhase() {
|
||||
# Compose arguments
|
||||
args=" -m pytest"
|
||||
if [ -n "$disabledTests" ]; then
|
||||
disabledTestsString=$(_pytestComputeDisabledTestsString "${disabledTests[@]}")
|
||||
disabledTestsString="not $(concatStringsSep " and not " disabledTests)"
|
||||
args+=" -k \""$disabledTestsString"\""
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user