summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-26 07:35:59 (GMT)
committerGitHub <noreply@github.com>2024-03-26 07:35:59 (GMT)
commitd52bdfb19fadd7614a0e5abaf68525fc7300e841 (patch)
treeb4bd7366fe691b58ddaa000ae755094fe82b8b77
parent9f74e86c78853c101a23e938f8e32ea838d8f62e (diff)
downloadcpython-d52bdfb19fadd7614a0e5abaf68525fc7300e841.zip
cpython-d52bdfb19fadd7614a0e5abaf68525fc7300e841.tar.gz
cpython-d52bdfb19fadd7614a0e5abaf68525fc7300e841.tar.bz2
gh-83434: Disable XML in regrtest when -R option is used (#117232)
-rw-r--r--Lib/test/libregrtest/cmdline.py14
-rw-r--r--Lib/test/test_regrtest.py18
-rw-r--r--Misc/NEWS.d/next/Tests/2024-03-25-21-31-49.gh-issue-83434.U7Z8cY.rst3
3 files changed, 34 insertions, 1 deletions
diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
index 876b1bc..3e7428c 100644
--- a/Lib/test/libregrtest/cmdline.py
+++ b/Lib/test/libregrtest/cmdline.py
@@ -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
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
index 903ad50..6a6b211 100644
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -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:
diff --git a/Misc/NEWS.d/next/Tests/2024-03-25-21-31-49.gh-issue-83434.U7Z8cY.rst b/Misc/NEWS.d/next/Tests/2024-03-25-21-31-49.gh-issue-83434.U7Z8cY.rst
new file mode 100644
index 0000000..7b7a8fc
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2024-03-25-21-31-49.gh-issue-83434.U7Z8cY.rst
@@ -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.