Skip to content

Commit fa708d1

Browse files
committed
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. Signed-off-by: Rob Norris <[email protected]>
1 parent 5b0c27c commit fa708d1

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

tests/test-runner/bin/test-runner.py.in

+27-20
Original file line numberDiff line numberDiff line change
@@ -858,9 +858,10 @@ class TestRun(object):
858858

859859
def complete_outputdirs(self):
860860
"""
861-
Collect all the pathnames for Tests, and TestGroups. Work
862-
backwards one pathname component at a time, to create a unique
863-
directory name in which to deposit test output. Tests will be able
861+
Collect all the pathnames for Tests, and TestGroups. Strip off all
862+
common leading path components, and append what remains to the top
863+
"output" dir, to create a tree of output directories that match
864+
the test and group names in structure. Tests will be able
864865
to write output files directly in the newly modified outputdir.
865866
TestGroups will be able to create one subdirectory per test in the
866867
outputdir, and are guaranteed uniqueness because a group can only
@@ -869,24 +870,30 @@ class TestRun(object):
869870
question for their output. Failsafe scripts will create a directory
870871
rooted at the outputdir of each Test for their output.
871872
"""
872-
done = False
873-
components = 0
874-
tmp_dict = dict(list(self.tests.items()) +
873+
874+
alltests = dict(list(self.tests.items()) +
875875
list(self.testgroups.items()))
876-
total = len(tmp_dict)
877-
base = self.outputdir
878-
879-
while not done:
880-
paths = []
881-
components -= 1
882-
for testfile in list(tmp_dict.keys()):
883-
uniq = '/'.join(testfile.split('/')[components:]).lstrip('/')
884-
if uniq not in paths:
885-
paths.append(uniq)
886-
tmp_dict[testfile].outputdir = os.path.join(base, uniq)
887-
else:
888-
break
889-
done = total == len(paths)
876+
base = os.path.join(self.outputdir, 'output')
877+
878+
seen = []
879+
880+
for path in list(alltests.keys()):
881+
frag = path.split('/')
882+
for i in range(0, len(frag)):
883+
if len(seen) == i:
884+
seen.append({})
885+
seen[i][frag[i]] = 1
886+
887+
cut = 0
888+
for i in range(0, len(seen)):
889+
if len(list(seen[i].keys())) == 1:
890+
cut += 1
891+
else:
892+
break
893+
894+
for path in list(alltests.keys()):
895+
uniq = path.split('/', cut)[-1]
896+
alltests[path].outputdir = os.path.join(base, uniq)
890897

891898
def setup_logging(self, options):
892899
"""

0 commit comments

Comments
 (0)