# Setup hook for pytest # shellcheck shell=bash echo "Sourcing pytest-check-hook" function _pytestIncludeExcludeExpr() { local includeListName="$1" local -n includeListRef="$includeListName" local excludeListName="$2" local -n excludeListRef="$excludeListName" local includeString excludeString if [[ -n "${includeListRef[*]-}" ]]; then # ((element1) or (element2)) includeString="(($(concatStringsSep ") or (" "$includeListName")))" fi if [[ -n "${excludeListRef[*]-}" ]]; then # and not (element1) and not (element2) excludeString="${includeString:+ and }not ($(concatStringsSep ") and not (" "$excludeListName"))" fi echo "$includeString$excludeString" } function pytestCheckPhase() { echo "Executing pytestCheckPhase" runHook preCheck # Compose arguments local -a flagsArray=(-m pytest) local -a _pathsArray local path _pathsArray=() concatTo _pathsArray enabledTestPaths for path in "${_pathsArray[@]}"; do if [[ "$path" =~ "::" ]]; then flagsArray+=("$path") else # The `|| kill "$$"` trick propagates the errors from the process substitutiton subshell, # which is suggested by a StackOverflow answer: https://unix.stackexchange.com/a/217643 readarray -t -O"${#flagsArray[@]}" flagsArray < <( @pythonCheckInterpreter@ - "$path" <