Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit174e9da

Browse files
authored
gh-108388: regrtest splits test_asyncio package (#108393)
Currently, test_asyncio package is only splitted into sub-tests whenusing command "./python -m test". With this change, it's alsosplitted when passing it on the command line:"./python -m test test_asyncio".Remove the concept of "STDTESTS". Python is now mature enough to nothave to bother with that anymore. Removing STDTESTS simplify thecode.
1 parent7a6cc3e commit174e9da

File tree

2 files changed

+39
-44
lines changed

2 files changed

+39
-44
lines changed

‎Lib/test/libregrtest/main.py‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
importunittest
1212
fromtest.libregrtest.cmdlineimport_parse_args
1313
fromtest.libregrtest.runtestimport (
14-
findtests,runtest,get_abs_module,is_failed,
15-
STDTESTS,NOTTESTS,PROGRESS_MIN_TIME,
14+
findtests,split_test_packages,runtest,get_abs_module,is_failed,
15+
PROGRESS_MIN_TIME,
1616
Passed,Failed,EnvChanged,Skipped,ResourceDenied,Interrupted,
1717
ChildError,DidNotRun)
1818
fromtest.libregrtest.setupimportsetup_tests
@@ -246,26 +246,23 @@ def find_tests(self, tests):
246246
# add default PGO tests if no tests are specified
247247
setup_pgo_tests(self.ns)
248248

249-
stdtests=STDTESTS[:]
250-
nottests=NOTTESTS.copy()
249+
exclude=set()
251250
ifself.ns.exclude:
252251
forarginself.ns.args:
253-
ifarginstdtests:
254-
stdtests.remove(arg)
255-
nottests.add(arg)
252+
exclude.add(arg)
256253
self.ns.args= []
257254

258-
# if testdir is set, then we are not running the python tests suite, so
259-
# don't add default tests to be executed or skipped (pass empty values)
260-
ifself.ns.testdir:
261-
alltests=findtests(self.ns.testdir,list(),set())
262-
else:
263-
alltests=findtests(self.ns.testdir,stdtests,nottests)
255+
alltests=findtests(testdir=self.ns.testdir,exclude=exclude)
264256

265257
ifnotself.ns.fromfile:
266-
self.selected=self.testsorself.ns.argsoralltests
258+
self.selected=self.testsorself.ns.args
259+
ifself.selected:
260+
self.selected=split_test_packages(self.selected)
261+
else:
262+
self.selected=alltests
267263
else:
268264
self.selected=self.tests
265+
269266
ifself.ns.single:
270267
self.selected=self.selected[:1]
271268
try:

‎Lib/test/libregrtest/runtest.py‎

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,6 @@ def __str__(self) -> str:
125125
# the test is running in background
126126
PROGRESS_MIN_TIME=30.0# seconds
127127

128-
# small set of tests to determine if we have a basically functioning interpreter
129-
# (i.e. if any of these fail, then anything else is likely to follow)
130-
STDTESTS= [
131-
'test_grammar',
132-
'test_opcodes',
133-
'test_dict',
134-
'test_builtin',
135-
'test_exceptions',
136-
'test_types',
137-
'test_unittest',
138-
'test_doctest',
139-
'test_doctest2',
140-
'test_support'
141-
]
142-
143-
# set of tests that we don't want to be executed when using regrtest
144-
NOTTESTS=set()
145-
146128
#If these test directories are encountered recurse into them and treat each
147129
# test_ .py or dir as a separate test module. This can increase parallelism.
148130
# Beware this can't generally be done for any directory with sub-tests as the
@@ -166,22 +148,38 @@ def findtestdir(path=None):
166148
returnpathoros.path.dirname(os.path.dirname(__file__))oros.curdir
167149

168150

169-
deffindtests(testdir=None,stdtests=STDTESTS,nottests=NOTTESTS,*,split_test_dirs=SPLITTESTDIRS,base_mod=""):
151+
deffindtests(*,testdir=None,exclude=(),
152+
split_test_dirs=SPLITTESTDIRS,base_mod=""):
170153
"""Return a list of all applicable test modules."""
171154
testdir=findtestdir(testdir)
172-
names=os.listdir(testdir)
173155
tests= []
174-
others=set(stdtests)|nottests
175-
fornameinnames:
156+
fornameinos.listdir(testdir):
176157
mod,ext=os.path.splitext(name)
177-
ifmod[:5]=="test_"andmodnotinothers:
178-
ifmodinsplit_test_dirs:
179-
subdir=os.path.join(testdir,mod)
180-
mod=f"{base_modor'test'}.{mod}"
181-
tests.extend(findtests(subdir, [],nottests,split_test_dirs=split_test_dirs,base_mod=mod))
182-
elifextin (".py",""):
183-
tests.append(f"{base_mod}.{mod}"ifbase_modelsemod)
184-
returnstdtests+sorted(tests)
158+
if (notmod.startswith("test_"))or (modinexclude):
159+
continue
160+
ifmodinsplit_test_dirs:
161+
subdir=os.path.join(testdir,mod)
162+
mod=f"{base_modor'test'}.{mod}"
163+
tests.extend(findtests(testdir=subdir,exclude=exclude,
164+
split_test_dirs=split_test_dirs,base_mod=mod))
165+
elifextin (".py",""):
166+
tests.append(f"{base_mod}.{mod}"ifbase_modelsemod)
167+
returnsorted(tests)
168+
169+
170+
defsplit_test_packages(tests,*,testdir=None,exclude=(),
171+
split_test_dirs=SPLITTESTDIRS):
172+
testdir=findtestdir(testdir)
173+
splitted= []
174+
fornameintests:
175+
ifnameinsplit_test_dirs:
176+
subdir=os.path.join(testdir,name)
177+
splitted.extend(findtests(testdir=subdir,exclude=exclude,
178+
split_test_dirs=split_test_dirs,
179+
base_mod=name))
180+
else:
181+
splitted.append(name)
182+
returnsplitted
185183

186184

187185
defget_abs_module(ns:Namespace,test_name:str)->str:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp