#!/bin/bash # Usage: test-correct INPUTFILE.tx ... # Run each INPUTFILE through the program, checking the result against # the standard output INPUTFILE.std. Reports number of failures. # Exits with 0 iff there are no errors. prog="java -ea tex61.Main" out="/tmp/tex61$$.out" normalize=$(dirname $0)/normalize trap 'rm -rf $out' 0 SIGHUP SIGINT SIGTERM tests=0 errs=0 problems=0 for f in "$@"; do name="$(basename $f .tx)" if [ ! -f $f ]; then continue fi echo -n $name... tests=$(($tests + 1)) rm -rf $out std="$(dirname $f)/${name}.std" if $prog $f $out; then if [ ! -f $std ]; then echo "PROBLEM ($std missing)" problems=$(($problems + 1)) elif diff <($normalize $out) <($normalize $std) >/dev/null 2>&1; then echo OK else echo "FAILED (wrong output)" errs=$(($errs + 1)) fi else echo "FAILED (error during execution)" errs=$(($errs + 1)) fi done echo -n "Out of $tests tests:" if [ $errs -eq 0 -a $problems -eq 0 ]; then echo " all passed" exit 0 elif [ $problems -eq 0 ]; then echo " $errs failures" exit 1 else echo " $errs failures, $problems problems" exit 1 fi