-
-
Notifications
You must be signed in to change notification settings - Fork 31.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-110722: Make -m test -T -j
use sys.monitoring
#111710
Conversation
-m test -T -j
use sys.monitoring-m test -T -j
use sys.monitoring
My hunch that nobody used to run a full suite with coverage seems to be corroborated by it not working, apparently. I was unable to get a full run of So instead, I focused on bringing down the number of tests failing under coverage. With the latest change, tests already marked with
In any case, unless anybody's got any strong opinions on this, this is ready to land. |
I would prefer to also use diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
index a5f02d6335..cf3943dd5d 100644
--- a/Lib/test/libregrtest/cmdline.py
+++ b/Lib/test/libregrtest/cmdline.py
@@ -426,8 +426,6 @@ def _parse_args(args, **kwargs):
ns.rerun = True
ns.print_slow = True
ns.verbose3 = True
- else:
- ns._add_python_opts = False
# When both --slow-ci and --fast-ci options are present,
# --slow-ci has the priority
@@ -448,16 +446,8 @@ def _parse_args(args, **kwargs):
if ns.single and ns.fromfile:
parser.error("-s and -f don't go together!")
- if ns.trace:
- if ns.use_mp is not None:
- if not Py_DEBUG:
- parser.error("need --with-pydebug to use -T and -j together")
- else:
- print(
- "Warning: collecting coverage without -j is imprecise. Configure"
- " --with-pydebug and run -m test -T -j for best results.",
- file=sys.stderr
- )
+ if ns.trace and not Py_DEBUG:
+ parser.error("need --with-pydebug to use -T")
if ns.python is not None:
if ns.use_mp is None:
parser.error("-p requires -j!")
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 296e1b4631..2a16969814 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -605,6 +605,8 @@ def _add_python_opts(self):
environ, keep_environ = self._add_cross_compile_opts(regrtest_opts)
if self.ci_mode:
self._add_ci_python_opts(python_opts, keep_environ)
+ if self.coverage:
+ python_opts.extend(('-X', 'test.cov'))
if (not python_opts) and (not regrtest_opts) and (environ is None):
# Nothing changed: nothing to do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe test.coverage
name would be more explicit than test.cov
?
I would prefer to use the same coverage implementation in all cases.
Would it be possible to make presite feature available to release builds?
I suppose that a function can be added to
Well, if a tracing tool runs in the background, such test can fail. So yeah, we should skip these lines, or just the whole test method. |
Thanks for the review! I'd prefer to change sequential Then there's the complication that |
This function replaces the current process with a new process which has the expected Python options: see _execute_python() method. On Unix, it uses the magic |
It makes sense, ok. I don't want to block the PR, I just mean that "it would be nice" to use |
Thanks for reviews, Victor and Serhiy! ✨ 🍰 ✨ |
…1710) 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=`.
…1710) 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=`.
Now all results from worker processes are aggregated and displayed together as a summary at the end of a regrtest run. Below is a non-scientific benchmark of how much faster this is compared to the old way of doing things.
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=
.Without coverage
With old trace.py-based coverage
With new
-T -j1
coverage based onsys.monitoring
Final caveat
Not all tests in the suite currently play well with coverage. When I'm running with
-Uall,extralargefile
on an M1 Mac, I get:This was true also with the old trace-based coverage gathering but it was so slow that probably nobody bothered to run coverage over the entire suite.
I will look into fixing some of those incompatibilities because most of them are about reference counts, like:
📚 Documentation preview 📚: https://cpython-previews--111710.org.readthedocs.build/