blob: a6c5da35e2f67a42099ca4fa91c0c9ddb7be7575 [file] [log] [blame]
Nadeem Vawda3c01d162011-08-01 23:48:26 +02001"""Run Python's test suite in a fast, rigorous way.
2
Nadeem Vawda328b5012011-08-02 10:16:45 +02003The defaults are meant to be reasonably thorough, while skipping certain
4tests that can be time-consuming or resource-intensive (e.g. largefile),
5or distracting (e.g. audio and gui). These defaults can be overridden by
6simply passing a -u option to this script.
Nadeem Vawda3c01d162011-08-01 23:48:26 +02007
8"""
9
10import os
11import sys
12import test.support
Antoine Pitrouebdcd852012-05-18 18:33:07 +020013try:
14 import threading
15except ImportError:
16 threading = None
Nadeem Vawda3c01d162011-08-01 23:48:26 +020017
18
19def is_multiprocess_flag(arg):
20 return arg.startswith('-j') or arg.startswith('--multiprocess')
21
22
23def is_resource_use_flag(arg):
24 return arg.startswith('-u') or arg.startswith('--use')
25
26
27def main(regrtest_args):
28 args = [sys.executable,
29 '-W', 'default', # Warnings set to 'default'
30 '-bb', # Warnings about bytes/bytearray
31 '-E', # Ignore environment variables
32 ]
33 # Allow user-specified interpreter options to override our defaults.
34 args.extend(test.support.args_from_interpreter_flags())
Serhiy Storchaka20f87282014-02-24 13:57:00 +020035
36 # Workaround for issue #20355
37 os.environ.pop("PYTHONWARNINGS", None)
38 # Workaround for issue #20361
39 args.extend(['-W', 'error::BytesWarning'])
40
Nadeem Vawda3c01d162011-08-01 23:48:26 +020041 args.extend(['-m', 'test', # Run the test suite
42 '-r', # Randomize test order
43 '-w', # Re-run failed tests in verbose mode
44 ])
Antoine Pitrou7f0a6dd2011-08-16 20:02:26 +020045 if sys.platform == 'win32':
46 args.append('-n') # Silence alerts under Windows
Antoine Pitrouebdcd852012-05-18 18:33:07 +020047 if threading and not any(is_multiprocess_flag(arg) for arg in regrtest_args):
Nadeem Vawda3c01d162011-08-01 23:48:26 +020048 args.extend(['-j', '0']) # Use all CPU cores
49 if not any(is_resource_use_flag(arg) for arg in regrtest_args):
Antoine Pitrou87ae0a22011-10-01 16:41:48 +020050 args.extend(['-u', 'all,-largefile,-audio,-gui'])
Nadeem Vawda3c01d162011-08-01 23:48:26 +020051 args.extend(regrtest_args)
52 print(' '.join(args))
53 os.execv(sys.executable, args)
54
55
56if __name__ == '__main__':
57 main(sys.argv[1:])