summaryrefslogtreecommitdiff
path: root/check
diff options
context:
space:
mode:
Diffstat (limited to 'check')
-rwxr-xr-xcheck56
1 files changed, 56 insertions, 0 deletions
diff --git a/check b/check
new file mode 100755
index 0000000..225aa7e
--- /dev/null
+++ b/check
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Run the automated tests for the project.
+
+set -eu -o pipefail
+
+cat_with_sep() {
+ for x in "$@"; do
+ cat "$x"
+ echo
+ done
+}
+
+hideok=chronic
+if [ "$#" -gt 0 ]; then
+ case "$1" in
+ verbose | -v | --verbose)
+ hideok=
+ shift 1
+ ;;
+ esac
+fi
+
+dir="$(mktemp -d -p .)"
+
+trap 'rm -rf "$dir"' EXIT
+
+rm -f test.log test.py
+cp subplot.subplot subplot.md "$dir"
+cat_with_sep subplot.md roles/*/subplot.md >"$dir/subplot.md"
+cat_with_sep subplot/*.py roles/*/subplot.py >"$dir/subplot.py"
+cat_with_sep subplot/*.yaml roles/*/subplot.yaml >"$dir/subplot.yaml"
+
+(
+ set -eu -o pipefail
+ cd "$dir"
+ subplot docgen subplot.subplot -o ../subplot.pdf
+ subplot docgen subplot.subplot -o ../subplot.html
+ subplot codegen subplot.subplot -o ../test.py
+)
+
+# Fix private key permissions. git doesn't preserve them.
+chmod 0600 ssh/id
+
+# Create configuration for the test VMs used by the test suite.
+cat >test.cfg <<EOF
+name: debian-ansible-test
+base_image: "$HOME/tmp/debian.qcow2"
+username: debian
+cpus: 2
+memory: 1024
+EOF
+
+$hideok python3 test.py --log test.log --env ANSIBLE_STDOUT_CALLBACK=yaml "$@"
+
+echo "Everything seems to be in order."