test_builtin_repo: add a marker to skip the test if builtin is not available (#50476)

This commit is contained in:
Tamara Dahlgren 2025-05-15 10:50:42 -07:00 committed by GitHub
parent f96def28cb
commit 37abfc7541
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 0 deletions

View File

@ -111,6 +111,7 @@ def split(output):
pkg = spack.main.SpackCommand("pkg") pkg = spack.main.SpackCommand("pkg")
@pytest.mark.requires_builtin("builtin repository path must exist")
def test_builtin_repo(): def test_builtin_repo():
assert spack.repo.builtin_repo() is spack.repo.PATH.get_repo("builtin") assert spack.repo.builtin_repo() is spack.repo.PATH.get_repo("builtin")

View File

@ -2072,6 +2072,11 @@ def pytest_runtest_setup(item):
if only_windows_marker and sys.platform != "win32": if only_windows_marker and sys.platform != "win32":
pytest.skip(*only_windows_marker.args) pytest.skip(*only_windows_marker.args)
# Skip tests marked "requires_builtin" if builtin repo is required
requires_builtin_marker = item.get_closest_marker(name="requires_builtin")
if requires_builtin_marker and not os.path.exists(spack.paths.packages_path):
pytest.skip(*requires_builtin_marker.args)
def _sequential_executor(*args, **kwargs): def _sequential_executor(*args, **kwargs):
return spack.util.parallel.SequentialExecutor() return spack.util.parallel.SequentialExecutor()

View File

@ -14,3 +14,4 @@ markers =
disable_clean_stage_check: avoid failing tests if there are leftover files in the stage area disable_clean_stage_check: avoid failing tests if there are leftover files in the stage area
not_on_windows: mark tests that are skipped on Windows not_on_windows: mark tests that are skipped on Windows
only_windows: mark tests that are skipped everywhere but Windows only_windows: mark tests that are skipped everywhere but Windows
requires_builtin: tests that require the builtin repository