From: Eric S. Raymond Date: Fri, 16 Apr 2021 19:11:56 +0000 (-0400) Subject: TAPify the test suite. X-Git-Tag: 2.6~4 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=refs%2Fmerge-requests%2F4%2Fmerge;p=super-star-trek.git TAPify the test suite. --- diff --git a/.gitignore b/.gitignore index fabcf9e..8e3a213 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ index.html sst.pyc sst.html +sst-doc.html sst.6 doc/sst.doc doc/sst-doc.txt diff --git a/test/Makefile b/test/Makefile index cf908be..557cbd5 100644 --- a/test/Makefile +++ b/test/Makefile @@ -2,11 +2,20 @@ PYTHON=python +TAPFILTER=cat +ifeq (,$(command -v tapview)) + TAPFILTER=tapview +else + ifeq (,$(command -v tappy)) + TAPFILTER=tappy + endif +endif + all: @echo "With Python 2:" - @$(MAKE) -e PYTHON=python2 regress + @$(MAKE) -e PYTHON=python2 regress | $(TAPFILTER) @echo "With Python 3:" - @$(MAKE) -e PYTHON=python3 regress + @$(MAKE) -e PYTHON=python3 regress | $(TAPFILTER) @echo "No diff output is good news." .SUFFIXES: .log .chk @@ -24,14 +33,13 @@ buildregress: fi \ done regress: + echo "1..$$(ls *.log | wc -l)" @for test in $(TESTLOADS); \ do \ if [ ! -f $${test}.tst ] ; \ then \ - (if echo -n "$${test}: " >&2; grep 'Test' $${test}.log >&2;\ - $(PYTHON) ../sst.py -r $${test}.log >/tmp/regress 2>&1; \ - then diff -u $${test}.chk /tmp/regress; \ - else echo "*** Nonzero return status on $${test}!"; exit 1; fi;) \ + legend=$$(sed -n -e '/# Test/s//Test/p' <$${test}.log); \ + ../sst.py -r "$${test}.log" | ./tapdiffer "$${legend}" "$${test}.chk"; \ fi \ done @rm -f /tmp/regress diff --git a/test/tapdiffer b/test/tapdiffer new file mode 100755 index 0000000..f200de1 --- /dev/null +++ b/test/tapdiffer @@ -0,0 +1,31 @@ +#! /bin/sh +# +# tapdiffer - Render diff between input and checkfile as a TAP report +# +# Usage: tapdiffer LEGEND CHECKFILE +# +# Output is a TAP report, ok if the diff is empty and not ok otherwisw. +# A nonempty diff is shipped as a TAP YAML block following "not ok" +# unless QUIET=1 in the environment. +# +legend=$1 +checkfile=$2 + +trap 'rm /tmp/tapdiff$$' EXIT HUP INT QUIT TERM + +if diff --text -u ${checkfile} - >/tmp/tapdiff$$ +then + echo "ok - ${legend}" + exit 0 +else + echo "not ok - ${checkfile}: ${legend}" + if [ ! "${QUIET}" = 1 ] + then + echo " --- |" + sed