Skip to content

gh-135494: Fix python -m test --pgo -x test_re #135713

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 10 additions & 6 deletions Lib/test/libregrtest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList

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:
# add default PGO tests if no tests are specified
setup_pgo_tests(self.cmdline_args, self.pgo_extended)
Expand All @@ -200,17 +206,15 @@ def find_tests(self, tests: TestList | None = None) -> tuple[TestTuple, TestList
if self.tsan_parallel:
setup_tsan_parallel_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,
exclude=exclude_tests)

if not self.fromfile:
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:
selected = split_test_packages(selected)
else:
Expand Down
11 changes: 11 additions & 0 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2346,6 +2346,17 @@ def check(output):
output = self.run_tests('-j1', '-v', testname, env=env, isolated=False)
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):
def test_format_duration(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix regrtest to support excluding tests from ``--pgo`` tests. Patch by
Victor Stinner.
Loading