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 May 29, 2024
1 parent ae941d1 commit dacecf2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,8 @@ def __init__(self,
path: Optional[Path] = None,
tree: Optional[fmf.Tree] = None,
fmf_context: Optional[FmfContext] = None,
logger: tmt.log.Logger) -> None:
logger: tmt.log.Logger,
phase_name: Optional[str] = None) -> None:
""" Initialize tmt tree from directory path or given fmf tree """

# TODO: not calling parent __init__ on purpose?
Expand All @@ -2743,6 +2744,7 @@ def __init__(self,
self._path = path or Path.cwd()
self._tree = tree
self._custom_fmf_context = fmf_context or FmfContext()
self.phase_name = phase_name

@classmethod
def grow(
Expand Down Expand Up @@ -2903,11 +2905,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.phase_name}::' if self.phase_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 @@ -343,7 +343,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
3 changes: 2 additions & 1 deletion tmt/steps/discover/fmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ def do_the_discovery(self, path: Optional[Path] = None) -> None:
tree = tmt.Tree(
logger=self._logger,
path=tree_path,
fmf_context=self.step.plan._fmf_context)
fmf_context=self.step.plan._fmf_context,
phase_name=self.name)
self._tests = tree.tests(
filters=filters,
names=names,
Expand Down
2 changes: 1 addition & 1 deletion tmt/trying.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def check_tests(self) -> None:
self.debug("Matching tests found\n" + tmt.utils.format_value(self.tests))

# Inject the test filtering options into the Test class
options = {"names": [f"^{re.escape(test.name)}$" for test in self.tests]}
options = {"names": [f"^.*::{re.escape(test.name)}$" for test in self.tests]}
tmt.Test.store_cli_invocation(context=None, options=options)

def get_default_plans(self, run: tmt.base.Run) -> list[Plan]:
Expand Down

0 comments on commit dacecf2

Please sign in to comment.