diff --git a/ci/tools/run-tests b/ci/tools/run-tests index cfa7e9d6a7a..658375f7dce 100755 --- a/ci/tools/run-tests +++ b/ci/tools/run-tests @@ -43,7 +43,7 @@ if [[ "${test_module}" == "pathfinder" ]]; then "LD:${CUDA_PATHFINDER_TEST_LOAD_NVIDIA_DYNAMIC_LIB_STRICTNESS} " \ "FH:${CUDA_PATHFINDER_TEST_FIND_NVIDIA_HEADERS_STRICTNESS} " \ "BC:${CUDA_PATHFINDER_TEST_FIND_NVIDIA_BITCODE_LIB_STRICTNESS}" - pytest -ra -s -v "${PYTEST_PARALLEL_ARGS[@]}" tests/ |& tee /tmp/pathfinder_test_log.txt + CUDA_PYTHON_TEST_INSTALLED_WHEELS=1 python -I -m pytest -ra -s -v "${PYTEST_PARALLEL_ARGS[@]}" tests/ |& tee /tmp/pathfinder_test_log.txt # Report the number of "INFO test_" lines (including zero) # to support quick validations based on GHA log archives. line_count=$(awk '/^INFO test_/ {count++} END {print count+0}' /tmp/pathfinder_test_log.txt) @@ -62,9 +62,9 @@ elif [[ "${test_module}" == "bindings" ]]; then "cuda-toolkit==${TEST_CUDA_MAJOR_MINOR}.*" fi echo "Running bindings tests" - ${SANITIZER_CMD} pytest -rxXs -v --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/ + CUDA_PYTHON_TEST_INSTALLED_WHEELS=1 ${SANITIZER_CMD} python -I -m pytest -rxXs -v --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/ if [[ "${SKIP_CYTHON_TEST}" == 0 ]]; then - ${SANITIZER_CMD} pytest -rxXs -v --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/cython + CUDA_PYTHON_TEST_INSTALLED_WHEELS=1 ${SANITIZER_CMD} python -I -m pytest -rxXs -v --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/cython fi popd elif [[ "${test_module}" == "core" || "${test_module}" == nightly-* ]]; then @@ -111,11 +111,11 @@ elif [[ "${test_module}" == "core" || "${test_module}" == nightly-* ]]; then echo "Installed packages before core tests:" pip list echo "Running core tests" - ${SANITIZER_CMD} pytest -rxXs -v --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/ + CUDA_PYTHON_TEST_INSTALLED_WHEELS=1 ${SANITIZER_CMD} python -I -m pytest -rxXs -v --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/ # Currently our CI always installs the latest bindings (from either major version). # This is not compatible with the test requirements. if [[ "${SKIP_CYTHON_TEST}" == 0 ]]; then - ${SANITIZER_CMD} pytest -rxXs -v --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/cython + CUDA_PYTHON_TEST_INSTALLED_WHEELS=1 ${SANITIZER_CMD} python -I -m pytest -rxXs -v --randomly-dont-reorganize "${PYTEST_PARALLEL_ARGS[@]}" tests/cython fi popd elif [[ "${test_module}" == "nightly-cuda-core" ]]; then diff --git a/cuda_bindings/tests/conftest.py b/cuda_bindings/tests/conftest.py index fada7d95601..3a87bee4845 100644 --- a/cuda_bindings/tests/conftest.py +++ b/cuda_bindings/tests/conftest.py @@ -4,6 +4,7 @@ import functools import importlib import inspect +import os import pathlib import sys from contextlib import contextmanager @@ -30,6 +31,17 @@ pytest_plugins = ["cuda_python_test_helpers._pytest_plugin"] +def pytest_sessionstart(session): + if os.environ.get("CUDA_PYTHON_TEST_INSTALLED_WHEELS") == "1": + checkout = pathlib.Path(__file__).resolve().parents[2] + for name in ("cuda.pathfinder", "cuda.bindings"): + module = importlib.import_module(name) + module_path = pathlib.Path(module.__file__).resolve() + print(f"{name}: {module_path}") + if module_path.is_relative_to(checkout): + raise pytest.UsageError(f"{name} imported from the checkout: {module_path}") + + def pytest_configure(config): # When using `parallel-threads` set up mini-plugin to ensure each thread has a CUDA context parallel_threads = getattr(config.option, "parallel_threads", 0) diff --git a/cuda_core/tests/conftest.py b/cuda_core/tests/conftest.py index a8678292422..0f480cf3de4 100644 --- a/cuda_core/tests/conftest.py +++ b/cuda_core/tests/conftest.py @@ -28,6 +28,18 @@ pytest_plugins = ["cuda_python_test_helpers._pytest_plugin"] + +def pytest_sessionstart(session): + if os.environ.get("CUDA_PYTHON_TEST_INSTALLED_WHEELS") == "1": + checkout = pathlib.Path(__file__).resolve().parents[2] + for name in ("cuda.pathfinder", "cuda.bindings", "cuda.core"): + module = importlib.import_module(name) + module_path = pathlib.Path(module.__file__).resolve() + print(f"{name}: {module_path}") + if module_path.is_relative_to(checkout): + raise pytest.UsageError(f"{name} imported from the checkout: {module_path}") + + from helpers.constants import POOL_SIZE from helpers.memory import skip_if_pinned_memory_unsupported diff --git a/cuda_pathfinder/tests/conftest.py b/cuda_pathfinder/tests/conftest.py index e8a5e11b391..32b06f33c11 100644 --- a/cuda_pathfinder/tests/conftest.py +++ b/cuda_pathfinder/tests/conftest.py @@ -2,9 +2,23 @@ # SPDX-License-Identifier: Apache-2.0 +import importlib +import os +from pathlib import Path + import pytest +def pytest_sessionstart(session): + if os.environ.get("CUDA_PYTHON_TEST_INSTALLED_WHEELS") == "1": + checkout = Path(__file__).resolve().parents[2] + module = importlib.import_module("cuda.pathfinder") + module_path = Path(module.__file__).resolve() + print(f"{module.__name__}: {module_path}") + if module_path.is_relative_to(checkout): + raise pytest.UsageError(f"{module.__name__} imported from the checkout: {module_path}") + + def pytest_configure(config): config.custom_info = []