From: Eric S. Raymond Date: Thu, 26 Aug 2010 21:32:25 +0000 (-0400) Subject: Document the regressioncheck script better, and make it a bit more flexible. X-Git-Tag: 0.29~103 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=f564cc985474fb05b2a510973ae6eecb3f2d6531;p=intercal.git Document the regressioncheck script better, and make it a bit more flexible. --- diff --git a/pit/Makefile b/pit/Makefile index b578587..ef79d0a 100644 --- a/pit/Makefile +++ b/pit/Makefile @@ -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 diff --git a/pit/regresscheck b/pit/regresscheck index c8a3b92..a5ad97b 100755 --- a/pit/regresscheck +++ b/pit/regresscheck @@ -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