Use test tree consistently with dist-git fmf#4973
Conversation
There was a problem hiding this comment.
Code Review
This pull request simplifies the local repository fetching and dist-git source processing in tmt/steps/discover/fmf.py by removing several conditional checks related to dist_git_source. Feedback suggests restoring the and not self.data.dist_git_source check when validating paths, as dist-git sources cannot be verified until extraction. Additionally, it is recommended to set requires_git to True and raise an error if no git repository is found when dist_git_source is enabled to prevent a regression where the git repository is not copied to test_dir.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if path and not path.is_dir(): | ||
| raise tmt.utils.DiscoverError(f"Provided path '{path}' is not a directory.") | ||
| if self.data.dist_git_source: | ||
| # Ensure we're in a git repo when extracting dist-git sources | ||
| if self.step.plan.fmf_root is None: | ||
| raise tmt.utils.DiscoverError("No git repository found for DistGit.") | ||
| git_root = tmt.utils.git.git_root( | ||
| fmf_root=self.step.plan.fmf_root, logger=self._logger | ||
| ) | ||
| if not git_root: | ||
| raise tmt.utils.DiscoverError(f"{self.step.plan.fmf_root} is not a git repo") | ||
| else: | ||
| if fmf_root is None: | ||
| raise tmt.utils.DiscoverError("No metadata found in the current directory.") | ||
| # Check git repository root (use fmf root if not found) | ||
| git_root = tmt.utils.git.git_root(fmf_root=fmf_root, logger=self._logger) | ||
| if not git_root: | ||
| self.debug(f"Git root not found, using '{fmf_root}.'") | ||
| git_root = fmf_root | ||
| # Set path to relative path from the git root to fmf root | ||
| path = fmf_root.resolve().relative_to( | ||
| git_root.resolve() if requires_git else fmf_root.resolve() | ||
| ) | ||
|
|
||
| if fmf_root is None: | ||
| raise tmt.utils.DiscoverError("No metadata found in the current directory.") | ||
| # Check git repository root (use fmf root if not found) | ||
| git_root = tmt.utils.git.git_root(fmf_root=fmf_root, logger=self._logger) | ||
| if not git_root: | ||
| self.debug(f"Git root not found, using '{fmf_root}.'") | ||
| git_root = fmf_root | ||
| # Set path to relative path from the git root to fmf root | ||
| path = fmf_root.resolve().relative_to( | ||
| git_root.resolve() if requires_git else fmf_root.resolve() | ||
| ) |
There was a problem hiding this comment.
Restore the and not self.data.dist_git_source check when validating path, as the path for dist-git sources cannot be verified until they are extracted. Additionally, set requires_git to True and raise an error if no git repository is found when dist_git_source is enabled to prevent a regression where the git repository is not copied to test_dir when the fmf root is a subdirectory of the git root.
if path and not path.is_dir() and not self.data.dist_git_source:
raise tmt.utils.DiscoverError(f"Provided path '{path}' is not a directory.")
if fmf_root is None:
raise tmt.utils.DiscoverError("No metadata found in the current directory.")
if self.data.dist_git_source:
requires_git = True
# Check git repository root (use fmf root if not found)
git_root = tmt.utils.git.git_root(fmf_root=fmf_root, logger=self._logger)
if not git_root:
if self.data.dist_git_source:
raise tmt.utils.DiscoverError("No git repository found for DistGit.")
self.debug(f"Git root not found, using '{fmf_root}.'")
git_root = fmf_root
# Set path to relative path from the git root to fmf root
path = fmf_root.resolve().relative_to(
git_root.resolve() if requires_git else fmf_root.resolve()
)References
- Use direct imperatives and be concise with no fluff. (link)
|
One Test Case is still failing. |
|
Here is the run tree before Details$ tree -a -I .git
.
├── cleanup
│ └── step.yaml
├── data
│ ├── plan-source-script.sh
│ └── variables.env-default-0
├── discover
│ ├── default-0
│ │ ├── source
│ │ │ ├── demo-1.0-build
│ │ │ ├── demo.spec
│ │ │ ├── .fmf
│ │ │ │ └── version
│ │ │ ├── mock_sources
│ │ │ ├── outsider
│ │ │ ├── sources
│ │ │ ├── SPECPARTS
│ │ │ ├── SRPMS
│ │ │ ├── top_test.fmf
│ │ │ ├── with-tmt-1
│ │ │ │ ├── .fmf
│ │ │ │ │ └── version
│ │ │ │ ├── from-source.txt
│ │ │ │ └── tests
│ │ │ │ └── from-source.fmf
│ │ │ └── with-tmt-1.tgz
│ │ └── tests
│ │ ├── .fmf
│ │ │ └── version
│ │ ├── from-source.txt
│ │ └── tests
│ │ └── from-source.fmf
│ ├── step.yaml
│ └── tests.yaml
├── execute
│ ├── results.yaml
│ └── step.yaml
├── finish
│ └── step.yaml
├── prepare
│ ├── results.yaml
│ └── step.yaml
├── provision
│ ├── default-0
│ │ └── podman-run-environment
│ ├── guests.yaml
│ └── step.yaml
├── report
│ └── step.yaml
└── tree
├── demo.spec
├── .fmf
│ └── version
├── mock_sources
├── sources
├── top_test.fmf
└── with-tmt-1.tgz
24 directories, 33 filesafter Details$ tree -a -I .git
.
├── cleanup
│ └── step.yaml
├── data
│ ├── plan-source-script.sh
│ └── variables.env-default-0
├── discover
│ ├── default-0
│ │ ├── source
│ │ │ ├── demo-1.0-build
│ │ │ ├── demo.spec
│ │ │ ├── .fmf
│ │ │ │ └── version
│ │ │ ├── mock_sources
│ │ │ ├── outsider
│ │ │ ├── sources
│ │ │ ├── SPECPARTS
│ │ │ ├── SRPMS
│ │ │ ├── top_test.fmf
│ │ │ ├── with-tmt-1
│ │ │ │ ├── .fmf
│ │ │ │ │ └── version
│ │ │ │ ├── from-source.txt
│ │ │ │ └── tests
│ │ │ │ └── from-source.fmf
│ │ │ └── with-tmt-1.tgz
│ │ └── tests
│ │ ├── demo.spec
│ │ ├── .fmf
│ │ │ └── version
│ │ ├── from-source.txt
│ │ ├── mock_sources
│ │ ├── sources
│ │ ├── tests
│ │ │ └── from-source.fmf
│ │ ├── top_test.fmf
│ │ └── with-tmt-1.tgz
│ ├── step.yaml
│ └── tests.yaml
├── execute
│ ├── results.yaml
│ └── step.yaml
├── finish
│ └── step.yaml
├── prepare
│ ├── results.yaml
│ └── step.yaml
├── provision
│ ├── default-0
│ │ └── podman-run-environment
│ ├── guests.yaml
│ └── step.yaml
├── report
│ └── step.yaml
└── tree
├── demo.spec
├── .fmf
│ └── version
├── mock_sources
├── sources
├── top_test.fmf
└── with-tmt-1.tgz
24 directories, 38 filesand the archive content Details$ tar -tf with-tmt-1.tgz
with-tmt-1/
with-tmt-1/from-source.txt
with-tmt-1/.fmf/
with-tmt-1/.fmf/version
with-tmt-1/tests/
with-tmt-1/tests/from-source.fmf
outsiderThe issue here is we have 2 paths:
The old approach basically had an empty test tree so the same copy operation that A quick fix would be in the non- Long-term I would instead want to clean this up as:
@therazix sounds good to you |
|
/packit retest-failed |
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Fixes a regression in #4915 where it would not get the appropriate
refwhen requested using the local git repository.Incidentally, the non-dist-git approach already behaves as we want it with and without
url, so we can (should be) using thetest_dirdirectly. We can thus just drop the special handling ofdist-gitin the_fetch_local_repositoryalso.