]> thyrsus.com Git - intercal.git/commitdiff
Document the regressioncheck script better, and make it a bit more flexible.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 26 Aug 2010 21:32:25 +0000 (17:32 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 26 Aug 2010 21:32:25 +0000 (17:32 -0400)
pit/Makefile
pit/regresscheck

index b57858752da3ee5743910701ed64fb5524ae1433..ef79d0a1a8d0e1cedfa8f053bf16386793664136 100644 (file)
@@ -86,6 +86,7 @@ TARGETS = $(BASE2SOURCES:.i=) \
 .7i:
        $(ICK) $<
 
+# For instructions on test conventions, see the header comment of regresscheck
 test: $(TARGETS)
        @./beer | ./regresscheck beer 
        @echo 'Hello, sailor!' | ./regresscheck icat 
index c8a3b92da8ee82453351dd21c84f1555a9ea6661..a5ad97b49ab4fb6589e930b08b430576d82eb2ec 100755 (executable)
@@ -1,9 +1,44 @@
 #!/bin/sh
+#
+# regresscheck - test driver for the INTERCAL regression-test suite
+#
+# This script expects to get output from an INTERCAL program to be checked 
+# on its standard input.  Its job is to compare that output against
+# a check file, which is presumably correct.
+#
+# If the program takes input, set up a pipeline with a cat at the beginning ,
+# the INTERCAL executable in the middle, and this script at the end.
+# The convention used by the INTERCAL test suite is that the input load for
+# a program foo is named foo.tst and the check file foo.chk.
+#
+# In normal use this script takes one argument, which is the location of the
+# check file with the trailing .chk extension omitted.  The extension is
+# omitted so that the basename can be used as the name of the program for
+# purposes of reporting success or failure.
+#
+# This pattern doesn't handle well the case where one program has multiple
+# tests, so options are provided to override the test file name 
 
-chkfile=$1
-prog=`basename $chkfile`
+chkfile=""
+while getopts cp opt
+do
+    case $opt in
+       c) chkfile=$OPTARG ;;   # Override the location of the checkfile
+       p) prog=$OPTARG ;;      # Override the name used in reporting
+    esac
+done
+shift $(($OPTIND - 1))
 
-if diff - ${chkfile}.chk
+if [ -z "$chkfile" ]
+then
+    chkfile=${1}.chk
+fi
+if [ -z "$prog" ]
+then
+    prog=`basename $chkfile`
+fi
+
+if diff - ${chkfile}
 then 
      echo "Regression test of $prog succeeded."; 
 else