From 714bbc47ab6e2de072ec509a4fa290003777abce Mon Sep 17 00:00:00 2001 From: Ismail Ibrahim Quwarah Date: Tue, 12 Nov 2024 15:02:46 +0100 Subject: [PATCH 1/2] Go to discover tests directory after login --- tmt/steps/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tmt/steps/__init__.py b/tmt/steps/__init__.py index 14964a0adc..30ad12f9eb 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 + worktree = self.parent.plan.worktree + test_path = self.parent.plan.discover.tests( + )[-1].path if self.parent.plan.discover.tests() else None + + if worktree and test_path: + test_path = worktree.parent / "discover" / test_path.unrooted() + else: + test_path = worktree + + cwd = cwd or test_path except tmt.utils.GeneralError: self.warn("Failed to push workdir to the guest.") cwd = None From 5480a8c989bfcbbd023a0fa25783a13450fdc58b Mon Sep 17 00:00:00 2001 From: Ismail Ibrahim Quwarah Date: Tue, 12 Nov 2024 15:43:24 +0100 Subject: [PATCH 2/2] Refactor code to remove unnecessary parts --- tmt/steps/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tmt/steps/__init__.py b/tmt/steps/__init__.py index 30ad12f9eb..f582b5e05e 100644 --- a/tmt/steps/__init__.py +++ b/tmt/steps/__init__.py @@ -1958,16 +1958,16 @@ def _login( # Attempt to push the workdir to the guest try: guest.push() - worktree = self.parent.plan.worktree - test_path = self.parent.plan.discover.tests( - )[-1].path if self.parent.plan.discover.tests() else None + 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: - test_path = worktree.parent / "discover" / test_path.unrooted() - else: - test_path = worktree + if worktree and test_path: + cwd = worktree.parent / "discover" / test_path.unrooted() + else: + cwd = worktree - cwd = cwd or test_path except tmt.utils.GeneralError: self.warn("Failed to push workdir to the guest.") cwd = None