2008-01-12 15:47:54 -04:00
|
|
|
#!/bin/bash
|
2007-05-23 14:28:08 -03:00
|
|
|
|
2007-08-20 17:17:57 -03:00
|
|
|
HELP="Usage: ./runtests.py [-h] [-x] [flags] [tests]
|
|
|
|
|
|
|
|
Runs each unit test independently, with output directed to a file in
|
|
|
|
OUT/<test>.out. If no tests are given, all tests are run; otherwise,
|
|
|
|
only the specified tests are run, unless -x is also given, in which
|
|
|
|
case all tests *except* those given are run.
|
|
|
|
|
|
|
|
Standard output shows the name of the tests run, with 'BAD' or
|
|
|
|
'SKIPPED' added if the test didn't produce a positive result. Also,
|
|
|
|
three files are created, named 'BAD', 'GOOD' and 'SKIPPED', to which
|
|
|
|
are written the names of the tests categorized by result.
|
|
|
|
|
|
|
|
Flags (arguments starting with '-') are passed transparently to
|
|
|
|
regrtest.py, except for -x, which is processed here."
|
2007-05-23 14:28:08 -03:00
|
|
|
|
|
|
|
# Choose the Python binary.
|
|
|
|
case `uname` in
|
|
|
|
Darwin) PYTHON=./python.exe;;
|
2007-07-18 13:59:11 -03:00
|
|
|
CYGWIN*) PYTHON=./python.exe;;
|
2007-05-23 14:28:08 -03:00
|
|
|
*) PYTHON=./python;;
|
|
|
|
esac
|
|
|
|
|
2008-10-17 09:05:40 -03:00
|
|
|
PYTHON="$PYTHON -bb"
|
|
|
|
|
2007-08-29 15:15:48 -03:00
|
|
|
# Unset PYTHONPATH, just to be sure.
|
|
|
|
unset PYTHONPATH
|
|
|
|
|
2007-05-23 14:28:08 -03:00
|
|
|
# Create the output directory if necessary.
|
|
|
|
mkdir -p OUT
|
|
|
|
|
|
|
|
# Empty the summary files.
|
|
|
|
>GOOD
|
|
|
|
>BAD
|
|
|
|
>SKIPPED
|
|
|
|
|
2007-08-20 17:17:57 -03:00
|
|
|
# Process flags (transparently pass these on to regrtest.py)
|
|
|
|
FLAGS=""
|
|
|
|
EXCEPT=""
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
case $1 in
|
|
|
|
-h|--h|-help|--help) echo "$HELP"; exit;;
|
|
|
|
--) FLAGS="$FLAGS $1"; shift; break;;
|
|
|
|
-x) EXCEPT="$1"; shift;;
|
|
|
|
-*) FLAGS="$FLAGS $1"; shift;;
|
|
|
|
*) break;;
|
|
|
|
esac
|
|
|
|
done
|
2007-06-11 21:28:30 -03:00
|
|
|
|
2007-05-23 14:28:08 -03:00
|
|
|
# Compute the list of tests to run.
|
2007-08-20 17:17:57 -03:00
|
|
|
case "$#$EXCEPT" in
|
2007-05-23 14:28:08 -03:00
|
|
|
0)
|
2007-06-07 21:07:57 -03:00
|
|
|
TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')`
|
2007-05-23 14:28:08 -03:00
|
|
|
;;
|
2007-08-20 17:17:57 -03:00
|
|
|
*-x)
|
|
|
|
PAT="^(`echo $@ | sed 's/\.py//' | sed 's/ /|/'`)$"
|
|
|
|
TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//' | egrep -v "$PAT")`
|
|
|
|
;;
|
2007-05-23 14:28:08 -03:00
|
|
|
*)
|
|
|
|
TESTS="$@"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Run the tests.
|
|
|
|
for T in $TESTS
|
|
|
|
do
|
|
|
|
echo -n $T
|
2007-07-26 15:43:46 -03:00
|
|
|
if case $T in
|
2007-08-22 18:46:00 -03:00
|
|
|
*curses*)
|
|
|
|
echo
|
|
|
|
$PYTHON -E Lib/test/regrtest.py $FLAGS $T 2>OUT/$T.out
|
|
|
|
;;
|
|
|
|
*) $PYTHON -E Lib/test/regrtest.py $FLAGS $T >OUT/$T.out 2>&1;;
|
2007-07-26 15:43:46 -03:00
|
|
|
esac
|
2007-05-23 14:28:08 -03:00
|
|
|
then
|
2007-08-20 17:17:57 -03:00
|
|
|
if grep -q "1 test skipped:" OUT/$T.out
|
|
|
|
then
|
|
|
|
echo " SKIPPED"
|
2007-05-23 14:28:08 -03:00
|
|
|
echo $T >>SKIPPED
|
2007-08-20 17:17:57 -03:00
|
|
|
else
|
|
|
|
echo
|
2007-05-23 14:28:08 -03:00
|
|
|
echo $T >>GOOD
|
2007-08-20 17:17:57 -03:00
|
|
|
fi
|
2007-05-23 14:28:08 -03:00
|
|
|
else
|
2007-08-20 17:17:57 -03:00
|
|
|
echo " BAD"
|
2007-05-23 14:28:08 -03:00
|
|
|
echo $T >>BAD
|
|
|
|
fi
|
|
|
|
done
|
2007-08-20 17:17:57 -03:00
|
|
|
|
|
|
|
# Summarize results
|
|
|
|
wc -l BAD GOOD SKIPPED
|