tests/run-tests
author mpm@selenic.com
Wed, 15 Jun 2005 15:50:28 -0800
changeset 362 410373162036
parent 350 b4e0e20646bb
child 382 37249c522770
permissions -rwxr-xr-x
run-tests: run tests given on the command line -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 run-tests: run tests given on the command line manifest hash: e0217e478de902d0de7b9a294509718365f1d837 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsL7EywK+sNU5EO8RAiGJAJ92ZB/+N8+XnOt717cuADK9ajQ+lwCfW1LG 02mjQ04uoS0n+D8xi0KX9tM= =d1lZ -----END PGP SIGNATURE-----

#!/bin/bash

set -e

tests=0
failed=0
H=$PWD

function run_one
{
    D=`mktemp -d`
    if [ "$D" == "" ] ; then
	echo mktemp failed!
    fi

    cd $D
    fail=0

    if ! $H/$f > .out 2>&1 ; then
	echo $f failed with error code $?
	fail=1
    fi

    if [ -s .out -a ! -r $H/$f.out ] ; then
	echo $f generated unexpected output:
	cat .out
	cp .out $H/$f.err
	fail=1
    elif [ -r $H/$f.out ] && ! diff -u $H/$f.out .out > /dev/null ; then
	echo $f output changed:
	diff -u $H/$f.out .out && true
	cp .out $H/$f.err
	fail=1
    fi

    cd $H
    rm -r $D
    return $fail
}

TESTS=$@
if [ "$TESTS" == "" ] ; then
    TESTS=`ls test-* | grep -Ev "\.|~"`
fi

for f in $TESTS ; do
    echo -n "."
    if ! run_one $f ; then
	failed=$[$failed + 1]
    fi
    tests=$[$tests + 1]
done

echo
echo Ran $tests tests, $failed failed

if [ $failed -gt 0 ] ; then
    exit 1
fi