tests/run-tests
author Thomas Arendsen Hein <thomas@intevation.de>
Tue, 28 Jun 2005 07:05:55 +0100
changeset 494 6020bde714e4
parent 473 5914e27dc717
child 488 77c66c4eec0e
child 495 e94cebc60d96
permissions -rwxr-xr-x
Fixed test for previous change of 'hg -v history'. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Fixed test for previous change of 'hg -v history'. manifest hash: 5a7d918645596751577b95d0dfba28fd70274b48 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFCwOjDW7P1GVgWeRoRAvL7AJwO27B6qhOZZC+16SPjIxJBKz3BSwCghmkB OMzLY0CjZSHixF5xs0ZU6Dw= =F04F -----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
473
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
     9
if [ -d /usr/lib64 ]; then
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    10
    lib=lib64
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    11
else
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    12
    lib=lib
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    13
fi
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    14
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    15
TESTPATH=$PWD/install/bin
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    16
export PATH=$TESTPATH:$PATH
473
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    17
export PYTHONPATH=$PWD/install/$lib/python
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    18
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    19
rm -rf install
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    20
cd ..
398
7ed217cfae9e Quiet successful test install in run-tests
mpm@selenic.com
parents: 397
diff changeset
    21
${PYTHON:-python} setup.py install --home=tests/install > tests/install.err
7ed217cfae9e Quiet successful test install in run-tests
mpm@selenic.com
parents: 397
diff changeset
    22
if [ $? != 0 ] ; then
7ed217cfae9e Quiet successful test install in run-tests
mpm@selenic.com
parents: 397
diff changeset
    23
    cat tests/install.err
7ed217cfae9e Quiet successful test install in run-tests
mpm@selenic.com
parents: 397
diff changeset
    24
fi
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    25
cd $H
398
7ed217cfae9e Quiet successful test install in run-tests
mpm@selenic.com
parents: 397
diff changeset
    26
rm install.err
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    27
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    28
function run_one
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    29
{
399
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    30
    rm -f $1.err
382
37249c522770 test suite: fix timezone problems and port collision problem
mpm@selenic.com
parents: 362
diff changeset
    31
    export TZ=GMT
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    32
    D=`mktemp -d`
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    33
    if [ "$D" == "" ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    34
	echo mktemp failed!
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 $D
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    38
    fail=0
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    39
399
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    40
    if ! $H/$1 > .out 2>&1 ; then
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    41
	echo $1 failed with error code $?
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    42
	fail=1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    43
    fi
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    44
399
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    45
    if [ -s .out -a ! -r $H/$1.out ] ; then
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    46
	echo $1 generated unexpected output:
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    47
	cat .out
399
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    48
	cp .out $H/$1.err
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    49
	fail=1
399
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    50
    elif [ -r $H/$1.out ] && ! diff -u $H/$1.out .out > /dev/null ; then
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    51
	echo $1 output changed:
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    52
	diff -u $H/$1.out .out && true
f060d728fe54 Delete error logs one test at a time
mpm@selenic.com
parents: 398
diff changeset
    53
	cp .out $H/$1.err
341
c0deea64ce64 run-tests: actually mark changed output as failure
mpm@selenic.com
parents: 331
diff changeset
    54
	fail=1
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    55
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    56
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    57
    cd $H
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    58
    rm -r $D
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    59
    return $fail
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    60
}
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    61
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    62
TESTS=$@
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    63
if [ "$TESTS" == "" ] ; then
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    64
    TESTS=`ls test-* | grep -Ev "\.|~"`
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    65
fi
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    66
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    67
for f in $TESTS ; do
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    68
    echo -n "."
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    69
    if ! run_one $f ; then
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    70
	failed=$[$failed + 1]
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    71
    fi
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    72
    tests=$[$tests + 1]
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    73
done
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    74
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    75
rm -rf install
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    76
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    77
echo
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    78
echo Ran $tests tests, $failed failed
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    79
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    80
if [ $failed -gt 0 ] ; then
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    81
    exit 1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    82
fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    83