Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions tmt/steps/execute/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from tmt.steps.context.reboot import RebootContext
from tmt.steps.context.restart import RestartContext
from tmt.steps.context.restraint import RestraintContext
from tmt.steps.discover import Discover, DiscoverPlugin, DiscoverStepData
from tmt.steps.discover import Discover, DiscoverPlugin
from tmt.utils import (
Command,
CommandOutput,
Expand All @@ -54,6 +54,7 @@
import tmt.base.plan
import tmt.result
import tmt.steps.discover
from tmt.steps.discover.fmf import DiscoverFmf

# Test data and checks directory names
TEST_DATA = 'data'
Expand Down Expand Up @@ -694,18 +695,19 @@ def go(
logger.verbose('exit-first', self.data.exit_first, 'green', level=2)

@property
def discover(self) -> Discover:
def discover(self) -> Union[Discover, 'DiscoverFmf']:
Comment thread
psss marked this conversation as resolved.
"""
Return discover plugin instance
Return discover step or discover plugin instance

This is used for iterating over discovered tests and setting the
workdir. During the upgrade phase of the upgrade plugin it
returns instance of DiscoverFmf with upgrade tasks.

FIXME: Find a way how to handle this more cleanly.
"""
# This is necessary so that upgrade plugin can inject a fake discover

return self.step.plan.discover

@discover.setter
def discover(self, plugin: Optional[DiscoverPlugin[DiscoverStepData]]) -> None:
self._discover = plugin

def prepare_tests(self, guest: Guest, logger: tmt.log.Logger) -> list[TestInvocation]:
"""
Prepare discovered tests for testing
Expand Down
14 changes: 6 additions & 8 deletions tmt/steps/execute/upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,21 +236,19 @@ def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)
self._discover_upgrade: Optional[DiscoverFmf] = None

@property # type:ignore[override]
@property
def discover(self) -> Union[Discover, DiscoverFmf]:
"""
Return discover plugin instance
Return discover step or discover plugin instance

If we are in the second phase (upgrade), take tests from our
fake discover plugin.
"""

# If we are in the second phase (upgrade), take tests from our fake
# discover plugin.
if self._discover_upgrade:
return self._discover_upgrade
return self.step.plan.discover

@discover.setter
def discover(self, plugin: Optional[DiscoverPlugin[DiscoverStepData]]) -> None:
self._discover = plugin
return self.step.plan.discover

@property
def tasks(
Expand Down
Loading