From 2f8f3871b98d0a431ca90372f318df67e5b7d01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 3 Mar 2017 11:09:37 +0100 Subject: test/lua: add infrastructure for busted based unit tests --- lua/test.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lua/test.sh') 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 -- cgit v1.2.3