77os .environ ["FIREDRAKE_DISABLE_OPTIONS_LEFT" ] = "1"
88
99import pytest
10- from firedrake .petsc import PETSc , get_external_packages
10+ from firedrake .petsc import PETSc , get_external_packages , get_petsc_variables
1111
1212
1313def _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
150154def 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 ))
0 commit comments