Skip to content
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

bpo-37667: Add regression test for regrtest. #14929

Merged
merged 1 commit into from
Jul 24, 2019
Merged
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
26 changes: 26 additions & 0 deletions Lib/test/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import contextlib
import faulthandler
import glob
import io
import os.path
import platform
Expand Down Expand Up @@ -529,6 +530,31 @@ def run_python(self, args, **kw):
return proc.stdout


class CheckActualTests(BaseTestCase):
"""
Check that regrtest appears to find the expected set of tests.
"""

def test_finds_expected_number_of_tests(self):
args = ['-Wd', '-E', '-bb', '-m', 'test.regrtest', '--list-tests']
output = self.run_python(args)
rough_number_of_tests_found = len(output.splitlines())
actual_testsuite_glob = os.path.join(os.path.dirname(__file__),
'test*.py')
rough_counted_test_py_files = len(glob.glob(actual_testsuite_glob))
# We're not trying to duplicate test finding logic in here,
# just give a rough estimate of how many there should be and
# be near that. This is a regression test to prevent mishaps
# such as https://bugs.python.org/issue37667 in the future.
# If you need to change the values in here during some
# mythical future test suite reorganization, don't go
# overboard with logic and keep that goal in mind.
self.assertGreater(rough_number_of_tests_found,
rough_counted_test_py_files*9//10,
msg='Unexpectedly low number of tests found in:\n'
f'{", ".join(output.splitlines())}')


class ProgramsTestCase(BaseTestCase):
"""
Test various ways to run the Python test suite. Use options close
Expand Down