Skip to content

Commit

Permalink
test: allow recursion in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Jun 29, 2024
1 parent 02bd866 commit 2c9cf7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
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

0 comments on commit 2c9cf7e

Please sign in to comment.