From 3ccc7effa376ea2b9206c272f3087c882f347c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 16 Nov 2016 22:22:49 +0100 Subject: test/vis: convert vis specific tests to use the Lua API Instead of using the keys utility to convert the textual key representation into something a terminal would send and then pipe it to vis' standard input use the Lua API to directly feed the keys into vis' input queue. This has a number of advantages: - it is less fragile: the keys utility is incomplete and only handles the most common keys - it is faster because there is no need to artificially delay input after an key to give vis a chance to distinguish between a single and the start of an escape sequence --- vis/test.sh | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'vis/test.sh') diff --git a/vis/test.sh b/vis/test.sh index a52fe0f..775890c 100755 --- a/vis/test.sh +++ b/vis/test.sh @@ -1,31 +1,37 @@ #!/bin/sh [ -z "$VIS" ] && VIS="../../vis" +$VIS -v -TESTS=$1 -[ -z "$TESTS" ] && TESTS=$(find . -name '*.keys' | sed 's/\.keys$//g') - -TESTS_RUN=0 TESTS_OK=0 +TESTS_RUN=0 -$VIS -v +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 + +export VIS_PATH=. + +for t in $test_files; do + TESTS_RUN=$((TESTS_RUN + 1)) + t=${t%.in} + t=${t#./} + $VIS "$t".in < /dev/null 2> /dev/null -for t in $TESTS; do - ERR="$t.err" - OUT="$t.out" - REF="$t.ref" - printf "Running test %s ... " "$t" - rm -f "$OUT" "$ERR" - { cat "$t.keys"; printf ":wq! $OUT"; } | cpp -P | ../util/keys | $VIS "$t.in" 2> /dev/null - if [ -e "$OUT" ]; then - if cmp -s "$REF" "$OUT"; then - printf "OK\n" - TESTS_OK=$((TESTS_OK+1)) + printf "%-50s" "$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 "$REF" "$OUT" > "$ERR" + diff -u "$t".ref "$t".out > "$t".err fi - TESTS_RUN=$((TESTS_RUN+1)) + else + printf "ERROR\n" fi done -- cgit v1.2.3