Skip to content

Commit f0958c4

Browse files
Merge pull request #1326 from linsword13/spack-runner-fixture
Add a spack-runner pytest fixture
2 parents f945ffa + 80c0f75 commit f0958c4

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import ramble.stage
2626
import ramble.workspace
2727
from ramble.fetch_strategy import FetchError, FetchStrategyComposite, URLFetchStrategy
28+
from ramble.pkg_man.builtin.spack_lightweight import SpackRunner
29+
from ramble.util.command_runner import RunnerError
2830
from ramble.util.file_util import is_dry_run_path
2931

3032
import spack.platforms
@@ -172,6 +174,15 @@ def mock_wms_repo_path():
172174
yield ramble.repository.Repo(ramble.paths.mock_builtin_path, obj_type)
173175

174176

177+
@pytest.fixture
178+
def ensure_spack_runner():
179+
"""Fixture to check for spack runner and skip if not found."""
180+
try:
181+
SpackRunner()
182+
except RunnerError as e:
183+
pytest.skip(f"Spack runner not found, skipping test: {e}")
184+
185+
175186
def _get_obj_repo_path(obj_type, extra_repo_path):
176187
repos = []
177188
# extra_repo_path takes precedence

lib/ramble/ramble/test/end_to_end/package_manager_requirements.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212

1313
import ramble.workspace
1414
from ramble.main import RambleCommand
15-
from ramble.pkg_man.builtin.spack_lightweight import SpackRunner, ValidationFailedError
16-
from ramble.util.command_runner import RunnerError
15+
from ramble.pkg_man.builtin.spack_lightweight import ValidationFailedError
1716

1817
pytestmark = pytest.mark.usefixtures("mutable_config", "mutable_mock_workspace_path")
1918

2019
workspace = RambleCommand("workspace")
2120

2221

2322
@pytest.mark.long
24-
def test_package_manager_requirements_zlib(mock_applications, mock_modifiers, workspace_name):
23+
def test_package_manager_requirements_zlib(
24+
mock_applications, mock_modifiers, workspace_name, ensure_spack_runner
25+
):
2526
test_config = """
2627
ramble:
2728
variants:
@@ -47,11 +48,6 @@ def test_package_manager_requirements_zlib(mock_applications, mock_modifiers, wo
4748
packages: []
4849
"""
4950

50-
try:
51-
SpackRunner()
52-
except RunnerError as e:
53-
pytest.skip(e)
54-
5551
with ramble.workspace.create(workspace_name) as ws:
5652
ws.write()
5753

@@ -73,7 +69,9 @@ def test_package_manager_requirements_zlib(mock_applications, mock_modifiers, wo
7369
assert "debug: true" in data
7470

7571

76-
def test_package_manager_requirements_error(mock_applications, mock_modifiers, workspace_name):
72+
def test_package_manager_requirements_error(
73+
mock_applications, mock_modifiers, workspace_name, ensure_spack_runner
74+
):
7775
test_config = """
7876
ramble:
7977
variants:
@@ -99,11 +97,6 @@ def test_package_manager_requirements_error(mock_applications, mock_modifiers, w
9997
packages: []
10098
"""
10199

102-
try:
103-
SpackRunner()
104-
except RunnerError as e:
105-
pytest.skip(e)
106-
107100
with ramble.workspace.create(workspace_name) as ws:
108101
ws.write()
109102

0 commit comments

Comments
 (0)