tests/run-tests
author Thomas Arendsen Hein <thomas@intevation.de>
Wed, 15 Jun 2005 08:32:29 +0100
changeset 349 b2293093b89e
parent 331 55f63f3b6a54
child 350 b4e0e20646bb
permissions -rwxr-xr-x
Merged with mercurial-identify (which includes upstream's current tip) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Merged with mercurial-identify (which includes upstream's current tip) manifest hash: b135d201757b84bbe7f14a446d2b001fd0cc1aa2 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCr9mNW7P1GVgWeRoRAmTjAJ919wnvZXbKI27N0cDJCrumR3z4rQCcD6PO yZTmrT6p+gt6GBO+j5FVBn0= =HWn8 -----END PGP SIGNATURE-----
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     1
#!/bin/bash
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     2
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     3
set -e
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     4
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     5
tests=0
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     6
failed=0
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     7
H=$PWD
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     8
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     9
for f in `ls test-* | grep -Ev "\.|~"` ; do
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    10
    echo -n "."
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    11
    D=`mktemp -d`
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    12
    if [ "$D" == "" ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    13
	echo mktemp failed!
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    14
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    15
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    16
    cd $D
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    17
    fail=0
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    18
    if ! $H/$f > .out 2>&1 ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    19
	echo $f failed with error code $?
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    20
	fail=1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    21
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    22
    if [ -s .out -a ! -r $H/$f.out ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    23
	echo $f generated unexpected output:
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    24
	cat .out
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    25
	cp .out $H/$f.err
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    26
	fail=1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    27
    elif ! diff -u $H/$f.out .out > /dev/null ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    28
	echo $f output changed:
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    29
	diff -u $H/$f.out .out && true
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    30
	cp .out $H/$f.err
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    31
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    32
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    33
    cd $H
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    34
    rm -r $D
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    35
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    36
    failed=$[$failed + $fail]
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    37
    tests=$[$tests + 1]
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    38
done
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    39
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    40
echo
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    41
echo Ran $tests tests, $failed failed
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    42
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    43
if [ $failed -gt 0 ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    44
    exit 1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    45
fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    46