File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: Apache-2.0
33
44
5+ import os
6+
57import pytest
68
79from cuda .pathfinder import get_cuda_path_or_home
810
911
12+ # Please keep in sync with the copy in cuda_core/tests/conftest.py.
13+ def _cuda_headers_available () -> bool :
14+ """Return True if CUDA headers are available, False if no CUDA path is set.
15+
16+ Raises AssertionError if a CUDA path is set but has no include/ subdirectory.
17+ """
18+ cuda_path = get_cuda_path_or_home ()
19+ if cuda_path is None :
20+ return False
21+ assert os .path .isdir (os .path .join (cuda_path , "include" )), (
22+ f"CUDA path { cuda_path } does not contain an 'include' subdirectory"
23+ )
24+ return True
25+
26+
1027def pytest_collection_modifyitems (config , items ): # noqa: ARG001
11- cuda_home = get_cuda_path_or_home ()
28+ have_headers = _cuda_headers_available ()
1229 for item in items :
1330 nodeid = item .nodeid .replace ("\\ " , "/" )
1431
@@ -32,6 +49,10 @@ def pytest_collection_modifyitems(config, items): # noqa: ARG001
3249 ):
3350 item .add_marker (pytest .mark .cython )
3451
35- # Gate core cython tests on CUDA_HOME
36- if "core" in item .keywords and not cuda_home :
37- item .add_marker (pytest .mark .skip (reason = "CUDA_HOME not set; skipping core cython tests" ))
52+ # Gate core cython tests on CUDA_PATH
53+ if "core" in item .keywords and not have_headers :
54+ item .add_marker (
55+ pytest .mark .skip (
56+ reason = "Environment variable CUDA_PATH or CUDA_HOME is not set: skipping core cython tests"
57+ )
58+ )
Original file line number Diff line number Diff line change @@ -254,7 +254,22 @@ def test_something(memory_resource_factory):
254254 return request .param
255255
256256
257+ # Please keep in sync with the copy in the top-level conftest.py.
258+ def _cuda_headers_available () -> bool :
259+ """Return True if CUDA headers are available, False if no CUDA path is set.
260+
261+ Raises AssertionError if a CUDA path is set but has no include/ subdirectory.
262+ """
263+ cuda_path = get_cuda_path_or_home ()
264+ if cuda_path is None :
265+ return False
266+ assert os .path .isdir (os .path .join (cuda_path , "include" )), (
267+ f"CUDA path { cuda_path } does not contain an 'include' subdirectory"
268+ )
269+ return True
270+
271+
257272skipif_need_cuda_headers = pytest .mark .skipif (
258- get_cuda_path_or_home () is None ,
273+ not _cuda_headers_available () ,
259274 reason = "need CUDA header" ,
260275)
You can’t perform that action at this time.
0 commit comments