test/sam: add tests for empty matches at the end of a range
[vis-test.git] / vis / test.sh
blob26702d3d35c820b41db5a8e2a1b50b9d9ddef7f8
1 #!/bin/sh
3 export VIS_PATH=.
4 export PATH="$(pwd)/../..:$PATH"
5 export LANG="en_US.UTF-8"
6 [ -z "$VIS" ] && VIS="../../vis"
7 $VIS -v
9 if ! $VIS -v | grep '+lua' >/dev/null 2>&1; then
10 echo "vis compiled without lua support, skipping tests"
11 exit 0
14 TESTS_OK=0
15 TESTS_RUN=0
17 if [ $# -gt 0 ]; then
18 test_files=$*
19 else
20 printf ':help\n:/ Lua paths/,$ w help\n:qall\n' | $VIS 2> /dev/null && cat help && rm -f help
21 test_files="$(find . -type f -name '*.in')"
24 for t in $test_files; do
25 TESTS_RUN=$((TESTS_RUN + 1))
26 t=${t%.in}
27 t=${t#./}
28 $VIS '+qall!' "$t".in < /dev/null 2> /dev/null
29 RETURN_CODE=$?
31 printf "%-50s" "$t"
32 if [ $RETURN_CODE -eq 0 -a -e "$t".out ]; then
33 if cmp -s "$t".ref "$t".out 2> /dev/null; then
34 printf "PASS\n"
35 TESTS_OK=$((TESTS_OK + 1))
36 else
37 printf "FAIL\n"
38 diff -u "$t".ref "$t".out > "$t".err
40 else
41 printf "ERROR\n"
43 done
45 printf "Tests ok %d/%d\n" $TESTS_OK $TESTS_RUN
47 # set exit status
48 [ $TESTS_OK -eq $TESTS_RUN ]