blob: 48b9858315b3f6554d06c334d50431dcc47ae3c6 [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
Guido van Rossume53309c2007-05-23 17:28:08 +000018# Choose the Python binary.
19case `uname` in
20Darwin) PYTHON=./python.exe;;
Guido van Rossum5ed317d2007-07-18 16:59:11 +000021CYGWIN*) PYTHON=./python.exe;;
Guido van Rossume53309c2007-05-23 17:28:08 +000022*) PYTHON=./python;;
23esac
24
25# Create the output directory if necessary.
26mkdir -p OUT
27
28# Empty the summary files.
29>GOOD
30>BAD
31>SKIPPED
32
Guido van Rossum360f2f82007-08-20 20:17:57 +000033# Process flags (transparently pass these on to regrtest.py)
34FLAGS=""
35EXCEPT=""
36while :
37do
38 case $1 in
39 -h|--h|-help|--help) echo "$HELP"; exit;;
40 --) FLAGS="$FLAGS $1"; shift; break;;
41 -x) EXCEPT="$1"; shift;;
42 -*) FLAGS="$FLAGS $1"; shift;;
43 *) break;;
44 esac
45done
Guido van Rossum53970392007-06-12 00:28:30 +000046
Guido van Rossume53309c2007-05-23 17:28:08 +000047# Compute the list of tests to run.
Guido van Rossum360f2f82007-08-20 20:17:57 +000048case "$#$EXCEPT" in
Guido van Rossume53309c2007-05-23 17:28:08 +0000490)
Guido van Rossum2bf71382007-06-08 00:07:57 +000050 TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')`
Guido van Rossume53309c2007-05-23 17:28:08 +000051 ;;
Guido van Rossum360f2f82007-08-20 20:17:57 +000052*-x)
53 PAT="^(`echo $@ | sed 's/\.py//' | sed 's/ /|/'`)$"
54 TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//' | egrep -v "$PAT")`
55 ;;
Guido van Rossume53309c2007-05-23 17:28:08 +000056*)
57 TESTS="$@"
58 ;;
59esac
60
61# Run the tests.
62for T in $TESTS
63do
64 echo -n $T
Guido van Rossum97a7f1e2007-07-26 18:43:46 +000065 if case $T in
Guido van Rossuma62b45c2007-08-22 21:46:00 +000066 *curses*)
67 echo
68 $PYTHON -E Lib/test/regrtest.py $FLAGS $T 2>OUT/$T.out
69 ;;
70 *) $PYTHON -E 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