gh-83434: Disable XML in regrtest when -R option is used (#117232)

This commit is contained in:
Victor Stinner 2024-03-26 08:35:59 +01:00 committed by GitHub
parent 9f74e86c78
commit d52bdfb19f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 34 additions and 1 deletions

View File

@ -173,6 +173,7 @@ class Namespace(argparse.Namespace):
self.fail_rerun = False
self.tempdir = None
self._add_python_opts = True
self.xmlpath = None
super().__init__(**kwargs)
@ -506,17 +507,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

View File

@ -464,6 +464,24 @@ class ParseArgsTestCase(unittest.TestCase):
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:

View File

@ -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.