summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-05-05 08:15:52 +0300
committerLars Wirzenius <liw@liw.fi>2023-05-05 08:15:52 +0300
commit85e26c059c4d0551513fdb3e40ee6f747dd0215e (patch)
treeca610e02d1f10c6345cc3da36c0b00ad62351cee
parentfad65a1bc353757db14a371574a6394c61a120f1 (diff)
downloadvmdb2-85e26c059c4d0551513fdb3e40ee6f747dd0215e.tar.gz
chore: reformat ./check script
Sponsored-by: author
-rwxr-xr-xcheck98
1 files changed, 45 insertions, 53 deletions
diff --git a/check b/check
index 31da2e8..992f7cc 100755
--- a/check
+++ b/check
@@ -1,17 +1,14 @@
#!/bin/bash
-set -eu
-set -o pipefail
+set -euo pipefail
hideok=chronic
-if ! command -v chronic > /dev/null
-then
- hideok=
+if ! command -v chronic >/dev/null; then
+ hideok=
fi
-if [ "$#" -gt 0 ] && [ "$1" = -v ]
-then
- hideok=
- shift
+if [ "$#" -gt 0 ] && [ "$1" = -v ]; then
+ hideok=
+ shift
fi
$hideok echo Running unit tests ============================================
@@ -19,77 +16,72 @@ $hideok python3 -m CoverageTestRunner --ignore-missing-from=without-tests yarns
$hideok echo
$hideok echo Checking every plugin looks OK ============================================
-for file in vmdb/plugins/*.py
-do
- case "$file" in
+for file in vmdb/plugins/*.py; do
+ case "$file" in
*_plugin.py) ;;
- *) echo "File $file should end in _plugin.py" 1>&2 ; exit 1 ;;
- esac
- if ! grep -q 'class .*Plugin' "$file"
- then
- echo "File $file does not seem to have a Plugin class" 1>&2
- exit 1
- fi
+ *)
+ echo "File $file should end in _plugin.py" 1>&2
+ exit 1
+ ;;
+ esac
+ if ! grep -q 'class .*Plugin' "$file"; then
+ echo "File $file does not seem to have a Plugin class" 1>&2
+ exit 1
+ fi
done
$hideok echo
-if command -v sp-codegen > /dev/null
-then
- $hideok echo Running Subplot ============================================
- $hideok sp-codegen vmdb2.md -o test.py --run
- $hideok echo
+if command -v sp-codegen >/dev/null; then
+ $hideok echo Running Subplot ============================================
+ $hideok sp-codegen vmdb2.md -o test.py --run
+ $hideok echo
fi
$hideok echo Running yarn tests ========================================
-if python3 -c 'import yarnutils' 2>/dev/null
-then
- $hideok yarn \
- --shell=python3 \
- --shell-arg '' \
- --shell-library yarns/lib.py \
- --env "PYTHONPATH=$(pwd)/yarns" \
- --cd-datadir \
- yarns/*.yarn "$@"
- $hideok echo
+if python3 -c 'import yarnutils' 2>/dev/null; then
+ $hideok yarn \
+ --shell=python3 \
+ --shell-arg '' \
+ --shell-library yarns/lib.py \
+ --env "PYTHONPATH=$(pwd)/yarns" \
+ --cd-datadir \
+ yarns/*.yarn "$@"
+ $hideok echo
fi
$hideok echo Formatting docs ========================================
./format.sh
plugindocs() {
- ls -1 vmdb/plugins/*.mdwn
+ ls -1 vmdb/plugins/*.mdwn
}
steps() {
- sed -n '/<h2 id="step-.*> Step: /s///p' vmdb2.html
+ sed -n '/<h2 id="step-.*> Step: /s///p' vmdb2.html
}
code() {
- steps | grep '<code>' || true
+ steps | grep '<code>' || true
}
panic() {
- echo "ERROR: $*" 1>&2
- exit 1
+ echo "ERROR: $*" 1>&2
+ exit 1
}
-for doc in $(plugindocs)
-do
- n="$(grep -c '^Step:' "$doc")"
- if [ "$n" != 1 ]
- then
- panic "Plugin doc $doc must have exactly 1 step title"
- fi
+for doc in $(plugindocs); do
+ n="$(grep -c '^Step:' "$doc")"
+ if [ "$n" != 1 ]; then
+ panic "Plugin doc $doc must have exactly 1 step title"
+ fi
done
n="$(code | wc -l)"
-if [ "$n" != 0 ]
-then
- code
- panic "Documentation has steps that use code in title"
+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"
+if ! diff -u <(steps) <(steps | sort); then
+ panic "Steps are not in sorted order"
fi