8000 [3.12] gh-83434: Sync libregrtest and test_regrtest with the main branch by vstinner · Pull Request #117250 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.12] gh-83434: Sync libregrtest and test_regrtest with the main branch #117250

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

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
gh-83434: Disable XML in regrtest when -R option is used (#117232)
(cherry picked from commit d52bdfb)
  • Loading branch information
vstinner committed Mar 26, 2024
commit 4612d1164944617e70e8f55ad521b1c9158c58c2
14 changes: 13 additions & 1 deletion Lib/test/libregrtest/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def __init__(self, **kwargs) -> None:
self.fail_rerun = False
self.tempdir = None
self._add_python_opts = True
self.xmlpath = None

super().__init__(**kwargs)

Expand Down Expand Up @@ -499,17 +500,28 @@ def _parse_args(args, **kwargs):
ns.randomize = True
if ns.verbose:
ns.header = True

# 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).
ns.verbose3 = False
print("WARNING: Disable --verbose3 because it's incompatible with "
"--huntrleaks without -jN option",
file=sys.stderr)

if ns.huntrleaks and ns.xmlpath:
# The XML data is written into a file outside runtest_refleak(), so
# it looks like a leak but it's not. Simply disable XML output when
# hunting for reference leaks (gh-83434).
ns.xmlpath = None
print("WARNING: Disable --junit-xml because it's incompatible "
"with --huntrleaks",
file=sys.stderr)

if ns.forever:
# --forever implies --failfast
ns.failfast = True
Expand Down
18 changes: 18 additions & 0 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,24 @@ def test_bisect(self):
regrtest = self.create_regrtest(args)
self.assertTrue(regrtest.want_bisect)

def test_verbose3_huntrleaks(self):
args = ['-R', '3:10', '--verbose3']
with support.captured_stderr():
regrtest = self.create_regrtest(args)
self.assertIsNotNone(regrtest.hunt_refleak)
self.assertEqual(regrtest.hunt_refleak.warmups, 3)
self.assertEqual(regrtest.hunt_refleak.runs, 10)
self.assertFalse(regrtest.output_on_failure)

def test_xml_huntrleaks(self):
args = ['-R', '3:12', '--junit-xml', 'output.xml']
with support.captured_stderr():
regrtest = self.create_regrtest(args)
self.assertIsNotNone(regrtest.hunt_refleak)
self.assertEqual(regrtest.hunt_refleak.warmups, 3)
self.assertEqual(regrtest.hunt_refleak.runs, 12)
self.assertIsNone(regrtest.junit_filename)


@dataclasses.dataclass(slots=True)
class Rerun:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Disable JUnit XML output (``--junit-xml=FILE`` command line option) in
regrtest when hunting for reference leaks (``-R`` option). Patch by Victor
Stinner.
0