File tree Expand file tree Collapse file tree
development/interpreters/python/hooks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,37 +4,14 @@ echo "Sourcing pytest-check-hook"
44declare -ar disabledTests
55declare -a disabledTestPaths
66
7- function _concatSep {
8- local result
9- local sep=" $1 "
10- local -n arr=$2
11- for index in ${! arr[*]} ; do
12- if [ $index -eq 0 ]; then
13- result=" ${arr[index]} "
14- else
15- result+=" $sep ${arr[index]} "
16- fi
17- done
18- echo " $result "
19- }
20-
21- function _pytestComputeDisabledTestsString() {
22- declare -a tests
23- local tests=($1 )
24- local prefix=" not "
25- prefixed=(" ${tests[@]/#/ $prefix } " )
26- result=$( _concatSep " and" prefixed)
27- echo " $result "
28- }
29-
307function pytestCheckPhase() {
318 echo " Executing pytestCheckPhase"
329 runHook preCheck
3310
3411 # Compose arguments
3512 args=" -m pytest"
3613 if [ -n " $disabledTests " ]; then
37- disabledTestsString=$( _pytestComputeDisabledTestsString " ${disabledTests[@]} " )
14+ disabledTestsString=" not $( concatStringsSep " and not " disabledTests ) "
3815 args+=" -k \" " $disabledTestsString " \" "
3916 fi
4017
Original file line number Diff line number Diff line change @@ -432,6 +432,11 @@ concatTo() {
432432# $ flags=("lorem ipsum" "dolor" "sit amet")
433433# $ concatStringsSep ";" flags
434434# lorem ipsum;dolor;sit amet
435+ #
436+ # Also supports multi-character separators;
437+ # $ flags=("lorem ipsum" "dolor" "sit amet")
438+ # $ concatStringsSep " and " flags
439+ # lorem ipsum and dolor and sit amet
435440concatStringsSep () {
436441 local sep=" $1 "
437442 local name=" $2 "
@@ -443,11 +448,15 @@ concatStringsSep() {
443448 echo " concatStringsSep(): ERROR: trying to use concatStringsSep on an associative array." >&2
444449 return 1 ;;
445450 -a* )
446- local IFS=" $sep "
447- echo -n " ${nameref[*]} " ;;
451+ # \036 is the "record separator" character. We assume that this will never need to be part of
452+ # an argument string we create here. If anyone ever hits this limitation: Feel free to refactor.
453+ local IFS=$' \036 ' ;;
448454 * )
449- echo -n " ${nameref// / " ${sep} " } " ;;
455+ local IFS=" " ;;
456+
450457 esac
458+ local ifs_separated=" ${nameref[*]} "
459+ echo -n " ${ifs_separated// " $IFS " / " $sep " } "
451460 fi
452461}
453462
Original file line number Diff line number Diff line change 161161 arrayWithSep="$(concatStringsSep "&" array)"
162162 [[ "$arrayWithSep" == "lorem ipsum&dolor&sit amet" ]] || (echo "'\$arrayWithSep' was not 'lorem ipsum&dolor&sit amet'" && false)
163163
164+ array=("lorem ipsum" "dolor" "sit amet")
165+ arrayWithSep="$(concatStringsSep "++" array)"
166+ [[ "$arrayWithSep" == "lorem ipsum++dolor++sit amet" ]] || (echo "'\$arrayWithSep' was not 'lorem ipsum++dolor++sit amet'" && false)
167+
168+ array=("lorem ipsum" "dolor" "sit amet")
169+ arrayWithSep="$(concatStringsSep " and " array)"
170+ [[ "$arrayWithSep" == "lorem ipsum and dolor and sit amet" ]] || (echo "'\$arrayWithSep' was not 'lorem ipsum and dolor and sit amet'" && false)
171+
164172 touch $out
165173 '' ;
166174 } ;
You can’t perform that action at this time.
0 commit comments