annotate Tools/scripts/run_tests.py @ 87690:66c1c9f32567 default tip

Add use_weakref option to functools.lru_cache The use_weakref option makes lru_cache create weak references to the function arguments when creating the cache key, which prevents them from staying in the memory forever even after all other references to them are gone. This is a proof of concept for http://bugs.python.org/issue19859
author Radomir Dopieralski <devel@sheep.art.pl>
date Tue, 03 Dec 2013 16:02:48 +0100
parents 2034b3de1144
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71682
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
1 """Run Python's test suite in a fast, rigorous way.
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
2
71687
0b52b6f1bfab Clean up description of Tools/scripts/run_tests.py.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents: 71682
diff changeset
3 The defaults are meant to be reasonably thorough, while skipping certain
0b52b6f1bfab Clean up description of Tools/scripts/run_tests.py.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents: 71682
diff changeset
4 tests that can be time-consuming or resource-intensive (e.g. largefile),
0b52b6f1bfab Clean up description of Tools/scripts/run_tests.py.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents: 71682
diff changeset
5 or distracting (e.g. audio and gui). These defaults can be overridden by
0b52b6f1bfab Clean up description of Tools/scripts/run_tests.py.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents: 71682
diff changeset
6 simply passing a -u option to this script.
71682
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
7
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
8 """
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
9
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
10 import os
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
11 import sys
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
12 import test.support
77036
2034b3de1144 Move private function _args_from_interpreter_flags() to subprocess.py, so
Antoine Pitrou <solipsis@pitrou.net>
parents: 75152
diff changeset
13 try:
2034b3de1144 Move private function _args_from_interpreter_flags() to subprocess.py, so
Antoine Pitrou <solipsis@pitrou.net>
parents: 75152
diff changeset
14 import threading
2034b3de1144 Move private function _args_from_interpreter_flags() to subprocess.py, so
Antoine Pitrou <solipsis@pitrou.net>
parents: 75152
diff changeset
15 except ImportError:
2034b3de1144 Move private function _args_from_interpreter_flags() to subprocess.py, so
Antoine Pitrou <solipsis@pitrou.net>
parents: 75152
diff changeset
16 threading = None
71682
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
17
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
18
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
19 def is_multiprocess_flag(arg):
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
20 return arg.startswith('-j') or arg.startswith('--multiprocess')
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
21
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
22
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
23 def is_resource_use_flag(arg):
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
24 return arg.startswith('-u') or arg.startswith('--use')
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
25
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
26
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
27 def main(regrtest_args):
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
28 args = [sys.executable,
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
29 '-W', 'default', # Warnings set to 'default'
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
30 '-bb', # Warnings about bytes/bytearray
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
31 '-E', # Ignore environment variables
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
32 ]
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
33 # Allow user-specified interpreter options to override our defaults.
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
34 args.extend(test.support.args_from_interpreter_flags())
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
35 args.extend(['-m', 'test', # Run the test suite
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
36 '-r', # Randomize test order
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
37 '-w', # Re-run failed tests in verbose mode
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
38 ])
71881
03d439f4ec5c Use -n for tests under Windows
Antoine Pitrou <solipsis@pitrou.net>
parents: 71687
diff changeset
39 if sys.platform == 'win32':
03d439f4ec5c Use -n for tests under Windows
Antoine Pitrou <solipsis@pitrou.net>
parents: 71687
diff changeset
40 args.append('-n') # Silence alerts under Windows
77036
2034b3de1144 Move private function _args_from_interpreter_flags() to subprocess.py, so
Antoine Pitrou <solipsis@pitrou.net>
parents: 75152
diff changeset
41 if threading and not any(is_multiprocess_flag(arg) for arg in regrtest_args):
71682
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
42 args.extend(['-j', '0']) # Use all CPU cores
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
43 if not any(is_resource_use_flag(arg) for arg in regrtest_args):
72564
7fabd75a6ae4 Backout of changeset 228fd2bd83a5 by Nadeem Vawda in branch 'default':
Antoine Pitrou <solipsis@pitrou.net>
parents: 72018
diff changeset
44 args.extend(['-u', 'all,-largefile,-audio,-gui'])
71682
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
45 args.extend(regrtest_args)
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
46 print(' '.join(args))
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
47 os.execv(sys.executable, args)
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
48
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
49
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
50 if __name__ == '__main__':
c68a80779434 Issue #11651: Move options for running tests into a Python script.
Nadeem Vawda <nadeem.vawda@gmail.com>
parents:
diff changeset
51 main(sys.argv[1:])