1 | n/a | """Run Python's test suite in a fast, rigorous way. |
---|
2 | n/a | |
---|
3 | n/a | The defaults are meant to be reasonably thorough, while skipping certain |
---|
4 | n/a | tests that can be time-consuming or resource-intensive (e.g. largefile), |
---|
5 | n/a | or distracting (e.g. audio and gui). These defaults can be overridden by |
---|
6 | n/a | simply passing a -u option to this script. |
---|
7 | n/a | |
---|
8 | n/a | """ |
---|
9 | n/a | |
---|
10 | n/a | import os |
---|
11 | n/a | import sys |
---|
12 | n/a | import test.support |
---|
13 | n/a | try: |
---|
14 | n/a | import threading |
---|
15 | n/a | except ImportError: |
---|
16 | n/a | threading = None |
---|
17 | n/a | |
---|
18 | n/a | |
---|
19 | n/a | def is_multiprocess_flag(arg): |
---|
20 | n/a | return arg.startswith('-j') or arg.startswith('--multiprocess') |
---|
21 | n/a | |
---|
22 | n/a | |
---|
23 | n/a | def is_resource_use_flag(arg): |
---|
24 | n/a | return arg.startswith('-u') or arg.startswith('--use') |
---|
25 | n/a | |
---|
26 | n/a | |
---|
27 | n/a | def main(regrtest_args): |
---|
28 | n/a | args = [sys.executable, |
---|
29 | n/a | '-u', # Unbuffered stdout and stderr |
---|
30 | n/a | '-W', 'default', # Warnings set to 'default' |
---|
31 | n/a | '-bb', # Warnings about bytes/bytearray |
---|
32 | n/a | '-E', # Ignore environment variables |
---|
33 | n/a | ] |
---|
34 | n/a | # Allow user-specified interpreter options to override our defaults. |
---|
35 | n/a | args.extend(test.support.args_from_interpreter_flags()) |
---|
36 | n/a | |
---|
37 | n/a | # Workaround for issue #20361 |
---|
38 | n/a | args.extend(['-W', 'error::BytesWarning']) |
---|
39 | n/a | |
---|
40 | n/a | args.extend(['-m', 'test', # Run the test suite |
---|
41 | n/a | '-r', # Randomize test order |
---|
42 | n/a | '-w', # Re-run failed tests in verbose mode |
---|
43 | n/a | ]) |
---|
44 | n/a | if sys.platform == 'win32': |
---|
45 | n/a | args.append('-n') # Silence alerts under Windows |
---|
46 | n/a | if threading and not any(is_multiprocess_flag(arg) for arg in regrtest_args): |
---|
47 | n/a | args.extend(['-j', '0']) # Use all CPU cores |
---|
48 | n/a | if not any(is_resource_use_flag(arg) for arg in regrtest_args): |
---|
49 | n/a | args.extend(['-u', 'all,-largefile,-audio,-gui']) |
---|
50 | n/a | args.extend(regrtest_args) |
---|
51 | n/a | print(' '.join(args)) |
---|
52 | n/a | if sys.platform == 'win32': |
---|
53 | n/a | from subprocess import call |
---|
54 | n/a | sys.exit(call(args)) |
---|
55 | n/a | else: |
---|
56 | n/a | os.execv(sys.executable, args) |
---|
57 | n/a | |
---|
58 | n/a | |
---|
59 | n/a | if __name__ == '__main__': |
---|
60 | n/a | main(sys.argv[1:]) |
---|