summaryrefslogtreecommitdiff
path: root/check
blob: 43f671a963b67e8cb22a6b46854fca244ec4009e (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash

set -eu
set -o pipefail

echo Running unit tests ============================================
python3 -m CoverageTestRunner --ignore-missing-from=without-tests yarns vmdb
echo

if command -v sp-codegen > /dev/null
then
    echo Running Subplot ============================================
    sp-codegen vmdb2.md -o test.py --run
    echo
fi

echo Running yarn tests ========================================
if python3 -c 'import yarnutils' 2>/dev/null
then
    yarn \
        --shell=python3 \
        --shell-arg '' \
        --shell-library yarns/lib.py \
        --env "PYTHONPATH=$(pwd)/yarns" \
        --cd-datadir \
        yarns/*.yarn "$@"
    echo
fi

echo Formatting docs ========================================
./format.sh

steps() {
    sed -n '/<h2 id="step-.*> Step: /s///p' vmdb2.html
}

code() {
    steps | grep '<code>' || true
}

panic() {
    echo "ERROR: $@" 1>&2
    exit 1
}

n="$(code | wc -l)"
if [ "$n" != 0 ]
then
    code
    panic "Documentation has steps that use code in title"
fi

if ! diff -u <(steps) <(steps | sort)
then
    panic "Steps are not in sorted order"
fi