summaryrefslogtreecommitdiff
path: root/pkgs/development/interpreters/python/hooks/stestr-check-hook.sh
blob: f6db613b89d876d21c9e1640b9d2e34b7ddadd47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Setup hook for stestr
# shellcheck shell=bash

echo "Sourcing stestr-check-hook"

function stestrCheckPhase() {
    echo "Executing stestrCheckPhase"
    runHook preCheck

    local -a patterns=()

    # Append regex pattern
    read -ra patterns <<< "$disabledTestsRegex"

    # Sanitize disabledTests options
    if [[ -n "${disabledTests[*]-}" ]] || [[ -n "${disabledTestsRegex[*]-}" ]]; then
        # Prevent unintentional matching for specific tests
        for test in ${disabledTests[@]-}; do
            patterns+=("^${test}$")
        done
    fi

    # Compose arguments
    local -a flagsArray=()
    if [[ -n "${patterns[*]}" ]]; then
        flagsArray+=(--exclude-regex "($(concatStringsSep "|" patterns))")
    fi

    echoCmd 'stestr flags' "${flagsArray[@]}"
    @pythonCheckInterpreter@ -m stestr run "${flagsArray[@]}"

    runHook postCheck
    echo "Finished executing stestrCheckPhase"
}

if [ -z "${dontUseStestrCheck-}" ] && [ -z "${installCheckPhase-}" ]; then
    echo "Using stestrCheckPhase"
    appendToVar preDistPhases stestrCheckPhase
fi