0
0
mirror of https://github.com/python/cpython.git synced 2024-11-25 01:20:47 +01:00
cpython/runtests.sh

92 lines
2.1 KiB
Bash
Raw Normal View History

#!/bin/bash
2007-05-23 19:28:08 +02: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 19:28:08 +02:00
# Choose the Python binary.
case `uname` in
Darwin) PYTHON=./python.exe;;
2007-07-18 18:59:11 +02:00
CYGWIN*) PYTHON=./python.exe;;
2007-05-23 19:28:08 +02:00
*) PYTHON=./python;;
esac
2007-08-29 20:15:48 +02:00
# Unset PYTHONPATH, just to be sure.
unset PYTHONPATH
2007-05-23 19:28:08 +02:00
# Create the output directory if necessary.
mkdir -p OUT
# Empty the summary files.
>GOOD
>BAD
>SKIPPED
# 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-05-23 19:28:08 +02:00
# Compute the list of tests to run.
case "$#$EXCEPT" in
2007-05-23 19:28:08 +02:00
0)
TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')`
2007-05-23 19:28:08 +02: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 19:28:08 +02:00
*)
TESTS="$@"
;;
esac
# Run the tests.
for T in $TESTS
do
echo -n $T
if case $T in
*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;;
esac
2007-05-23 19:28:08 +02:00
then
if grep -q "1 test skipped:" OUT/$T.out
then
echo " SKIPPED"
2007-05-23 19:28:08 +02:00
echo $T >>SKIPPED
else
echo
2007-05-23 19:28:08 +02:00
echo $T >>GOOD
fi
2007-05-23 19:28:08 +02:00
else
echo " BAD"
2007-05-23 19:28:08 +02:00
echo $T >>BAD
fi
done
# Summarize results
wc -l BAD GOOD SKIPPED