summaryrefslogtreecommitdiffstats
path: root/Lib/trace.py
diff options
context:
space:
mode:
authorƁukasz Langa <lukasz@langa.pl>2023-11-10 17:17:45 (GMT)
committerGitHub <noreply@github.com>2023-11-10 17:17:45 (GMT)
commit3932b0f7b1566374427daa8bc47203032015e350 (patch)
treed7a4c61cda7d382f3e480f56f2ad9edb8ff29d6c /Lib/trace.py
parent0b06d2482d77e02c5d40e221f6046c9c355458b2 (diff)
downloadcpython-3932b0f7b1566374427daa8bc47203032015e350.zip
cpython-3932b0f7b1566374427daa8bc47203032015e350.tar.gz
cpython-3932b0f7b1566374427daa8bc47203032015e350.tar.bz2
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=`.
Diffstat (limited to 'Lib/trace.py')
-rwxr-xr-xLib/trace.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/trace.py b/Lib/trace.py
index fb9a423..7cb6f89 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -202,7 +202,8 @@ class CoverageResults:
for key in other_callers:
callers[key] = 1
- def write_results(self, show_missing=True, summary=False, coverdir=None):
+ def write_results(self, show_missing=True, summary=False, coverdir=None, *,
+ ignore_missing_files=False):
"""
Write the coverage results.
@@ -211,6 +212,9 @@ class CoverageResults:
:param coverdir: If None, the results of each module are placed in its
directory, otherwise it is included in the directory
specified.
+ :param ignore_missing_files: If True, counts for files that no longer
+ exist are silently ignored. Otherwise, a missing file
+ will raise a FileNotFoundError.
"""
if self.calledfuncs:
print()
@@ -253,6 +257,9 @@ class CoverageResults:
if filename.endswith(".pyc"):
filename = filename[:-1]
+ if ignore_missing_files and not os.path.isfile(filename):
+ continue
+
if coverdir is None:
dir = os.path.dirname(os.path.abspath(filename))
modulename = _modname(filename)
@@ -278,7 +285,6 @@ class CoverageResults:
percent = int(100 * n_hits / n_lines)
sums[modulename] = n_lines, percent, modulename, filename
-
if summary and sums:
print("lines cov% module (path)")
for m in sorted(sums):