mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-07-12 10:47:40 +03:00
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
(cherry picked from commit 9aae14a14a
)
This commit is contained in:
parent
1c11d3a54f
commit
56a61d54f4
@ -858,9 +858,10 @@ class TestRun(object):
|
||||
|
||||
def complete_outputdirs(self):
|
||||
"""
|
||||
Collect all the pathnames for Tests, and TestGroups. Work
|
||||
backwards one pathname component at a time, to create a unique
|
||||
directory name in which to deposit test output. Tests will be able
|
||||
Collect all the pathnames for Tests, and TestGroups. Strip off all
|
||||
common leading path components, and append what remains to the top
|
||||
"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.
|
||||
TestGroups will be able to create one subdirectory per test in the
|
||||
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
|
||||
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:
|
||||
paths = []
|
||||
components -= 1
|
||||
for testfile in list(tmp_dict.keys()):
|
||||
uniq = '/'.join(testfile.split('/')[components:]).lstrip('/')
|
||||
if uniq not in paths:
|
||||
paths.append(uniq)
|
||||
tmp_dict[testfile].outputdir = os.path.join(base, uniq)
|
||||
else:
|
||||
break
|
||||
done = total == len(paths)
|
||||
alltests = dict(list(self.tests.items()) +
|
||||
list(self.testgroups.items()))
|
||||
base = os.path.join(self.outputdir, 'output')
|
||||
|
||||
seen = []
|
||||
|
||||
for path in list(alltests.keys()):
|
||||
frag = path.split('/')
|
||||
for i in range(0, len(frag)):
|
||||
if len(seen) == i:
|
||||
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):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user