From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu From: Fco.J.Ballesteros MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="upas-jjhndsefyetkcvcxccvyyocjrw" Subject: [9fans] silly script to perform regression testing Date: Sat, 18 Oct 2003 02:09:10 +0200 Topicbox-Message-UUID: 736f3af4-eacc-11e9-9e20-41e7f4b1d025 This is a multi-part message in MIME format. --upas-jjhndsefyetkcvcxccvyyocjrw Content-Disposition: inline Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit I thought this might be useful for others, although it's a bit naive. hth --upas-jjhndsefyetkcvcxccvyyocjrw Content-Disposition: attachment; filename=check Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit #!/bin/rc prog=8.out verb=no if (~ $1 -v){ verb=yes shift } switch($#*){ case 0 tests=`{ls [0-9]* >[2]/dev/null | grep -v 'out' | grep -v new} case 1 prog=$1 tests=`{ls [0-9]* >[2]/dev/null | grep -v 'out' | grep -v new} case 2 prog=$1 shift if (test -d $1) tests=`{ls $1/[0-9]* >[2]/dev/null | grep -v 'out$' | grep -v 'new$'} if not tests=$1 case * echo usage: $0 '[-v] [prog [test|testdir]]' >[1=2] exit usage } if (! test -x $prog){ echo $prog ': not executable' >[1=2] exit prog } pname=`{basename $prog} fn fail (){ echo $* >[1=2] exit failed } for ( f in $tests) { what=`{sed 1q $f | grep '^#'} if (! ~ $#what 0) echo test $f : $what if not echo test $f broke|rc kill $pname|rc rm -f $f.new grep '^#!' $f | sed 's/..//' | rc grep -v '^#' $f | $prog $params>$f.new >[2=1] if (test -e $f.out){ diff <{grep -v '^#' $f.out} <{grep -v '^#' $f.new} || { echo ; echo mv $f.new $f.out echo output was: sed 's/^/ /' $f.new fail test $f failed } if (~ $verb yes) sed 's/^/ /' $f.new rm -f $f.new } if not { echo first time for $f if (~ $verb yes) sed 's/^/ /' $f.new mv $f.new $f.out } } echo all tests passed exit 0 --upas-jjhndsefyetkcvcxccvyyocjrw Content-Disposition: attachment; filename=check Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit .TH CHECK 1 .SH NAME check \- check that regression tests pass .SH SYNOPSIS .B check [ .B -v ] [ .I prog [ .I file | .I dir ] ] .SH DESCRIPTION .I Check is an rc script that performs regression testing for a program. It sends input files to the program .I prog (by default .B 8.out ) and compares its output with that of previous runs. It is usual to have one input file per program test. Input files must have names that start with a digit and do not have .B .out or .B .new suffixes. .PP Check executes the program just for .IR file , if given as an argument. It checks all input files in .I dir if given, and all input files in the current directory otherwise. .PP The first time a test is run, it is considered to pass and its output is kept in a file named like the input file but terminated in .BR .out . When a check fails the new output (which differs from the .B .out file) is kept in a file for inspection. This file has the same name of the input file terminated in .BR .new . .PP Input files may contain arbitrary text. Lines starting with .B # are ignored and lines starting with .B #! are executed before starting the check of the input file. This mechanism can be used to prepare the environment for the check. Option .B -v makes the program output more verbose. .PP If the first line of an input file is a comment, check considers that it contains a one-line description of the test performed by the file. That description is printed when the test is run. .SH SOURCE .B /rc/bin/check .SH BUGS Binary input files are not handled properly. --upas-jjhndsefyetkcvcxccvyyocjrw--