Merged revisions 73727 via svnmerge from
[python/dscho.git] / runtests.sh
blob2d3cfc8969be3df21627097b547deda1c2db8c3e
1 #!/bin/bash
3 HELP="Usage: ./runtests.py [-h] [-x] [flags] [tests]
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.
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.
15 Flags (arguments starting with '-') are passed transparently to
16 regrtest.py, except for -x, which is processed here."
18 # Choose the Python binary.
19 case `uname` in
20 Darwin) PYTHON=./python.exe;;
21 CYGWIN*) PYTHON=./python.exe;;
22 *) PYTHON=./python;;
23 esac
25 PYTHON="$PYTHON -bb"
27 # Unset PYTHONPATH, just to be sure.
28 unset PYTHONPATH
30 # Create the output directory if necessary.
31 mkdir -p OUT
33 # Empty the summary files.
34 >GOOD
35 >BAD
36 >SKIPPED
38 # Process flags (transparently pass these on to regrtest.py)
39 FLAGS=""
40 EXCEPT=""
41 while :
43 case $1 in
44 -h|--h|-help|--help) echo "$HELP"; exit;;
45 --) FLAGS="$FLAGS $1"; shift; break;;
46 -x) EXCEPT="$1"; shift;;
47 -*) FLAGS="$FLAGS $1"; shift;;
48 *) break;;
49 esac
50 done
52 # Compute the list of tests to run.
53 case "$#$EXCEPT" in
54 0)
55 TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//')`
57 *-x)
58 PAT="^(`echo $@ | sed 's/\.py//' | sed 's/ /|/'`)$"
59 TESTS=`(cd Lib/test; ls test_*.py | sed 's/\.py//' | egrep -v "$PAT")`
62 TESTS="$@"
64 esac
66 # Run the tests.
67 for T in $TESTS
69 echo -n $T
70 if case $T in
71 *curses*)
72 echo
73 $PYTHON -E Lib/test/regrtest.py $FLAGS $T 2>OUT/$T.out
75 *) $PYTHON -E Lib/test/regrtest.py $FLAGS $T >OUT/$T.out 2>&1;;
76 esac
77 then
78 if grep -q "1 test skipped:" OUT/$T.out
79 then
80 echo " SKIPPED"
81 echo $T >>SKIPPED
82 else
83 echo
84 echo $T >>GOOD
86 else
87 echo " BAD"
88 echo $T >>BAD
90 done
92 # Summarize results
93 wc -l BAD GOOD SKIPPED