test-runner: rework output dir construction

The old code would compare all the test group names to work out some
sort of common path, but it didn't appear to work consistently,
sometimes placing output in a top-level dir, other times in one or more
subdirs. (I confess, I do not quite understand what it's supposed to
do).

This is a very simple rework that simply looks at all the test group
paths, removes common leading components, and uses the remainder as the
output directory. This should work because groups paths are unique, and
means we get a output dir tree of roughly the same shape as the test
groups in the runfiles and the test source dirs themselves.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: @ImAwsumm
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #17167
This commit is contained in:
Rob Norris 2025-05-12 05:24:05 +10:00 committed by GitHub
parent 8b9c4e643b
commit 9aae14a14a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -858,9 +858,10 @@ class TestRun(object):
def complete_outputdirs(self): def complete_outputdirs(self):
""" """
Collect all the pathnames for Tests, and TestGroups. Work Collect all the pathnames for Tests, and TestGroups. Strip off all
backwards one pathname component at a time, to create a unique common leading path components, and append what remains to the top
directory name in which to deposit test output. Tests will be able "output" dir, to create a tree of output directories that match
the test and group names in structure. Tests will be able
to write output files directly in the newly modified outputdir. to write output files directly in the newly modified outputdir.
TestGroups will be able to create one subdirectory per test in the TestGroups will be able to create one subdirectory per test in the
outputdir, and are guaranteed uniqueness because a group can only outputdir, and are guaranteed uniqueness because a group can only
@ -869,24 +870,30 @@ class TestRun(object):
question for their output. Failsafe scripts will create a directory question for their output. Failsafe scripts will create a directory
rooted at the outputdir of each Test for their output. rooted at the outputdir of each Test for their output.
""" """
done = False
components = 0
tmp_dict = dict(list(self.tests.items()) +
list(self.testgroups.items()))
total = len(tmp_dict)
base = self.outputdir
while not done: alltests = dict(list(self.tests.items()) +
paths = [] list(self.testgroups.items()))
components -= 1 base = os.path.join(self.outputdir, 'output')
for testfile in list(tmp_dict.keys()):
uniq = '/'.join(testfile.split('/')[components:]).lstrip('/') seen = []
if uniq not in paths:
paths.append(uniq) for path in list(alltests.keys()):
tmp_dict[testfile].outputdir = os.path.join(base, uniq) frag = path.split('/')
else: for i in range(0, len(frag)):
break if len(seen) == i:
done = total == len(paths) seen.append({})
seen[i][frag[i]] = 1
cut = 0
for i in range(0, len(seen)):
if len(list(seen[i].keys())) == 1:
cut += 1
else:
break
for path in list(alltests.keys()):
uniq = path.split('/', cut)[-1]
alltests[path].outputdir = os.path.join(base, uniq)
def setup_logging(self, options): def setup_logging(self, options):
""" """