Skip to content

Commit

Permalink
We don't have to check cwd if there's no test_path
Browse files Browse the repository at this point in the history
  • Loading branch information
psss committed Dec 9, 2024
1 parent 30a96c5 commit b67e154
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tmt/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1959,17 +1959,20 @@ def _login(
try:
guest.push()
if not cwd:
# Use path of the last executed test as the default
# current working directory
worktree = self.parent.plan.worktree
tests = self.parent.plan.discover.tests()
test_path = tests[-1].path if tests else None
try:
if test_path is None or worktree is None:
cwd = worktree
if worktree and test_path:
else:
try:
cwd = worktree.parent / "discover" / test_path.unrooted()
guest.execute(tmt.utils.ShellScript("/bin/true"),
interactive=True, cwd=cwd, env=env)
except RunError:
cwd = worktree
guest.execute(tmt.utils.ShellScript("/bin/true"),
interactive=True, cwd=cwd, env=env)
except RunError:
cwd = worktree

except tmt.utils.GeneralError:
self.warn("Failed to push workdir to the guest.")
Expand Down

0 comments on commit b67e154

Please sign in to comment.