diff options
Diffstat (limited to 't/testsuite')
-rwxr-xr-x | t/testsuite | 139 |
1 files changed, 0 insertions, 139 deletions
diff --git a/t/testsuite b/t/testsuite deleted file mode 100755 index bd870ce..0000000 --- a/t/testsuite +++ /dev/null @@ -1,139 +0,0 @@ -#! /bin/sh -# testsuite for runcap - run program and capture its output -# Copyright (C) 2017 Sergey Poznyakoff -# -# Runcap is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# Runcap is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with Runcap. If not, see <http://www.gnu.org/licenses/>. - -testdir=$(cd $(dirname $0); pwd) -progname=$(basename $0) - -topworkdir=$(pwd) -workdir=$topworkdir/testsuite.dir -if [ ! -d $workdir ]; then - mkdir $workdir -fi - -cd $testdir -numfiles=$(ls -1 *.t 2>/dev/null| sed -n '$=') - -if [ ${numfiles:-0} -eq 0 ]; then - echo >&2 "$progname: no test files in $testdir" - exit 2 -fi - -printheader() { - awk -v P=$numfiles 'NR==1 { num=$1; next } - NR==2 { printf("%0d: %s", num, $1); next } - { if (NF!=0) printf(" - %s", $0); - printf(": "); }' <<EOF -$1 -$2 -$3 -EOF -} - -PATH=$topworkdir:$PATH -echo $PATH -TC_EXPECT() { - cat > exp$1 -} -TC_TITLE() { - : -} - -numtests=0 -numfail=0 -cd $testdir -exec 3>$topworkdir/testsuite.log - -if [ $# -gt 0 ]; then - testlist=$(ls $*) || exit 1 -else - testlist=$(ls *.t) -fi - -for tc in $testlist -do - cd $testdir - tc=$(echo $tc|sed 's|\./||') - # Skip if invalid name - echo "$tc" | grep -q '[^a-zA-Z0-9._-]' && continue - # Skip if not executable - test -x $tc || continue - - cd $workdir - - dirname=${tc%%.t} - if [ -d $dirname ]; then - rm -rf $dirname/* - else - mkdir $dirname || continue - fi - cd $dirname - - descr=$(sed -n '/TC_TITLE /s///p' $testdir/$tc) - printheader $numtests $tc "$descr" - ( . $testdir/$tc ) >out 2>err - retcode=$? - numtests=$(( $numtests + 1 )) - cd $workdir - - exec 4>templog - if [ $retcode -eq 77 ]; then - echo "SKIP" - continue - fi - if [ $retcode -ne 0 ]; then - echo >&4 "# exit code: $retcode" - fi - - test -r $dirname/expout || > $dirname/expout - if ! cmp $dirname/expout $dirname/out 2>/dev/null >&2; then - echo >&4 "# stdout diff" - diff -pu $dirname/expout $dirname/out >&4 - fi - test -r $dirname/experr || > $dirname/experr - if ! cmp $dirname/experr $dirname/err 2>/dev/null >&2; then - echo >&4 "# stderr diff" - diff -pu $dirname/experr $dirname/err >&4 - fi - - if [ -s templog ]; then - echo "FAIL" - numfail=$(( $numfail + 1 )) - echo >&3 "# Testcase $tc FAILED" - cat >&3 templog - echo >&3 "# Content:" - cat >&3 $testdir/$tc - echo >&3 "# stdout:" - cat >&3 $dirname/out - echo >&3 "# stderr:" - cat >&3 $dirname/err - else - echo "OK" - rm -rf $dirname - fi - rm templog -done - -cd $topworkdir - -if [ $numfail -ne 0 ]; then - echo >&2 "# $numfail out of $numtests tests failed" - echo >&2 "# See testsuite.log for more info" - exit 1 -else - rmdir $workdir 2>/dev/null - rm testsuite.log -fi |