1
"""Load and run the Pygame test suite
3
python -c "import pygame.tests.go" [<test options>]
7
python test/go.py [<test options>]
9
Command line option --help displays a command line usage message.
11
run_tests.py in the main distribution directory is an alternative to test.go
17
if __name__ == '__main__':
19
pkg_dir = os.path.split(os.path.abspath(__file__))[0]
20
parent_dir, pkg_name = os.path.split(pkg_dir)
21
is_pygame_pkg = (pkg_name == 'tests' and
22
os.path.split(parent_dir)[1] == 'pygame')
24
sys.path.insert(0, parent_dir)
26
is_pygame_pkg = __name__.startswith('pygame.tests.')
29
from pygame.tests.test_utils.run_tests import run
30
from pygame.tests.test_utils.test_runner import opt_parser
32
from test.test_utils.run_tests import run
33
from test.test_utils.test_runner import opt_parser
36
test_pkg_name = "pygame.tests"
38
test_pkg_name = "test"
39
program_name = sys.argv[0]
40
if program_name == '-c':
41
program_name = 'python -c "import %s.go"' % test_pkg_name
43
###########################################################################
44
# Set additional command line options
46
# Defined in test_runner.py as it shares options, added to here
48
opt_parser.set_usage("""
50
Runs all or some of the %(pkg)s.xxxx_test tests.
52
$ %(exec)s sprite threads -sd
54
Runs the sprite and threads module tests isolated in subprocesses, dumping
55
all failing tests info in the form of a dict.
57
""" % {'pkg': test_pkg_name, 'exec': program_name})
59
opt_parser.add_option (
60
"-d", "--dump", action = 'store_true',
61
help = "dump failures/errors as dict ready to eval" )
63
opt_parser.add_option (
65
help = "dump failures/errors to a file" )
67
opt_parser.add_option (
68
"-a", "--all", action = 'store_true',
69
help = "dump all results not just errors eg. -da" )
71
opt_parser.add_option (
72
"-m", "--multi_thread", metavar = 'THREADS', type = 'int',
73
help = "run subprocessed tests in x THREADS" )
75
opt_parser.add_option (
76
"-t", "--time_out", metavar = 'SECONDS', type = 'int',
77
help = "kill stalled subprocessed tests after SECONDS" )
79
opt_parser.add_option (
80
"-f", "--fake", metavar = "DIR",
81
help = "run fake tests in run_tests__tests/$DIR" )
83
opt_parser.add_option (
84
"-p", "--python", metavar = "PYTHON",
85
help = "path to python excutable to run subproccesed tests\n"
86
"default (sys.executable): %s" % sys.executable)
88
opt_parser.add_option (
89
"-I", "--interactive", action = 'store_true',
90
help = "include tests requiring user input")
92
###########################################################################
93
# Set run() keyword arguements according to command line arguemnts.
94
# args will be the test module list, passed as positional argumemts.
96
options, args = opt_parser.parse_args()
99
if options.incomplete:
100
kwds['incomplete'] = True
101
if options.nosubprocess:
102
kwds['nosubprocess'] = True
106
kwds['file'] = options.file
107
kwds['timings'] = options.timings
109
kwds['exclude'] = options.exclude
110
if options.show_output:
111
kwds['show_output'] = True
114
if options.randomize:
115
kwds['randomize'] = True
116
if options.seed is not None:
117
kwds['seed'] = options.seed
118
if options.multi_thread is not None:
119
kwds['multi_thread'] = options.multi_thread
120
if options.time_out is not None:
121
kwds['time_out'] = options.time_out
123
kwds['fake'] = options.fake
125
kwds['python'] = options.python
126
if options.interactive:
127
kwds['interactive'] = True
129
###########################################################################
130
# Run the test suite.