From: Richard W.M. Jones Date: Sat, 11 Jan 2020 20:07:47 +0000 (+0000) Subject: tests: Print PASS/FAIL for each test. X-Git-Tag: v'0.2'~43 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=490d147a899cb682af67bc5bc3eb64a9ad00985e;p=goals.git tests: Print PASS/FAIL for each test. Simple test harness. --- diff --git a/.gitignore b/.gitignore index c7b71aa..f7f3271 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.cmx *.cma *.cmxa +*.log *.o /man/*.? diff --git a/Goalfile.in b/Goalfile.in index 3c6bf9d..623a09d 100644 --- a/Goalfile.in +++ b/Goalfile.in @@ -38,6 +38,7 @@ goal clean = { done rm -f src/parser.ml src/parser.mli src/lexer.ml src/parser.conflicts rm -f man/*.1 man/*.5 + rm -f tests/*.log # We don't delete src/goals because it is required to do builds. # If you want to really delete it, use the maintainer-clean rule. @@ -135,8 +136,19 @@ let tests = wrap ("test", wildcard ("tests/*.sh")) goal check () = : tests -goal test (name) = : { +goal test (name) = @{ t=`basename %name` cd tests - ../run ./$t + if ../run ./$t > $t.log 2>&1; then + start_green + echo -n "PASS: " + end_colour + echo $t + else + start_red + echo -n "FAIL: " + end_colour + echo $t + exit 1 + fi } diff --git a/stdlib/prelude.sh b/stdlib/prelude.sh index 60d5b9f..254c380 100644 --- a/stdlib/prelude.sh +++ b/stdlib/prelude.sh @@ -26,3 +26,23 @@ function quoted_string () # XXX This doesn't actually do quoting XXX echo -n "\"$1\"" } + +# For printing strings in different colours, use these functions. +function start_red () +{ + echo -ne "\x1b[1;31m" +} + +function start_green () +{ + echo -ne "\x1b[0;32m" +} + +function end_colour () +{ + echo -ne "\x1b[0m" +} +function end_color () +{ + echo -ne "\x1b[0m" +}