test/sam: add tests for empty matches at the end of a range
[vis-test.git] / lua / test.sh
blob4d885de3125128caaf4272d126f4500455254fd1
1 #!/bin/sh
3 export VIS_PATH=.
4 [ -z "$VIS" ] && VIS="../../vis"
5 $VIS -v
7 if ! $VIS -v | grep '+lua' >/dev/null 2>&1; then
8 echo "vis compiled without lua support, skipping tests"
9 exit 0
12 type busted >/dev/null 2>&1 || {
13 echo "busted(1) not found, skipping tests"
14 exit 0
17 TESTS_OK=0
18 TESTS_RUN=0
20 if [ $# -gt 0 ]; then
21 test_files=$*
22 else
23 test_files="$(find . -type f -name '*.lua' -a ! -name visrc.lua)"
26 for t in $test_files; do
27 TESTS_RUN=$((TESTS_RUN + 1))
28 t=${t%.lua}
29 t=${t#./}
30 printf "%-30s" "$t"
31 $VIS "$t.in" < /dev/null 2> /dev/null > "$t.busted"
33 if [ $? -ne 0 ]; then
34 printf "FAIL\n"
35 cat "$t.busted"
36 else
37 TESTS_OK=$((TESTS_OK + 1))
38 printf "OK\n"
40 done
42 printf "Tests ok %d/%d\n" $TESTS_OK $TESTS_RUN
44 # set exit status
45 [ $TESTS_OK -eq $TESTS_RUN ]