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