blob: 5d31276a219f6d1d6729b8c6912db1b925aa8d4d [file] [log] [blame]
Guido van Rossume53309c2007-05-23 17:28:08 +00001#!/bin/sh
2
Guido van Rossum360f2f82007-08-20 20:17:57 +00003HELP="Usage: ./runtests.py [-h] [-x] [flags] [tests]
4
5Runs each unit test independently, with output directed to a file in
6OUT/<test>.out. If no tests are given, all tests are run; otherwise,
7only the specified tests are run, unless -x is also given, in which
8case all tests *except* those given are run.
9
10Standard output shows the name of the tests run, with 'BAD' or
11'SKIPPED' added if the test didn't produce a positive result. Also,
12three files are created, named 'BAD', 'GOOD' and 'SKIPPED', to which
13are written the names of the tests categorized by result.
14
15Flags (arguments starting with '-') are passed transparently to
16regrtest.py, except for -x, which is processed here."
Guido van Rossume53309c2007-05-23 17:28:08 +000017
18# Reset PYTHONPATH to avoid alien influences on the tests.
19unset PYTHONPATH
20
21# Choose the Python binary.
22case `uname` in
23Darwin) PYTHON=./python.exe;;
Guido van Rossum5ed317d2007-07-18 16:59:11 +000024CYGWIN*) PYTHON=./python.exe;;
Guido van Rossume53309c2007-05-23 17:28:08 +000025*) PYTHON=./python;;
26esac
27
28# Create the output directory if necessary.
29mkdir -p OUT
30
31# Empty the summary files.
32>GOOD
33>BAD
34>SKIPPED
35
Guido van Rossum360f2f82007-08-20 20:17:57 +000036# Process flags (transparently pass these on to regrtest.py)
37FLAGS=""
38EXCEPT=""
39while :
40do
41 case $1 in
42 -h|--h|-help|--help) echo "$HELP"; exit;;
43 --) FLAGS="$FLAGS $1"; shift; break;;
44 -x) EXCEPT="$1"; shift;;
45 -*) FLAGS="$FLAGS $1"; shift;;
46 *) break;;
47 esac
48done
Guido van Rossum53970392007-06-12 00:28:30 +000049
Guido van Rossume53309c2007-05-23 17:28:08 +000050# Compute the list of tests to run.
Guido van Rossum360f2f82007-08-20 20:17:57 +000051case "$#$EXCEPT" in
Guido van Rossume53309c2007-05-23 17:28:08 +0000520)
Guido van Rossum2bf71382007-06-08 00:07:57 +000053 TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')`
Guido van Rossume53309c2007-05-23 17:28:08 +000054 ;;
Guido van Rossum360f2f82007-08-20 20:17:57 +000055*-x)
56 PAT="^(`echo $@ | sed 's/\.py//' | sed 's/ /|/'`)$"
57 TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//' | egrep -v "$PAT")`
58 ;;
Guido van Rossume53309c2007-05-23 17:28:08 +000059*)
60 TESTS="$@"
61 ;;
62esac
63
64# Run the tests.
65for T in $TESTS
66do
67 echo -n $T
Guido van Rossum97a7f1e2007-07-26 18:43:46 +000068 if case $T in
Guido van Rossum360f2f82007-08-20 20:17:57 +000069 *curses*) echo; $PYTHON Lib/test/regrtest.py $FLAGS $T 2>OUT/$T.out;;
70 *) $PYTHON Lib/test/regrtest.py $FLAGS $T >OUT/$T.out 2>&1;;
Guido van Rossum97a7f1e2007-07-26 18:43:46 +000071 esac
Guido van Rossume53309c2007-05-23 17:28:08 +000072 then
Guido van Rossum360f2f82007-08-20 20:17:57 +000073 if grep -q "1 test skipped:" OUT/$T.out
74 then
75 echo " SKIPPED"
Guido van Rossume53309c2007-05-23 17:28:08 +000076 echo $T >>SKIPPED
Guido van Rossum360f2f82007-08-20 20:17:57 +000077 else
78 echo
Guido van Rossume53309c2007-05-23 17:28:08 +000079 echo $T >>GOOD
Guido van Rossum360f2f82007-08-20 20:17:57 +000080 fi
Guido van Rossume53309c2007-05-23 17:28:08 +000081 else
Guido van Rossum360f2f82007-08-20 20:17:57 +000082 echo " BAD"
Guido van Rossume53309c2007-05-23 17:28:08 +000083 echo $T >>BAD
Guido van Rossume53309c2007-05-23 17:28:08 +000084 fi
85done
Guido van Rossum360f2f82007-08-20 20:17:57 +000086
87# Summarize results
88wc -l BAD GOOD SKIPPED