TAPify the test suite. 4/merge
authorEric S. Raymond <esr@thyrsus.com>
Fri, 16 Apr 2021 19:11:56 +0000 (15:11 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 16 Apr 2021 19:11:56 +0000 (15:11 -0400)
.gitignore
test/Makefile
test/tapdiffer [new file with mode: 0755]
test/test01.chk
test/test01.log

index fabcf9ef41e10ab03c8b473e88a930abde6d3d34..8e3a213315e6ceaca4838356b19f31979df72002 100644 (file)
@@ -1,6 +1,7 @@
 index.html
 sst.pyc
 sst.html
+sst-doc.html
 sst.6
 doc/sst.doc
 doc/sst-doc.txt
index cf908beb7c607e34a9bcfcc210beb519567a103f..557cbd50658da21b91653fc8c0e7f658d074ef23 100644 (file)
@@ -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 (executable)
index 0000000..f200de1
--- /dev/null
@@ -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 </tmp/tapdiff$$ -e 's/^/  /'
+               echo "  ..."
+       fi
+       exit 1
+fi
+
+# end
index b811a073a44c5849b7725f481beac91a03ed1b25..37c0d590237565a2914ea7cb10a773fad2208cd7 100644 (file)
@@ -3,7 +3,7 @@
 -SUPER- STAR TREK
 
 Would you like a regular, tournament, or saved game? # SST2K version 2.4
-# Test bringng game up, viewng galaxy, quitting
+# Test bringing game up, viewing galaxy, quitting
 # recorded by esr@snark on Wed Apr 24 01:46:01 2019
 #seed(1556084761)
 r
index c38f57cbf7f469e3622fe0ac9d093e85348856a3..4f18bb59514ae6ae5ee92621f2816c4a1404dd2a 100644 (file)
@@ -1,7 +1,7 @@
 # seed 1556084761
 # options 
 # SST2K version 2.4
-# Test bringng game up, viewng galaxy, quitting
+# Test bringing game up, viewing galaxy, quitting
 # recorded by esr@snark on Wed Apr 24 01:46:01 2019
 #seed(1556084761)
 r