Skip to content

Commit

Permalink
Do not present discover phase name as a part of test name
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Havlin committed Apr 24, 2024
1 parent 0b0398a commit 61109bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2714,6 +2714,7 @@ class Tree(tmt.utils.Common):
def __init__(self,
*,
path: Optional[Path] = None,
name: Optional[str] = None,
tree: Optional[fmf.Tree] = None,
fmf_context: Optional[FmfContext] = None,
logger: tmt.log.Logger) -> None:
Expand All @@ -2723,6 +2724,7 @@ def __init__(self,
self.inject_logger(logger)

self._path = path or Path.cwd()
self._name = name or ''
self._tree = tree
self._custom_fmf_context = fmf_context or FmfContext()

Expand Down Expand Up @@ -2885,11 +2887,12 @@ def tests(

def name_filter(nodes: Iterable[fmf.Tree]) -> list[fmf.Tree]:
""" Filter nodes based on names provided on the command line """
prefix = f'{self.name}::' if self.name else ''
if not cmd_line_names:
return list(nodes)
return [
node for node in nodes
if any(re.search(name, node.name) for name in cmd_line_names)]
if any(re.search(name, f'{prefix}{node.name}') for name in cmd_line_names)]

# Append post filter to support option --enabled or --disabled
if Test._opt('enabled'):
Expand Down
2 changes: 1 addition & 1 deletion tmt/steps/discover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def go(self, force: bool = False) -> None:
self._tests[phase.name] = []

# Prefix test name only if multiple plugins configured
prefix = f'/{phase.name}' if len(self.phases()) > 1 else ''
prefix = f'{phase.name}::' if len(self.phases()) > 1 else ''
# Check discovered tests, modify test name/path
for test in phase.tests(enabled=True):
test.name = f"{prefix}{test.name}"
Expand Down
1 change: 1 addition & 0 deletions tmt/steps/discover/fmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ def do_the_discovery(self, path: Optional[Path] = None) -> None:
tree = tmt.Tree(
logger=self._logger,
path=tree_path,
name=self.name,
fmf_context=self.step.plan._fmf_context)
self._tests = tree.tests(
filters=filters,
Expand Down

0 comments on commit 61109bc

Please sign in to comment.