aboutsummaryrefslogtreecommitdiffstats
path: root/test.sh
diff options
context:
space:
mode:
authorWolfgang Müller2021-03-10 17:09:13 +0100
committerWolfgang Müller2021-03-10 17:09:13 +0100
commit3bce19d12d93f1b27e7d2f2acbef0926417d5390 (patch)
tree3700afd21af95a0904be6aaf3378fc75e3955b10 /test.sh
parent1d767c0bdd6476a4ba9a998b8953ec8b9ad9f21c (diff)
downloadbosun-3bce19d12d93f1b27e7d2f2acbef0926417d5390.tar.gz
Add a first draft of the test suite1.3.0
The introduction of a test suite makes future changes easier to troubleshoot and verify. Whilst this is only a first draft, it should be stable enough to be used in normal development and should cover the entirety of bosun's functionality.
Diffstat (limited to 'test.sh')
-rw-r--r--test.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/test.sh b/test.sh
new file mode 100644
index 0000000..f59412c
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+TMPDIR=${TMPDIR:-/tmp}
+MOCK_ROOT=$TMPDIR/bosun-test
+
+TESTDIR=$PWD/test
+BOSUN_CMD=$PWD/bosun
+
+run_test() {
+ TARGET_DIR=$MOCK_ROOT/$1/mock
+ BOSUN_DIR=$TARGET_DIR/stow
+
+ rm -rf "$TARGET_DIR"
+
+ . test/setup.sh || exit 1
+
+ (
+ cd "$TARGET_DIR/.." || exit 1
+ env -i \
+ PATH="/usr/bin:/bin" \
+ BOSUN_CMD="$BOSUN_CMD" \
+ BOSUN_DIR="$BOSUN_DIR" \
+ sh -c ". $TESTDIR/lib.sh; . $TESTDIR/$1.test"
+ )
+ TESTS_FAILED=$((TESTS_FAILED + $?))
+}
+
+run_test 01-add
+run_test 02-list
+run_test 03-flush
+run_test 04-rebuild
+run_test 05-remove
+run_test 06-default
+
+test $TESTS_FAILED -gt 0 && exit 1
+exit 0