Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-82054: Parallel test sharding of test_asyncio and test_multiprocessing #103934

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

Closed
Closed
Prev Previous commit
Next Next commit
This allows the test runner to execute test_multiprocessing and test_…
…asyncio in parallel

By sharding the individual tests in test_multiprocessing and test_asyncio we are able to reduce considerably the time it takes to run the whole test suite.
  • Loading branch information
zitterbewegung committed Apr 27, 2023
commit 9ffd6b72403a9ef8d6572a560431fbe954f006a7
39 changes: 20 additions & 19 deletions 39 Lib/test/libregrtest/runtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ def __str__(self) -> str:
# Beware this can't generally be done for any directory with sub-tests as the
# __init__.py may do things which alter what tests are to be run.
SPLITTESTDIRS = {
"test_asyncio"
"test_asyncio",
"test_multiprocessing",
}

# Storage of uncollectable objects
Expand All @@ -167,24 +168,24 @@ def findtestdir(path=None):


def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS, splittestdirs=SPLITTESTDIRS, base_mod=""):
"""Return a list of all applicable test modules."""
testdir = findtestdir(testdir)
names = os.listdir(testdir)
tests = []
others = set(stdtests) | nottests
for name in names:
mod, ext = os.path.splitext(name)
if mod[:5] == "test_" and mod not in others:
if mod in splittestdirs:
subdir = os.path.join(testdir, mod)
if len(base_mod):
mod = f"{base_mod}.{mod}"
else:
mod = f"test.{mod}"
tests.extend(findtests(subdir, [], nottests, splittestdirs, mod))
elif ext in (".py", ""):
tests.append(f"{base_mod}.{mod}" if len(base_mod) else mod)
return stdtests + sorted(tests)
"""Return a list of all applicable test modules."""
testdir = findtestdir(testdir)
names = os.listdir(testdir)
tests = []
others = set(stdtests) | nottests
for name in names:
mod, ext = os.path.splitext(name)
if mod[:5] == "test_" and mod not in others:
if mod in splittestdirs:
subdir = os.path.join(testdir, mod)
if len(base_mod):
mod = f"{base_mod}.{mod}"
else:
mod = f"test.{mod}"
tests.extend(findtests(subdir, [], nottests, splittestdirs, mod))
elif ext in (".py", ""):
tests.append(f"{base_mod}.{mod}" if len(base_mod) else mod)
return stdtests + sorted(tests)

def get_abs_module(ns: Namespace, test_name: str) -> str:
if test_name.startswith('test.') or ns.testdir:
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.