gh-110722: Make -m test -T -j use sys.monitoring (GH-111710)

Now all results from worker processes are aggregated and
displayed together as a summary at the end of a regrtest run.

The traditional trace is left in place for use with sequential
in-process test runs but now raises a warning that those
numbers are not precise.

`-T -j` requires `--with-pydebug` as it relies on `-Xpresite=`.
This commit is contained in:
Łukasz Langa 2023-11-10 18:17:45 +01:00 committed by GitHub
parent 0b06d2482d
commit 3932b0f7b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 166 additions and 34 deletions

View file

@ -1082,18 +1082,30 @@ def check_impl_detail(**guards):
def no_tracing(func):
"""Decorator to temporarily turn off tracing for the duration of a test."""
if not hasattr(sys, 'gettrace'):
return func
else:
trace_wrapper = func
if hasattr(sys, 'gettrace'):
@functools.wraps(func)
def wrapper(*args, **kwargs):
def trace_wrapper(*args, **kwargs):
original_trace = sys.gettrace()
try:
sys.settrace(None)
return func(*args, **kwargs)
finally:
sys.settrace(original_trace)
return wrapper
coverage_wrapper = trace_wrapper
if 'test.cov' in sys.modules: # -Xpresite=test.cov used
cov = sys.monitoring.COVERAGE_ID
@functools.wraps(func)
def coverage_wrapper(*args, **kwargs):
original_events = sys.monitoring.get_events(cov)
try:
sys.monitoring.set_events(cov, 0)
return trace_wrapper(*args, **kwargs)
finally:
sys.monitoring.set_events(cov, original_events)
return coverage_wrapper
def refcount_test(test):