Skip to content

Commit 4bc9941

Browse files
authored
[scripts] Adding run_tests.sh script (NVIDIA#953)
* Adding script that runs all nested modules unit tests. * updating legal * renaming run_all_tests.sh to run_tests.sh * removing unnecessary file print * Removing unnecessary prints * Using pytest.mark * :Using pytest.mark # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # Date: Tue Sep 9 15:07:24 2025 -0700 # # On branch rparolin/run_test_all # Your branch is up to date with 'origin/rparolin/run_test_all'. # # Changes to be committed: # new file: conftest.py # new file: pytest.ini # modified: scripts/run_tests.sh # modified: tests/integration/test_smoke.py # * Fixing filepath in comments. * Removing empty function * Removing integration test placeholder * docs: changing to * Running examples and also running cuda_bindings tests both enabled/disabled flag: CUDA_PYTHON_CUDA_PER_THREAD_DEFAULT_STREAM * run_all_tests.sh → run_tests.sh (3x)
1 parent 9922034 commit 4bc9941

5 files changed

Lines changed: 377 additions & 7 deletions

File tree

conftest.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import os
5+
import pytest
6+
7+
8+
def pytest_collection_modifyitems(config, items):
9+
cuda_home = os.environ.get("CUDA_HOME")
10+
for item in items:
11+
nodeid = item.nodeid.replace("\\", "/")
12+
13+
# Package markers by path
14+
if (
15+
nodeid.startswith("cuda_pathfinder/tests/")
16+
or "/cuda_pathfinder/tests/" in nodeid
17+
):
18+
item.add_marker(pytest.mark.pathfinder)
19+
if (
20+
nodeid.startswith("cuda_bindings/tests/")
21+
or "/cuda_bindings/tests/" in nodeid
22+
):
23+
item.add_marker(pytest.mark.bindings)
24+
if nodeid.startswith("cuda_core/tests/") or "/cuda_core/tests/" in nodeid:
25+
item.add_marker(pytest.mark.core)
26+
27+
# Smoke tests
28+
if nodeid.startswith("tests/integration/") or "/tests/integration/" in nodeid:
29+
item.add_marker(pytest.mark.smoke)
30+
31+
# Cython tests (any tests/cython subtree)
32+
if (
33+
"/tests/cython/" in nodeid
34+
or nodeid.endswith("/tests/cython")
35+
or ("/cython/" in nodeid and "/tests/" in nodeid)
36+
):
37+
item.add_marker(pytest.mark.cython)
38+
39+
# Gate core cython tests on CUDA_HOME
40+
if "core" in item.keywords and not cuda_home:
41+
item.add_marker(
42+
pytest.mark.skip(
43+
reason="CUDA_HOME not set; skipping core cython tests"
44+
)
45+
)

cuda_core/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ To run these tests:
1616
* `python -m pytest tests/` with editable installations
1717
* `pytest tests/` with installed packages
1818

19+
Alternatively, from the repository root you can use a simple script:
20+
21+
* `./scripts/run_tests.sh core` to run only `cuda_core` tests
22+
* `./scripts/run_tests.sh` to run all package tests (pathfinder → bindings → core)
23+
* `./scripts/run_tests.sh smoke` to run meta-level smoke tests under `tests/integration`
24+
1925
### Cython Unit Tests
2026

2127
Cython tests are located in `tests/cython` and need to be built. These builds have the same CUDA Toolkit header requirements as [those of cuda.bindings](https://nvidia.github.io/cuda-python/cuda-bindings/latest/install.html#requirements) where the major.minor version must match `cuda.bindings`. To build them:

cuda_pathfinder/tests/conftest.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ def pytest_configure(config):
99
config.custom_info = []
1010

1111

12-
def pytest_terminal_summary(terminalreporter, exitstatus, config): # noqa: ARG001
13-
if config.custom_info:
14-
terminalreporter.write_sep("=", "INFO summary")
15-
for msg in config.custom_info:
16-
terminalreporter.line(f"INFO {msg}")
17-
18-
1912
@pytest.fixture
2013
def info_summary_append(request):
2114
def _append(message):

pytest.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
[pytest]
5+
testpaths =
6+
cuda_pathfinder/tests
7+
cuda_bindings/tests
8+
cuda_core/tests
9+
tests/integration
10+
11+
markers =
12+
pathfinder: tests for cuda_pathfinder
13+
bindings: tests for cuda_bindings
14+
core: tests for cuda_core
15+
cython: cython tests
16+
smoke: meta-level smoke tests

0 commit comments

Comments
 (0)