Skip to content
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-110367: Make regrtest --verbose3 compatible with --huntrleaks -jN #111577

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Lib/test/libregrtest/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,16 @@ def _parse_args(args, **kwargs):
ns.randomize = True
if ns.verbose:
ns.header = True
if ns.huntrleaks and ns.verbose3:
# When -jN option is used, a worker process does not use --verbose3
# and so -R 3:3 -jN --verbose3 just works as expected: there is no false
# alarm about memory leak.
if ns.huntrleaks and ns.verbose3 and ns.use_mp is None:
ns.verbose3 = False
# run_single_test() replaces sys.stdout with io.StringIO if verbose3
# is true. In this case, huntrleaks sees an write into StringIO as
# a memory leak, whereas it is not (gh-71290).
print("WARNING: Disable --verbose3 because it's incompatible with "
"--huntrleaks: see http://bugs.python.org/issue27103",
"--huntrleaks without -jN option",
file=sys.stderr)
if ns.forever:
# --forever implies --failfast
Expand Down
23 changes: 23 additions & 0 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,29 @@ def test_crash(self):
self.assertIn(f"Exit code {exitcode} (SIGSEGV)", output)
self.check_line(output, "just before crash!", full=True, regex=False)

def test_verbose3(self):
code = textwrap.dedent(r"""
import unittest
from test import support

class VerboseTests(unittest.TestCase):
def test_pass(self):
print("SPAM SPAM SPAM")
""")
testname = self.create_test(code=code)

# Run sequentially
output = self.run_tests("--verbose3", testname)
self.check_executed_tests(output, testname, stats=1)
self.assertNotIn('SPAM SPAM SPAM', output)

# -R option needs a debug build
if support.Py_DEBUG:
# Check for reference leaks, run in parallel
output = self.run_tests("-R", "3:3", "-j1", "--verbose3", testname)
self.check_executed_tests(output, testname, stats=1, parallel=True)
self.assertNotIn('SPAM SPAM SPAM', output)


class TestUtils(unittest.TestCase):
def test_format_duration(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Make regrtest ``--verbose3`` option compatible with ``--huntrleaks -jN``
options. The ``./python -m test -j1 -R 3:3 --verbose3`` command now works as
expected. Patch by Victor Stinner.