11#! /bin/sh
22
3- # A script that runs each unit test independently, with output
4- # directed to a file in OUT/$T.out. If command line arguments are
5- # given, they are tests to run; otherwise every file named
6- # Lib/test/test_* is run (via regrtest). A summary of failing,
7- # passing and skipped tests is written to stdout and to the files
8- # GOOD, BAD and SKIPPED.
3+ HELP=" Usage: ./runtests.py [-h] [-x] [flags] [tests]
4+
5+ Runs each unit test independently, with output directed to a file in
6+ OUT/<test>.out. If no tests are given, all tests are run; otherwise,
7+ only the specified tests are run, unless -x is also given, in which
8+ case all tests *except* those given are run.
9+
10+ Standard output shows the name of the tests run, with 'BAD' or
11+ 'SKIPPED' added if the test didn't produce a positive result. Also,
12+ three files are created, named 'BAD', 'GOOD' and 'SKIPPED', to which
13+ are written the names of the tests categorized by result.
14+
15+ Flags (arguments starting with '-') are passed transparently to
16+ regrtest.py, except for -x, which is processed here."
917
1018# Reset PYTHONPATH to avoid alien influences on the tests.
1119unset PYTHONPATH
@@ -25,20 +33,29 @@ mkdir -p OUT
2533> BAD
2634> SKIPPED
2735
28- # The -u flag.
29- UFLAG=" "
30- case $1 in
31- -u)
32- UFLAG=" $1 $2 " ; shift ; shift ;;
33- -u* )
34- UFLAG=" $1 " ; shift ;;
35- esac
36+ # Process flags (transparently pass these on to regrtest.py)
37+ FLAGS=" "
38+ EXCEPT=" "
39+ while :
40+ do
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
48+ done
3649
3750# Compute the list of tests to run.
38- case $# in
51+ case " $# $EXCEPT " in
39520)
4053 TESTS=` (cd Lib/test; ls test_* .py | sed ' s/\.py//' )`
4154 ;;
55+ * -x)
56+ PAT=" ^(` echo $@ | sed ' s/\.py//' | sed ' s/ /|/' ` )$"
57+ TESTS=` (cd Lib/test; ls test_* .py | sed ' s/\.py//' | egrep -v " $PAT " )`
58+ ;;
4259* )
4360 TESTS=" $@ "
4461 ;;
@@ -49,20 +66,23 @@ for T in $TESTS
4966do
5067 echo -n $T
5168 if case $T in
52- * curses* ) echo ; $PYTHON Lib/test/regrtest.py $UFLAG $T 2> OUT/$T .out;;
53- * ) $PYTHON Lib/test/regrtest.py $UFLAG $T > OUT/$T .out 2>&1 ;;
69+ * 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 ;;
5471 esac
5572 then
56- if grep -q " 1 test skipped:" OUT/$T .out
57- then
58- echo " SKIPPED"
73+ if grep -q " 1 test skipped:" OUT/$T .out
74+ then
75+ echo " SKIPPED"
5976 echo $T >> SKIPPED
60- else
61- echo
77+ else
78+ echo
6279 echo $T >> GOOD
63- fi
80+ fi
6481 else
65- echo " BAD"
82+ echo " BAD"
6683 echo $T >> BAD
6784 fi
6885done
86+
87+ # Summarize results
88+ wc -l BAD GOOD SKIPPED
0 commit comments