-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy pathconftest.py
More file actions
58 lines (45 loc) · 2.1 KB
/
conftest.py
File metadata and controls
58 lines (45 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import os
import pytest
from cuda.pathfinder import get_cuda_path_or_home
# Please keep in sync with the copy in cuda_core/tests/conftest.py.
def _cuda_headers_available() -> bool:
"""Return True if CUDA headers are available, False if no CUDA path is set.
Raises AssertionError if a CUDA path is set but has no include/ subdirectory.
"""
cuda_path = get_cuda_path_or_home()
if cuda_path is None:
return False
assert os.path.isdir(os.path.join(cuda_path, "include")), (
f"CUDA path {cuda_path} does not contain an 'include' subdirectory"
)
return True
def pytest_collection_modifyitems(config, items): # noqa: ARG001
have_headers = _cuda_headers_available()
for item in items:
nodeid = item.nodeid.replace("\\", "/")
# Package markers by path
if nodeid.startswith("cuda_pathfinder/tests/") or "/cuda_pathfinder/tests/" in nodeid:
item.add_marker(pytest.mark.pathfinder)
if nodeid.startswith("cuda_bindings/tests/") or "/cuda_bindings/tests/" in nodeid:
item.add_marker(pytest.mark.bindings)
if nodeid.startswith("cuda_core/tests/") or "/cuda_core/tests/" in nodeid:
item.add_marker(pytest.mark.core)
# Smoke tests
if nodeid.startswith("tests/integration/") or "/tests/integration/" in nodeid:
item.add_marker(pytest.mark.smoke)
# Cython tests (any tests/cython subtree)
if (
"/tests/cython/" in nodeid
or nodeid.endswith("/tests/cython")
or ("/cython/" in nodeid and "/tests/" in nodeid)
):
item.add_marker(pytest.mark.cython)
# Gate core cython tests on CUDA_PATH
if "core" in item.keywords and not have_headers:
item.add_marker(
pytest.mark.skip(
reason="Environment variable CUDA_PATH or CUDA_HOME is not set: skipping core cython tests"
)
)