mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
bpo-37531: sync regrtest with master branch (GH-16285)
This commit is contained in:
parent
8d9efc4a27
commit
fb7746d5d1
2 changed files with 26 additions and 17 deletions
|
@ -22,6 +22,12 @@ from test.libregrtest.utils import removepy, count, format_duration, printlist
|
||||||
from test import support
|
from test import support
|
||||||
|
|
||||||
|
|
||||||
|
# bpo-38203: Maximum delay in seconds to exit Python (call Py_Finalize()).
|
||||||
|
# Used to protect against threading._shutdown() hang.
|
||||||
|
# Must be smaller than buildbot "1200 seconds without output" limit.
|
||||||
|
EXIT_TIMEOUT = 120.0
|
||||||
|
|
||||||
|
|
||||||
class Regrtest:
|
class Regrtest:
|
||||||
"""Execute a test suite.
|
"""Execute a test suite.
|
||||||
|
|
||||||
|
@ -158,11 +164,6 @@ class Regrtest:
|
||||||
def parse_args(self, kwargs):
|
def parse_args(self, kwargs):
|
||||||
ns = _parse_args(sys.argv[1:], **kwargs)
|
ns = _parse_args(sys.argv[1:], **kwargs)
|
||||||
|
|
||||||
if ns.timeout and not hasattr(faulthandler, 'dump_traceback_later'):
|
|
||||||
print("Warning: The timeout option requires "
|
|
||||||
"faulthandler.dump_traceback_later", file=sys.stderr)
|
|
||||||
ns.timeout = None
|
|
||||||
|
|
||||||
if ns.xmlpath:
|
if ns.xmlpath:
|
||||||
support.junit_xml_list = self.testsuite_xml = []
|
support.junit_xml_list = self.testsuite_xml = []
|
||||||
|
|
||||||
|
@ -616,16 +617,24 @@ class Regrtest:
|
||||||
|
|
||||||
test_cwd = self.create_temp_dir()
|
test_cwd = self.create_temp_dir()
|
||||||
|
|
||||||
# Run the tests in a context manager that temporarily changes the CWD
|
try:
|
||||||
# to a temporary and writable directory. If it's not possible to
|
# Run the tests in a context manager that temporarily changes the CWD
|
||||||
# create or change the CWD, the original CWD will be used.
|
# to a temporary and writable directory. If it's not possible to
|
||||||
# The original CWD is available from support.SAVEDCWD.
|
# create or change the CWD, the original CWD will be used.
|
||||||
with support.temp_cwd(test_cwd, quiet=True):
|
# The original CWD is available from support.SAVEDCWD.
|
||||||
# When using multiprocessing, worker processes will use test_cwd
|
with support.temp_cwd(test_cwd, quiet=True):
|
||||||
# as their parent temporary directory. So when the main process
|
# When using multiprocessing, worker processes will use test_cwd
|
||||||
# exit, it removes also subdirectories of worker processes.
|
# as their parent temporary directory. So when the main process
|
||||||
self.ns.tempdir = test_cwd
|
# exit, it removes also subdirectories of worker processes.
|
||||||
self._main(tests, kwargs)
|
self.ns.tempdir = test_cwd
|
||||||
|
|
||||||
|
self._main(tests, kwargs)
|
||||||
|
except SystemExit as exc:
|
||||||
|
# bpo-38203: Python can hang at exit in Py_Finalize(), especially
|
||||||
|
# on threading._shutdown() call: put a timeout
|
||||||
|
faulthandler.dump_traceback_later(EXIT_TIMEOUT, exit=True)
|
||||||
|
|
||||||
|
sys.exit(exc.code)
|
||||||
|
|
||||||
def getloadavg(self):
|
def getloadavg(self):
|
||||||
if self.win_load_tracker is not None:
|
if self.win_load_tracker is not None:
|
||||||
|
|
|
@ -185,14 +185,14 @@ class MultiprocessThread(threading.Thread):
|
||||||
def _timedout(self, test_name):
|
def _timedout(self, test_name):
|
||||||
self._kill()
|
self._kill()
|
||||||
|
|
||||||
stdout = sterr = ''
|
stdout = stderr = ''
|
||||||
popen = self._popen
|
popen = self._popen
|
||||||
try:
|
try:
|
||||||
stdout, stderr = popen.communicate(timeout=JOIN_TIMEOUT)
|
stdout, stderr = popen.communicate(timeout=JOIN_TIMEOUT)
|
||||||
except (subprocess.TimeoutExpired, OSError) as exc:
|
except (subprocess.TimeoutExpired, OSError) as exc:
|
||||||
print("WARNING: Failed to read worker process %s output "
|
print("WARNING: Failed to read worker process %s output "
|
||||||
"(timeout=%.1f sec): %r"
|
"(timeout=%.1f sec): %r"
|
||||||
% (popen.pid, exc, timeout),
|
% (popen.pid, JOIN_TIMEOUT, exc),
|
||||||
file=sys.stderr, flush=True)
|
file=sys.stderr, flush=True)
|
||||||
|
|
||||||
self._close_wait()
|
self._close_wait()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue