Skip to content

Commit c984f72

Browse files
committed
adding pytest marker
1 parent 67601d1 commit c984f72

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

tests/firedrake/conftest.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
os.environ["FIREDRAKE_DISABLE_OPTIONS_LEFT"] = "1"
88

99
import pytest
10-
from firedrake.petsc import PETSc, get_external_packages
10+
from firedrake.petsc import PETSc, get_external_packages, get_petsc_variables
1111

1212

1313
def _skip_test_dependency(dependency):
@@ -145,11 +145,21 @@ def pytest_configure(config):
145145
"markers",
146146
"skipnetgen: mark as skipped if netgen and ngsPETSc is not installed"
147147
)
148+
config.addinivalue_line(
149+
"markers",
150+
"skipcuda: mark as skipped if CUDA is not available"
151+
)
148152

149153

150154
def pytest_collection_modifyitems(session, config, items):
151155
from firedrake.utils import complex_mode, SLATE_SUPPORTS_COMPLEX
152156

157+
try:
158+
get_petsc_variables()["CUDA_VERSION"]
159+
cuda_unavailable = False
160+
except:
161+
cuda_unavailable = True
162+
153163
for item in items:
154164
if complex_mode:
155165
if item.get_closest_marker("skipcomplex") is not None:
@@ -160,6 +170,10 @@ def pytest_collection_modifyitems(session, config, items):
160170
if item.get_closest_marker("skipreal") is not None:
161171
item.add_marker(pytest.mark.skip(reason="Test makes no sense unless in complex mode"))
162172

173+
if cuda_unavailable:
174+
if item.get_closest_marker("skipcuda") is not None:
175+
item.add_marker(pytest.mark.skip(reason="CUDA not available"))
176+
163177
for dep, marker, reason in dependency_skip_markers_and_reasons:
164178
if _skip_test_dependency(dep) and item.get_closest_marker(marker) is not None:
165179
item.add_marker(pytest.mark.skip(reason))

tests/firedrake/cuda/test_poisson_offloading_pc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pytest
44

55
# TODO: add marker for cuda pytests and something to check if cuda memory was really used
6+
@pytest.mark.skipcuda
67
@pytest.mark.parametrize("ksp_type, pc_type", [("cg", "sor"), ("cg", "gamg"), ("preonly", "lu")])
78
def test_poisson_on_cuda(ksp_type, pc_type):
89

tests/firedrake/cuda/test_wave_equation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import pytest
77

88

9-
# TODO: add marker for cuda pytestss
9+
@pytest.mark.skipcuda
1010
def test_kmv_wave_propagation_cuda():
1111
nested_parameters = {
1212
"ksp_type": "preonly",

0 commit comments

Comments
 (0)