tests/run-tests
author Thomas Arendsen Hein <thomas@intevation.de>
Fri, 29 Jul 2005 21:50:05 +0100
changeset 804 19388dcbac49
parent 803 3d47e7fc33a3
child 808 8f5637f0a0c0
permissions -rwxr-xr-x
Incorporated most of Aron Griffis suggestions for sh compatibility.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
544
3d4d5f2aba9a Remove bashisms and use /bin/sh instead of /bin/bash.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 495
diff changeset
     1
#!/bin/sh -e
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
     2
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
     3
LANG="C"; export LANG
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
     4
LC_CTYPE="C"; export LC_CTYPE
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
     5
LC_NUMERIC="C"; export LC_NUMERIC
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
     6
LC_TIME="C"; export LC_TIME
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
     7
LC_COLLATE="C"; export LC_COLLATE
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
     8
LC_MONETARY="C"; export LC_MONETARY
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
     9
LC_MESSAGES="C"; export LC_MESSAGES
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    10
LC_PAPER="C"; export LC_PAPER
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    11
LC_NAME="C"; export LC_NAME
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    12
LC_ADDRESS="C"; export LC_ADDRESS
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    13
LC_TELEPHONE="C"; export LC_TELEPHONE
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    14
LC_MEASUREMENT="C"; export LC_MEASUREMENT
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    15
LC_IDENTIFICATION="C"; export LC_IDENTIFICATION
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    16
LC_ALL=""; export LC_ALL
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    17
TZ=GMT; export TZ
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    18
HGEDITOR=true; export HGEDITOR
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    19
HGMERGE=true; export HGMERGE
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    20
HGUSER="test"; export HGUSER
488
77c66c4eec0e [PATCH] Set locale before run-tests does anything
mpm@selenic.com
parents: 473
diff changeset
    21
489
a636f7d2cd5b [PATCH] umask for run-tests
mpm@selenic.com
parents: 488
diff changeset
    22
umask 022
a636f7d2cd5b [PATCH] umask for run-tests
mpm@selenic.com
parents: 488
diff changeset
    23
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    24
tests=0
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    25
failed=0
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    26
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    27
HGTMP=""
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    28
cleanup_exit() {
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    29
    rm -rf "$HGTMP"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    30
    exit $1
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    31
}
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    32
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    33
# Remove temporary files even if we get interrupted
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    34
trap "cleanup_exit 255" TERM KILL INT QUIT ABRT
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    35
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    36
HGTMP="${TMPDIR-/tmp}/hgtests.$RANDOM.$RANDOM.$RANDOM.$$"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    37
(umask 077 && mkdir "$HGTMP") || {
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    38
    echo "Could not create temporary directory! Exiting." 1>&2
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    39
    exit 1
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    40
}
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    41
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    42
TESTDIR="$PWD"
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    43
473
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    44
if [ -d /usr/lib64 ]; then
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    45
    lib=lib64
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    46
else
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    47
    lib=lib
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    48
fi
5914e27dc717 [PATCH] Get run-tests working on 64-bit machines.
mpm@selenic.com
parents: 429
diff changeset
    49
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    50
INST="$HGTMP/install"
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    51
cd ..
804
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
    52
if ${PYTHON-python} setup.py install --home="$INST" > tests/install.err 2>&1
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    53
then
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    54
    rm tests/install.err
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    55
    mv "$INST/bin/hg" "$INST/bin/hg.real"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    56
    (
803
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
    57
	echo '#!/bin/sh'
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
    58
	echo 'echo "+ hg $@"'
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
    59
	echo 'exec hg.real "$@"'
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    60
    ) > "$INST/bin/hg"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    61
    chmod 755 "$INST/bin/hg"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    62
else
398
7ed217cfae9e Quiet successful test install in run-tests
mpm@selenic.com
parents: 397
diff changeset
    63
    cat tests/install.err
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    64
    cleanup_exit 1
398
7ed217cfae9e Quiet successful test install in run-tests
mpm@selenic.com
parents: 397
diff changeset
    65
fi
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    66
cd "$TESTDIR"
397
e5683db23ec4 From: Andrew Thompson <andrewkt@aktzero.com>
mpm@selenic.com
parents: 382
diff changeset
    67
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    68
PATH="$INST/bin:$PATH"; export PATH
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    69
PYTHONPATH="$INST/$lib/python"; export PYTHONPATH
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    70
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    71
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    72
run_one() {
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    73
    rm -f "$1.err"
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    74
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    75
    mkdir "$HGTMP/$1"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    76
    cd "$HGTMP/$1"
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    77
    fail=0
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    78
    HOME="$HGTMP/$1"; export HOME
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    79
    OUT="$HGTMP/$1.out"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    80
    OUTOK="$TESTDIR/$1.out"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    81
    ERR="$TESTDIR/$1.err"
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    82
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    83
    if "$TESTDIR/$1" > "$OUT" 2>&1; then
803
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
    84
	: no error
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    85
    else
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    86
	echo "$1 failed with error code $?"
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    87
	fail=1
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    88
    fi
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
    89
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    90
    if [ -s "$OUT" -a ! -s "$OUTOK" ] ; then
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    91
	cp "$OUT" "$ERR"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    92
	echo
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    93
	echo "$1 generated unexpected output:"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    94
	cat "$ERR"
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
    95
	fail=1
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
    96
    elif [ -r "$OUTOK" ]; then
803
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
    97
	if diff -u "$OUTOK" "$OUT" > /dev/null; then
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
    98
	    : no differences
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
    99
	else
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   100
	    if FIXME="`grep 'FIXME' \"$TESTDIR/$1\"`"; then
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   101
		echo
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   102
		echo "$1 failed, but this is ignored because of:"
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   103
		echo "$FIXME"
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   104
	    else
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   105
		cp "$OUT" "$ERR"
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   106
		echo
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   107
		echo "$1 output changed:"
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   108
		diff -u "$OUTOK" "$ERR" || true
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   109
		fail=1
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   110
	    fi
3d47e7fc33a3 Use tabs instead of spaces where apropriate.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 802
diff changeset
   111
	fi
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
   112
    fi
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
   113
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
   114
    cd "$TESTDIR"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
   115
    rm -f "$HGTMP/$1.out"
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
   116
    rm -rf "$HGTMP/$1"
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
   117
    return $fail
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
   118
}
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
   119
804
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
   120
TESTS="$*"
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
   121
if [ -z "$TESTS" ] ; then
804
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
   122
    TESTS=`ls test-* | grep -v "[.~]"`
362
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
   123
fi
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
   124
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
   125
for f in $TESTS ; do
410373162036 run-tests: run tests given on the command line
mpm@selenic.com
parents: 350
diff changeset
   126
    echo -n "."
804
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
   127
    run_one $f || failed=`expr $failed + 1`
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
   128
    tests=`expr $tests + 1`
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
   129
done
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
   130
804
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
   131
echo
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
   132
echo "Ran $tests tests, $failed failed."
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
   133
804
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
   134
if [ $failed -gt 0 ] ; then
19388dcbac49 Incorporated most of Aron Griffis suggestions for sh compatibility.
Thomas Arendsen Hein <thomas@intevation.de>
parents: 803
diff changeset
   135
    cleanup_exit 1
331
55f63f3b6a54 Add a simple testing framework
mpm@selenic.com
parents:
diff changeset
   136
fi
798
c28f9feb7c2e Make tests work on Solaris:
Thomas Arendsen Hein <thomas@intevation.de>
parents: 793
diff changeset
   137
cleanup_exit 0