ยปCore Development>Code coverage>Tools/scripts/run_tests.py

Python code coverage for Tools/scripts/run_tests.py

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