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

test: allow recursion in testing #53640

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion test/sequential/testcfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
import testpy

def GetConfiguration(context, root):
return testpy.SimpleTestConfiguration(context, root, 'sequential')
return testpy.SimpleTestConfiguration(context, root, 'sequential', allow_recursion=True)
14 changes: 10 additions & 4 deletions test/testpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,24 @@ def GetSource(self):


class SimpleTestConfiguration(test.TestConfiguration):
def __init__(self, context, root, section, additional=None):
def __init__(self, context, root, section, additional=None, allow_recursion=False):
super(SimpleTestConfiguration, self).__init__(context, root, section)
self.allow_recursion = allow_recursion
if additional is not None:
self.additional_flags = additional
else:
self.additional_flags = []

def Ls(self, path):
return [f for f in os.listdir(path) if LS_RE.match(f)]
if self.allow_recursion:
return [os.path.relpath(os.path.join(dp, f), path)
for dp, dn, filenames in os.walk(path)
for f in filenames if LS_RE.match(f)]
else:
return [f for f in os.listdir(path) if LS_RE.match(f)]

def ListTests(self, current_path, path, arch, mode):
all_tests = [current_path + [t] for t in self.Ls(os.path.join(self.root))]
all_tests = [current_path + t.split(os.path.sep) for t in self.Ls(os.path.join(self.root))]
result = []
for tst in all_tests:
if self.Contains(path, tst):
Expand All @@ -121,7 +127,7 @@ def GetBuildRequirements(self):
class ParallelTestConfiguration(SimpleTestConfiguration):
def __init__(self, context, root, section, additional=None):
super(ParallelTestConfiguration, self).__init__(context, root, section,
additional)
additional, allow_recursion=True)

def ListTests(self, current_path, path, arch, mode):
result = super(ParallelTestConfiguration, self).ListTests(
Expand Down
1 change: 1 addition & 0 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,7 @@ def ArgsToTestPaths(test_root, args, suites):
subsystem_regex = re.compile(r'^[a-zA-Z-]*$')
check = lambda arg: subsystem_regex.match(arg) and (arg not in suites)
mapped_args = ["*/test*-%s-*" % arg if check(arg) else arg for arg in args]
mapped_args += ["*/%s/test*" % arg for arg in args]
paths = [SplitPath(NormalizePath(a)) for a in mapped_args]
return paths

Expand Down
Loading