tests/run-tests
author mpm@selenic.com
Tue, 21 Jun 2005 17:19:12 -0800
changeset 397 e5683db23ec4
parent 382 37249c522770
child 398 7ed217cfae9e
permissions -rwxr-xr-x
From: Andrew Thompson <andrewkt@aktzero.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 From: Andrew Thompson <andrewkt@aktzero.com> Make a local temporary install of hg for running tests Delete old error files before running tests manifest hash: bbae21d506ce5be8df5dc97f14fcd0f8aece0b20 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuLyQywK+sNU5EO8RAvROAJ93xEPZNphcpoLxGCMNkZ7SfL6+AQCfXCHZ 3kMQAuZnxo0dn98of/LVecY= =bsV2 -----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
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
     9
TESTPATH=$PWD/install/bin
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    10
export PATH=$TESTPATH:$PATH
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    11
export PYTHONPATH=$PWD/install/lib/python
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    12
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    13
rm -rf install
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    14
cd ..
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    15
${PYTHON:-python} setup.py install --home=tests/install
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    16
cd $H
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    17
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    18
function run_one
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    19
{
382
37249c522770 test suite: fix timezone problems and port collision problem
mpm@selenic.com
parents: 362
diff changeset
    20
    export TZ=GMT
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    21
    D=`mktemp -d`
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    22
    if [ "$D" == "" ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    23
	echo mktemp failed!
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    24
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    25
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    26
    cd $D
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    27
    fail=0
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    28
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    29
    if ! $H/$f > .out 2>&1 ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    30
	echo $f failed with error code $?
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    31
	fail=1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    32
    fi
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    33
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    34
    if [ -s .out -a ! -r $H/$f.out ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    35
	echo $f generated unexpected output:
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    36
	cat .out
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    37
	cp .out $H/$f.err
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    38
	fail=1
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    39
    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
    40
	echo $f output changed:
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    41
	diff -u $H/$f.out .out && true
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    42
	cp .out $H/$f.err
341
c0deea64ce64 run-tests: actually mark changed output as failure
mpm@selenic.com
parents: 331
diff changeset
    43
	fail=1
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    44
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    45
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    46
    cd $H
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    47
    rm -r $D
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    48
    return $fail
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    49
}
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    50
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    51
TESTS=$@
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    52
if [ "$TESTS" == "" ] ; then
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    53
    TESTS=`ls test-* | grep -Ev "\.|~"`
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    54
fi
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    55
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    56
rm -f test-*.err
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    57
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    58
for f in $TESTS ; do
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    59
    echo -n "."
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    60
    if ! run_one $f ; then
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    61
	failed=$[$failed + 1]
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    62
    fi
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    63
    tests=$[$tests + 1]
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    64
done
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    65
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    66
rm -rf install
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    67
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    68
echo
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    69
echo Ran $tests tests, $failed failed
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    70
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    71
if [ $failed -gt 0 ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    72
    exit 1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    73
fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    74