forked from python/cpython
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pythongh-110756: Sync regrtest with main branch (python#110758)
pythongh-110756: Sync regrtest with main branch Copy files from main to this branch: * Lib/test/libregrtest/*.py * Lib/test/__init__.py * Lib/test/__main__.py * Lib/test/autotest.py * Lib/test/pythoninfo.py * Lib/test/regrtest.py * Lib/test/test_regrtest.py Copy also changes from: * Lib/test/support/__init__.py * Lib/test/support/os_helper.py * Lib/test/support/testresult.py * Lib/test/support/threading_helper.py * Lib/test/test_support.py Do not modify scripts running tests such as Makefile.pre.in, .github/workflows/build.yml or Tools/scripts/run_tests.py: do not use --fast-ci and --slow-ci in this change. Changes: * SPLITTESTDIRS: don't include test_inspect. * Add utils.process_cpu_count() using len(os.sched_getaffinity(0)). * test_regrtest doesn't use @support.without_optimizer which doesn't exist in Python 3.11. * Add support.set_sanitizer_env_var(). * Update test_faulthandler to use support.set_sanitizer_env_var(). * @support.without_optimizer doesn't exist in 3.11. * Add support.Py_DEBUG. * regrtest.refleak: 3.11 doesn't have sys.getunicodeinternedsize.
- Loading branch information
Showing
29 changed files
with
3,715 additions
and
2,176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from test.libregrtest import main | ||
main() | ||
from test.libregrtest.main import main | ||
main(_add_python_opts=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# This should be equivalent to running regrtest.py from the cmdline. | ||
# It can be especially handy if you're in an interactive shell, e.g., | ||
# from test import autotest. | ||
from test.libregrtest import main | ||
from test.libregrtest.main import main | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
from test.libregrtest.cmdline import _parse_args, RESOURCE_NAMES, ALL_RESOURCES | ||
from test.libregrtest.main import main | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import os | ||
import sys | ||
import unittest | ||
|
||
from test import support | ||
|
||
from .utils import ( | ||
StrPath, TestName, TestTuple, TestList, FilterTuple, | ||
abs_module_name, count, printlist) | ||
|
||
|
||
# If these test directories are encountered recurse into them and treat each | ||
# "test_*.py" file or each sub-directory as a separate test module. This can | ||
# increase parallelism. | ||
# | ||
# 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: set[TestName] = { | ||
"test_asyncio", | ||
"test_concurrent_futures", | ||
"test_future_stmt", | ||
"test_gdb", | ||
"test_multiprocessing_fork", | ||
"test_multiprocessing_forkserver", | ||
"test_multiprocessing_spawn", | ||
} | ||
|
||
|
||
def findtestdir(path: StrPath | None = None) -> StrPath: | ||
return path or os.path.dirname(os.path.dirname(__file__)) or os.curdir | ||
|
||
|
||
def findtests(*, testdir: StrPath | None = None, exclude=(), | ||
split_test_dirs: set[TestName] = SPLITTESTDIRS, | ||
base_mod: str = "") -> TestList: | ||
"""Return a list of all applicable test modules.""" | ||
testdir = findtestdir(testdir) | ||
tests = [] | ||
for name in os.listdir(testdir): | ||
mod, ext = os.path.splitext(name) | ||
if (not mod.startswith("test_")) or (mod in exclude): | ||
continue | ||
if base_mod: | ||
fullname = f"{base_mod}.{mod}" | ||
else: | ||
fullname = mod | ||
if fullname in split_test_dirs: | ||
subdir = os.path.join(testdir, mod) | ||
if not base_mod: | ||
fullname = f"test.{mod}" | ||
tests.extend(findtests(testdir=subdir, exclude=exclude, | ||
split_test_dirs=split_test_dirs, | ||
base_mod=fullname)) | ||
elif ext in (".py", ""): | ||
tests.append(fullname) | ||
return sorted(tests) | ||
|
||
|
||
def split_test_packages(tests, *, testdir: StrPath | None = None, exclude=(), | ||
split_test_dirs=SPLITTESTDIRS): | ||
testdir = findtestdir(testdir) | ||
splitted = [] | ||
for name in tests: | ||
if name in split_test_dirs: | ||
subdir = os.path.join(testdir, name) | ||
splitted.extend(findtests(testdir=subdir, exclude=exclude, | ||
split_test_dirs=split_test_dirs, | ||
base_mod=name)) | ||
else: | ||
splitted.append(name) | ||
return splitted | ||
|
||
|
||
def _list_cases(suite): | ||
for test in suite: | ||
if isinstance(test, unittest.loader._FailedTest): | ||
continue | ||
if isinstance(test, unittest.TestSuite): | ||
_list_cases(test) | ||
elif isinstance(test, unittest.TestCase): | ||
if support.match_test(test): | ||
print(test.id()) | ||
|
||
def list_cases(tests: TestTuple, *, | ||
match_tests: FilterTuple | None = None, | ||
ignore_tests: FilterTuple | None = None, | ||
test_dir: StrPath | None = None): | ||
support.verbose = False | ||
support.set_match_tests(match_tests, ignore_tests) | ||
|
||
skipped = [] | ||
for test_name in tests: | ||
module_name = abs_module_name(test_name, test_dir) | ||
try: | ||
suite = unittest.defaultTestLoader.loadTestsFromName(module_name) | ||
_list_cases(suite) | ||
except unittest.SkipTest: | ||
skipped.append(test_name) | ||
|
||
if skipped: | ||
sys.stdout.flush() | ||
stderr = sys.stderr | ||
print(file=stderr) | ||
print(count(len(skipped), "test"), "skipped:", file=stderr) | ||
printlist(skipped, file=stderr) |
Oops, something went wrong.