tests/run-tests
author mpm@selenic.com
Thu, 16 Jun 2005 22:32:55 -0800
changeset 383 4862a134e2c2
parent 382 37249c522770
child 397 e5683db23ec4
child 429 688d03d6997a
permissions -rwxr-xr-x
hg merge: fix time asymmetry bug with deleting files on update to past -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hg merge: fix time asymmetry bug with deleting files on update to past manifest hash: 41feb7bf9b56e071a538a0918224898acb2bd31c -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCsm6XywK+sNU5EO8RAncbAKCwn/W4cr6civp4Zt79JFH6um0/lQCdFCh8 F7ZOQ+S/PL3HL4iE6avOBDc= =kHPm -----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
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
     9
function run_one
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    10
{
382
37249c522770 test suite: fix timezone problems and port collision problem
mpm@selenic.com
parents: 362
diff changeset
    11
    export TZ=GMT
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    12
    D=`mktemp -d`
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    13
    if [ "$D" == "" ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    14
	echo mktemp failed!
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    15
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    16
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    17
    cd $D
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    18
    fail=0
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    19
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    20
    if ! $H/$f > .out 2>&1 ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    21
	echo $f failed with error code $?
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    22
	fail=1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    23
    fi
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    24
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    25
    if [ -s .out -a ! -r $H/$f.out ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    26
	echo $f generated unexpected output:
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    27
	cat .out
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    28
	cp .out $H/$f.err
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    29
	fail=1
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    30
    elif [ -r $H/$f.out ] && ! diff -u $H/$f.out .out > /dev/null ; then
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    31
	echo $f output changed:
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    32
	diff -u $H/$f.out .out && true
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    33
	cp .out $H/$f.err
341
c0deea64ce64 run-tests: actually mark changed output as failure
mpm@selenic.com
parents: 331
diff changeset
    34
	fail=1
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    35
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    36
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    37
    cd $H
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    38
    rm -r $D
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    39
    return $fail
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    40
}
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    41
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    42
TESTS=$@
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    43
if [ "$TESTS" == "" ] ; then
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    44
    TESTS=`ls test-* | grep -Ev "\.|~"`
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    45
fi
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    46
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    47
for f in $TESTS ; do
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    48
    echo -n "."
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    49
    if ! run_one $f ; then
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    50
	failed=$[$failed + 1]
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    51
    fi
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    52
    tests=$[$tests + 1]
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    53
done
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    54
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    55
echo
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    56
echo Ran $tests tests, $failed failed
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    57
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    58
if [ $failed -gt 0 ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    59
    exit 1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    60
fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    61