mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
gh-135494: Fix python -m test --pgo -x test_re (#135713)
Fix regrtest to support excluding tests from --pgo tests.
(cherry picked from commit 15c6d63fe6)
This commit is contained in:
parent
028d56fd78
commit
a27398d5b3
3 changed files with 23 additions and 6 deletions
|
|
@ -186,6 +186,12 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList
|
||||||
|
|
||||||
strip_py_suffix(tests)
|
strip_py_suffix(tests)
|
||||||
|
|
||||||
|
exclude_tests = set()
|
||||||
|
if self.exclude:
|
||||||
|
for arg in self.cmdline_args:
|
||||||
|
exclude_tests.add(arg)
|
||||||
|
self.cmdline_args = []
|
||||||
|
|
||||||
if self.pgo:
|
if self.pgo:
|
||||||
# add default PGO tests if no tests are specified
|
# add default PGO tests if no tests are specified
|
||||||
setup_pgo_tests(self.cmdline_args, self.pgo_extended)
|
setup_pgo_tests(self.cmdline_args, self.pgo_extended)
|
||||||
|
|
@ -193,17 +199,15 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList
|
||||||
if self.tsan:
|
if self.tsan:
|
||||||
setup_tsan_tests(self.cmdline_args)
|
setup_tsan_tests(self.cmdline_args)
|
||||||
|
|
||||||
exclude_tests = set()
|
|
||||||
if self.exclude:
|
|
||||||
for arg in self.cmdline_args:
|
|
||||||
exclude_tests.add(arg)
|
|
||||||
self.cmdline_args = []
|
|
||||||
|
|
||||||
alltests = findtests(testdir=self.test_dir,
|
alltests = findtests(testdir=self.test_dir,
|
||||||
exclude=exclude_tests)
|
exclude=exclude_tests)
|
||||||
|
|
||||||
if not self.fromfile:
|
if not self.fromfile:
|
||||||
selected = tests or self.cmdline_args
|
selected = tests or self.cmdline_args
|
||||||
|
if exclude_tests:
|
||||||
|
# Support "--pgo/--tsan -x test_xxx" command
|
||||||
|
selected = [name for name in selected
|
||||||
|
if name not in exclude_tests]
|
||||||
if selected:
|
if selected:
|
||||||
selected = split_test_packages(selected)
|
selected = split_test_packages(selected)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -2346,6 +2346,17 @@ def check(output):
|
||||||
output = self.run_tests('-j1', '-v', testname, env=env, isolated=False)
|
output = self.run_tests('-j1', '-v', testname, env=env, isolated=False)
|
||||||
check(output)
|
check(output)
|
||||||
|
|
||||||
|
def test_pgo_exclude(self):
|
||||||
|
# Get PGO tests
|
||||||
|
output = self.run_tests('--pgo', '--list-tests')
|
||||||
|
pgo_tests = output.strip().split()
|
||||||
|
|
||||||
|
# Exclude test_re
|
||||||
|
output = self.run_tests('--pgo', '--list-tests', '-x', 'test_re')
|
||||||
|
tests = output.strip().split()
|
||||||
|
self.assertNotIn('test_re', tests)
|
||||||
|
self.assertEqual(len(tests), len(pgo_tests) - 1)
|
||||||
|
|
||||||
|
|
||||||
class TestUtils(unittest.TestCase):
|
class TestUtils(unittest.TestCase):
|
||||||
def test_format_duration(self):
|
def test_format_duration(self):
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fix regrtest to support excluding tests from ``--pgo`` tests. Patch by
|
||||||
|
Victor Stinner.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue