Skip to content

Commit

Permalink
Simplify the implementation a bit
Browse files Browse the repository at this point in the history
The extra action for handling options should not be needed.
Plus it breaks use cases like `tmt try --epel` with tests.
Included a few minor style adjustments.
  • Loading branch information
psss committed Sep 23, 2024
1 parent aba2d1a commit 4d5bf16
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tests/try/basic/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rlJournalStart
rlPhaseStartTest "Epel"
rlRun -s "./epel.exp"
rlAssertGrep "Let's try.*/plans/basic" $rlRun_LOG
rlAssertGrep "out: PLAY \[Enable EPEL repositories\]" $rlRun_LOG
rlAssertGrep "PLAY \[Enable EPEL repositories\]" $rlRun_LOG
rlAssertGrep "Run .* successfully finished. Bye for now!" $rlRun_LOG
rlPhaseEnd

Expand Down
22 changes: 6 additions & 16 deletions tmt/trying.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Action(enum.Enum):
START_LOGIN = "-", "jump directly to login after start"
START_ASK = "-", "do nothing without first asking the user"
START_TEST = "-", "start directly with executing detected tests"
START_CLI_OPTION = "-", "do requested cli option then ask the user"

@property
def key(self) -> str:
Expand Down Expand Up @@ -313,13 +312,6 @@ def action_start_ask(self, plan: Plan) -> None:

plan.provision.go()

def action_start_cli_option(self, plan: Plan) -> None:
""" Do requested cli option """
self.action_start(plan)

plan.provision.go()
plan.prepare.go()

def action_test(self, plan: Plan) -> None:
""" Test again """
plan.discover.go(force=True)
Expand Down Expand Up @@ -414,14 +406,14 @@ def action_quit(self, plan: Plan) -> None:
self.print(f"Run {run_id} successfully finished. Bye for now!")

def handle_options(self, plan: Plan) -> None:
"""Choose requested cli option"""
""" Choose requested cli option """

for o in self.cli_options:
if self.opt(o):
getattr(self, f"handle_{o}")(plan)
for option in self.cli_options:
if self.opt(option):
getattr(self, f"handle_{option}")(plan)

def handle_epel(self, plan: Plan) -> None:
""" Enable EPEL repository"""
""" Enable EPEL repository """

# tmt run prepare --how feature --epel enabled
data: _RawPrepareFeatureStepData = {
Expand Down Expand Up @@ -451,7 +443,7 @@ def go(self) -> None:
self.welcome()
self.save()

# Set the default verbosity level
# Set the default verbosity level, handle options
for plan in self.plans:
self.handle_options(plan)
self.action_verbose(plan)
Expand All @@ -461,8 +453,6 @@ def go(self) -> None:
action = Action.START_LOGIN
elif self.opt("ask"):
action = Action.START_ASK
elif any(self.opt(o) for o in self.cli_options):
action = Action.START_CLI_OPTION
elif self.tests:
action = Action.START_TEST
else:
Expand Down

0 comments on commit 4d5bf16

Please sign in to comment.