Skip to content

Commit

Permalink
Move check & exception deeper
Browse files Browse the repository at this point in the history
  • Loading branch information
Ismail Ibrahim Quwarah committed Sep 24, 2024
1 parent c302010 commit a778269
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 6 additions & 1 deletion tmt/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,12 @@ def _fmf_id(self) -> None:
# TODO: cached_property candidates
@property
def fmf_root(self) -> Path:
return Path(self.node.root)
# Check if fmf root exists
try:
return Path(self.node.root)
except TypeError:
raise tmt.utils.GeneralError(
"No fmf root found. Directory is not initialized with `tmt init`")

@property
def git_root(self) -> Optional[Path]:
Expand Down
9 changes: 1 addition & 8 deletions tmt/steps/prepare/ansible.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,9 @@ def go(

logger.info('playbook-path', playbook_path, 'green')

# Check if fmf root exists
try:
playbook_root = self.step.plan.fmf_root
except TypeError:
raise PrepareError(
"No fmf root found. Directory is not initialized with `tmt init`")

guest.ansible(
playbook_path,
playbook_root=playbook_root,
playbook_root=self.step.plan.fmf_root,
extra_args=self.data.extra_args)

return results
Expand Down

0 comments on commit a778269

Please sign in to comment.