mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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:
parent
0b06d2482d
commit
3932b0f7b1
13 changed files with 166 additions and 34 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue