diff --git a/tmt/steps/__init__.py b/tmt/steps/__init__.py index 14964a0adc..f582b5e05e 100644 --- a/tmt/steps/__init__.py +++ b/tmt/steps/__init__.py @@ -1958,7 +1958,16 @@ def _login( # Attempt to push the workdir to the guest try: guest.push() - cwd = cwd or self.parent.plan.worktree + if not cwd: + worktree = self.parent.plan.worktree + tests = self.parent.plan.discover.tests() + test_path = tests[-1].path if tests else None + + if worktree and test_path: + cwd = worktree.parent / "discover" / test_path.unrooted() + else: + cwd = worktree + except tmt.utils.GeneralError: self.warn("Failed to push workdir to the guest.") cwd = None