view test/runtests.sh @ 387:a741d2e4869f

Various bugfixes; fixed lwobjdump to display symbols with unprintable characters more sensibly; start of a (nonfunctional for now) testing framework
author lost@l-w.ca
date Wed, 14 Jul 2010 20:15:23 -0600
parents
children
line wrap: on
line source

#!/bin/bash
#
# run the various tests under the tests/ folder recursively

function runtests()
{
	local fn
	local base="$2"
	local odir=`pwd`
	local dir="$1"
	
	cd "$dir"

	for fn in *.t; do
		if [ -d "$fn" ]; then
			echo "Running tests in $base/$fn"
			runtests "$fn" "$base/$fn"
		elif [ -r "$fn" ]; then
			echo "Running test $fn"
			testcount=$(($testcount+1))
			TESTSTATE=failed
			source "$fn"
			if [ "$TESTSTATE" = ok ]; then
				testpassed=$(($testpassed+1))
			else
				testfailed=$(($testfailed+1))
			fi
		fi
	done
	
	cd "$odir"
}

testcount=0
testfailed=0
testpassed=0

dir="$1"
if [ "x$dir" = "x" ]; then
	dir=.
fi

runtests "$dir" "$dir"

echo "Passed $testpassed tests of $testcount"
if [ "$testfailed" -ne 0 ]; then
	echo "Failed $testfailed of $testcount tests!"
	exit 1
fi
exit 0