aboutsummaryrefslogtreecommitdiff
path: root/lua/test.sh
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-03-03 11:09:37 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-03-03 11:29:35 +0100
commit2f8f3871b98d0a431ca90372f318df67e5b7d01f (patch)
tree6b652eceab043fb37486a4b82128282694b52618 /lua/test.sh
parent85f9eac4b981629af2f63c94407843d4dd554ca7 (diff)
downloadvis-2f8f3871b98d0a431ca90372f318df67e5b7d01f.tar.gz
vis-2f8f3871b98d0a431ca90372f318df67e5b7d01f.tar.xz
test/lua: add infrastructure for busted based unit tests
Diffstat (limited to 'lua/test.sh')
-rwxr-xr-xlua/test.sh27
1 files changed, 14 insertions, 13 deletions
diff --git a/lua/test.sh b/lua/test.sh
index d4193e0..717a02d 100755
--- a/lua/test.sh
+++ b/lua/test.sh
@@ -9,33 +9,34 @@ if ! $VIS -v | grep '+lua' >/dev/null 2>&1; then
exit 0
fi
+type busted >/dev/null 2>&1 || {
+ echo "busted(1) not found, skipping tests"
+ exit 0
+}
+
TESTS_OK=0
TESTS_RUN=0
if [ $# -gt 0 ]; then
test_files=$*
else
- printf ':help\n:/ Lua paths/,$ w help\n:qall\n' | $VIS 2> /dev/null && cat help && rm -f help
- test_files="$(find . -type f -name "*.in") basic_empty_file.in"
+ #test_files="$(find . -type f -name "*.in") basic_empty_file.in"
+ test_files="lines.in"
fi
for t in $test_files; do
TESTS_RUN=$((TESTS_RUN + 1))
t=${t%.in}
t=${t#./}
- $VIS "$t".in < /dev/null 2> /dev/null
-
printf "%-30s" "$t"
- if [ -e "$t".out ]; then
- if cmp -s "$t".ref "$t".out 2> /dev/null; then
- printf "PASS\n"
- TESTS_OK=$((TESTS_OK + 1))
- else
- printf "FAIL\n"
- diff -u "$t".ref "$t".out > "$t".err
- fi
+ $VIS "$t.in" < /dev/null 2> /dev/null > "$t.busted"
+
+ if [ $? -ne 0 ]; then
+ printf "FAIL\n"
+ cat "$t.busted"
else
- printf "ERROR\n"
+ TESTS_OK=$((TESTS_OK + 1))
+ printf "OK\n"
fi
done