blob: 3c1c3bd060bff87e163b411253a178c9a87fafa4 [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
13
14
15def is_multiprocess_flag(arg):
16 return arg.startswith('-j') or arg.startswith('--multiprocess')
17
18
19def is_resource_use_flag(arg):
20 return arg.startswith('-u') or arg.startswith('--use')
21
22
23def main(regrtest_args):
24 args = [sys.executable,
Victor Stinner3e56c232016-09-21 17:12:50 +020025 '-u', # Unbuffered stdout and stderr
Nadeem Vawda3c01d162011-08-01 23:48:26 +020026 '-W', 'default', # Warnings set to 'default'
27 '-bb', # Warnings about bytes/bytearray
28 '-E', # Ignore environment variables
29 ]
30 # Allow user-specified interpreter options to override our defaults.
31 args.extend(test.support.args_from_interpreter_flags())
Serhiy Storchaka20f87282014-02-24 13:57:00 +020032
Nadeem Vawda3c01d162011-08-01 23:48:26 +020033 args.extend(['-m', 'test', # Run the test suite
34 '-r', # Randomize test order
35 '-w', # Re-run failed tests in verbose mode
36 ])
Antoine Pitrou7f0a6dd2011-08-16 20:02:26 +020037 if sys.platform == 'win32':
38 args.append('-n') # Silence alerts under Windows
Antoine Pitroud39dbf42017-09-10 20:32:13 +020039 if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
Nadeem Vawda3c01d162011-08-01 23:48:26 +020040 args.extend(['-j', '0']) # Use all CPU cores
41 if not any(is_resource_use_flag(arg) for arg in regrtest_args):
Antoine Pitrou87ae0a22011-10-01 16:41:48 +020042 args.extend(['-u', 'all,-largefile,-audio,-gui'])
Nadeem Vawda3c01d162011-08-01 23:48:26 +020043 args.extend(regrtest_args)
44 print(' '.join(args))
Zachary Waree12fa652014-07-07 13:39:59 -050045 if sys.platform == 'win32':
46 from subprocess import call
Zachary Ware69d2d012014-07-07 15:07:46 -050047 sys.exit(call(args))
Zachary Waree12fa652014-07-07 13:39:59 -050048 else:
49 os.execv(sys.executable, args)
Nadeem Vawda3c01d162011-08-01 23:48:26 +020050
51
52if __name__ == '__main__':
53 main(sys.argv[1:])