| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 1 #! /usr/bin/env python3 | 1 #! /usr/bin/env python3 |
| 2 | 2 |
| 3 """ | 3 """ |
| 4 Usage: | 4 Usage: |
| 5 | 5 |
| 6 python -m test [options] [test_name1 [test_name2 ...]] | 6 python -m test [options] [test_name1 [test_name2 ...]] |
| 7 python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]] | 7 python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]] |
| 8 | 8 |
| 9 | 9 |
| 10 If no arguments or options are provided, finds all files matching | 10 If no arguments or options are provided, finds all files matching |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 153 subprocess Run all tests for the subprocess module. | 153 subprocess Run all tests for the subprocess module. |
| 154 | 154 |
| 155 urlfetch - It is okay to download files required on testing. | 155 urlfetch - It is okay to download files required on testing. |
| 156 | 156 |
| 157 gui - Run tests that require a running GUI. | 157 gui - Run tests that require a running GUI. |
| 158 | 158 |
| 159 To enable all resources except one, use '-uall,-<resource>'. For | 159 To enable all resources except one, use '-uall,-<resource>'. For |
| 160 example, to run all the tests except for the gui tests, give the | 160 example, to run all the tests except for the gui tests, give the |
| 161 option '-uall,-gui'. | 161 option '-uall,-gui'. |
| 162 """ | 162 """ |
| 163 USAGE_SIGUSR1 = """ | |
| 164 You can send a SIGUSR1 signal to display the traceback of the current threads. | |
|
eric.araujo
2011/05/23 16:26:18
“the traceback” (singular) “of the current threads
| |
| 165 But send a signal may interrupt the current system call and so interfer with | |
|
eric.araujo
2011/05/23 16:26:18
“Note that sending a signal may interrupt a system
| |
| 166 the tests, only do that if a test hangs and you would like to know where. | |
| 167 """ | |
| 163 | 168 |
| 164 import builtins | 169 import builtins |
| 170 import errno | |
| 165 import faulthandler | 171 import faulthandler |
| 166 import getopt | 172 import getopt |
| 173 import io | |
| 167 import json | 174 import json |
| 168 import os | 175 import os |
| 169 import random | 176 import random |
| 170 import re | 177 import re |
| 171 import io | 178 import signal |
| 172 import sys | 179 import sys |
| 173 import time | 180 import time |
| 174 import errno | |
| 175 import traceback | 181 import traceback |
| 182 import unittest | |
| 176 import warnings | 183 import warnings |
| 177 import unittest | |
| 178 from inspect import isabstract | 184 from inspect import isabstract |
| 179 import tempfile | 185 import tempfile |
| 180 import platform | 186 import platform |
| 181 import sysconfig | 187 import sysconfig |
| 182 import logging | 188 import logging |
| 183 | 189 |
| 184 | 190 |
| 185 # Some times __path__ and __file__ are not absolute (e.g. while running from | 191 # Some times __path__ and __file__ are not absolute (e.g. while running from |
| 186 # Lib/) and, if we change the CWD to run the tests in a temporary dir, some | 192 # Lib/) and, if we change the CWD to run the tests in a temporary dir, some |
| 187 # imports might fail. This affects only the modules imported before os.chdir(). | 193 # imports might fail. This affects only the modules imported before os.chdir(). |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 | 267 |
| 262 The other default arguments (verbose, quiet, exclude, | 268 The other default arguments (verbose, quiet, exclude, |
| 263 single, randomize, findleaks, use_resources, trace, coverdir, | 269 single, randomize, findleaks, use_resources, trace, coverdir, |
| 264 print_slow, and random_seed) allow programmers calling main() | 270 print_slow, and random_seed) allow programmers calling main() |
| 265 directly to set the values that would normally be set by flags | 271 directly to set the values that would normally be set by flags |
| 266 on the command line. | 272 on the command line. |
| 267 """ | 273 """ |
| 268 | 274 |
| 269 # Display the Python traceback fatal errors (e.g. segfault) | 275 # Display the Python traceback fatal errors (e.g. segfault) |
| 270 faulthandler.enable(all_threads=True) | 276 faulthandler.enable(all_threads=True) |
| 277 if hasattr(signal, 'SIGUSR1'): | |
| 278 faulthandler.register(signal.SIGUSR1) | |
| 271 | 279 |
| 272 if hasattr(faulthandler, 'dump_tracebacks_later'): | 280 if hasattr(faulthandler, 'dump_tracebacks_later'): |
| 273 timeout = 60*60 | 281 timeout = 60*60 |
| 274 else: | 282 else: |
| 275 timeout = None | 283 timeout = None |
| 276 | 284 |
| 277 replace_stdout() | 285 replace_stdout() |
| 278 | 286 |
| 279 support.record_original_stdout(sys.stdout) | 287 support.record_original_stdout(sys.stdout) |
| 280 try: | 288 try: |
| 281 opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:' , | 289 opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:nj:' , |
| 282 ['help', 'verbose', 'verbose2', 'verbose3', 'quiet', | 290 ['help', 'verbose', 'verbose2', 'verbose3', 'quiet', |
| 283 'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks', | 291 'exclude', 'single', 'slow', 'random', 'fromfile', 'findleaks', |
| 284 'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir', | 292 'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir', |
| 285 'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=', | 293 'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=', |
| 286 'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug', | 294 'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug', |
| 287 'start=', 'nowindows', 'header', 'testdir=', 'timeout=', 'wait']) | 295 'start=', 'nowindows', 'header', 'testdir=', 'timeout=', 'wait']) |
| 288 except getopt.error as msg: | 296 except getopt.error as msg: |
| 289 usage(msg) | 297 usage(msg) |
| 290 | 298 |
| 291 # Defaults | 299 # Defaults |
| 292 if random_seed is None: | 300 if random_seed is None: |
| 293 random_seed = random.randrange(10000000) | 301 random_seed = random.randrange(10000000) |
| 294 if use_resources is None: | 302 if use_resources is None: |
| 295 use_resources = [] | 303 use_resources = [] |
| 296 debug = False | 304 debug = False |
| 297 start = None | 305 start = None |
| 298 for o, a in opts: | 306 for o, a in opts: |
| 299 if o in ('-h', '--help'): | 307 if o in ('-h', '--help'): |
| 300 print(__doc__) | 308 usage = __doc__ |
| 309 if hasattr(signal, 'SIGUSR1'): | |
| 310 usage += USAGE_SIGUSR1 | |
| 311 print(usage) | |
| 301 return | 312 return |
| 302 elif o in ('-v', '--verbose'): | 313 elif o in ('-v', '--verbose'): |
| 303 verbose += 1 | 314 verbose += 1 |
| 304 elif o in ('-w', '--verbose2'): | 315 elif o in ('-w', '--verbose2'): |
| 305 verbose2 = True | 316 verbose2 = True |
| 306 elif o in ('-d', '--debug'): | 317 elif o in ('-d', '--debug'): |
| 307 debug = True | 318 debug = True |
| 308 elif o in ('-W', '--verbose3'): | 319 elif o in ('-W', '--verbose3'): |
| 309 verbose3 = True | 320 verbose3 = True |
| 310 elif o in ('-q', '--quiet'): | 321 elif o in ('-q', '--quiet'): |
| (...skipping 1303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1614 assert __file__ == os.path.abspath(sys.argv[0]) | 1625 assert __file__ == os.path.abspath(sys.argv[0]) |
| 1615 | 1626 |
| 1616 TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR) | 1627 TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR) |
| 1617 | 1628 |
| 1618 # Run the tests in a context manager that temporary changes the CWD to a | 1629 # Run the tests in a context manager that temporary changes the CWD to a |
| 1619 # temporary and writable directory. If it's not possible to create or | 1630 # temporary and writable directory. If it's not possible to create or |
| 1620 # change the CWD, the original CWD will be used. The original CWD is | 1631 # change the CWD, the original CWD will be used. The original CWD is |
| 1621 # available from support.SAVEDCWD. | 1632 # available from support.SAVEDCWD. |
| 1622 with support.temp_cwd(TESTCWD, quiet=True): | 1633 with support.temp_cwd(TESTCWD, quiet=True): |
| 1623 main() | 1634 main() |
| OLD | NEW |