summaryrefslogtreecommitdiff
path: root/test/vis/test.sh
diff options
context:
space:
mode:
authorRandy Palamar <randy@rnpnr.xyz>2024-05-21 19:53:22 -0600
committerRandy Palamar <randy@rnpnr.xyz>2024-05-21 19:53:22 -0600
commitb7074021b7bfb0932b889b9560dd22df31cef818 (patch)
tree0295b18de8fb8ea5289cbda95675687ae06025ff /test/vis/test.sh
parentb7f8018a00be930e3f2b864949aec1f91291309c (diff)
parentefafa3c178268a4149fc3e432bc1174a013c16de (diff)
Merge vis-tests into test directory
Going forward all tests should be submitted here directly.
Diffstat (limited to 'test/vis/test.sh')
-rwxr-xr-xtest/vis/test.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/vis/test.sh b/test/vis/test.sh
new file mode 100755
index 0000000..26702d3
--- /dev/null
+++ b/test/vis/test.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+export VIS_PATH=.
+export PATH="$(pwd)/../..:$PATH"
+export LANG="en_US.UTF-8"
+[ -z "$VIS" ] && VIS="../../vis"
+$VIS -v
+
+if ! $VIS -v | grep '+lua' >/dev/null 2>&1; then
+ echo "vis compiled without lua support, skipping tests"
+ exit 0
+fi
+
+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')"
+fi
+
+for t in $test_files; do
+ TESTS_RUN=$((TESTS_RUN + 1))
+ t=${t%.in}
+ t=${t#./}
+ $VIS '+qall!' "$t".in < /dev/null 2> /dev/null
+ RETURN_CODE=$?
+
+ printf "%-50s" "$t"
+ if [ $RETURN_CODE -eq 0 -a -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
+ else
+ printf "ERROR\n"
+ fi
+done
+
+printf "Tests ok %d/%d\n" $TESTS_OK $TESTS_RUN
+
+# set exit status
+[ $TESTS_OK -eq $TESTS_RUN ]