aboutsummaryrefslogtreecommitdiff
path: root/tests/rt_generic.sh
blob: 672a8a00698d132239a4475ed1c5b40ae479b6b1 (plain) (blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env bash
set -x
unset STASIS_SYSCONFDIR
if [ -n "$GITHUB_TOKEN" ] && [ -z "$STASIS_GH_TOKEN"]; then
    export STASIS_GH_TOKEN="$GITHUB_TOKEN"
else
    export STASIS_GH_TOKEN="anonymous"
fi
python_versions=(
    3.10
    3.11
    3.12
)

topdir=$(pwd)

ws="rt_workspace"
rm -rf "$ws"
mkdir -p "$ws"
ws="$(realpath $ws)"

prefix="$ws"/local
mkdir -p "$prefix"

bdir="$ws"/build
mkdir -p "$bdir"

pushd "$bdir"
cmake -DCMAKE_INSTALL_PREFIX="$prefix" -DCMAKE_BUILD_TYPE=Debug "${topdir}"/../..
make install
export PATH="$prefix/bin:$PATH"
popd

pushd "$ws"
    type -P stasis
    type -P stasis_indexer
    retcode=0

    for py_version in "${python_versions[@]}"; do
        stasis --python "$py_version" --no-docker --no-artifactory --unbuffered -v "$topdir"/generic.ini
        retcode+=$?
    done

    set +x

    echo "#### Files ####"
    find stasis/*/output | sort
    echo

    echo "#### Contents ####"
    files=$(find stasis/*/output -type f \( -name '*.yml' -o -name '*.md' -o -name '*.stasis' -o -name '*.ini' \) | sort)
    for x in $files; do
        echo
        echo "FILENAME: $x"
        echo
        cat "$x"
        echo "[EOF]"
        echo

        fail_on_main=(
            "(null)"
        )
        for cond in "${fail_on_main[@]}"; do
            if grep --color -H -n "$cond" "$x" >&2; then
                echo "ERROR DETECTED IN $x!" >&2
                retcode+=1
            fi
        done
    done

    # Something above failed, so drop out. Don't bother indexing.
    # Don't clean up either.
    (( retcode )) && exit $retcode

    fail_on_indexer=(
        "(null)"
    )
    logfile="stasis_indexer.log"
    set -x
    stasis_indexer --web --unbuffered -v stasis/* 2>&1 | tee "$logfile"
    retcode=$?

    set +x
    echo "#### Files ####"
    find output

    for cond in "${fail_on_indexer[@]}"; do
        if grep --color -H -n "$cond" "$logfile" >&2; then
            echo "ERROR DETECTED IN INDEX OPERATION!" >&2
            exit 1
        fi
    done

    echo "#### Contents ####"
    files=$(find output -type f \( -name '*.html' \) | sort)
    for x in $files; do
        echo
        echo "FILENAME: $x"
        echo
        cat "$x"
        echo "[EOF]"
        echo
    done
popd

if [ -z "$RT_KEEP_WORKSPACE"]; then
    rm -rf "$ws"
fi

exit $retcode