Skip to content

Commit c6ac07b

Browse files
authored
[Dexter] Add option to Dexter to name results based on directory (#148611)
As a legacy of Dexter's role as a test runner, it selects a name for result files based on the relative path from the test root to each individual test. Since Dexter no longer takes a test directory as an argument, only the basename for each test is ever used. This patch adds an optional --test-root-dir argument, allowing for relative paths to be used for result files again.
1 parent fda3fbe commit c6ac07b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

cross-project-tests/debuginfo-tests/dexter/dex/tools/TestToolBase.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ def add_tool_arguments(self, parser, defaults):
5858
default=None,
5959
help="directory to save results (default: none)",
6060
)
61+
parser.add_argument(
62+
"--test-root-dir",
63+
type=str,
64+
metavar="<directory>",
65+
default=None,
66+
help="if passed, result names will include relative path from this directory",
67+
)
6168

6269
def handle_options(self, defaults):
6370
options = self.context.options
@@ -130,10 +137,10 @@ def _get_test_name(self, test_path):
130137
"""Get the test name from either the test file, or the sub directory
131138
path it's stored in.
132139
"""
133-
# test names are distinguished by their relative path from the
134-
# specified test path.
135-
test_name = os.path.relpath(test_path, self.context.options.test_path)
136-
if self._is_current_directory(test_name):
140+
# Test names are either relative to an explicitly given test root directory, or else we just use the base name.
141+
if self.context.options.test_root_dir is not None:
142+
test_name = os.path.relpath(test_path, self.context.options.test_root_dir)
143+
else:
137144
test_name = os.path.basename(test_path)
138145
return test_name
139146

0 commit comments

Comments
 (0)