From 23cd9128de60aab9cfc12ebc5df3e04ce05fe6ae Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 7 Aug 2023 22:51:41 -0700 Subject: [PATCH] test_type_caster_odr_guard: pytest.skip(...NVCOMPILER...) --- tests/test_type_caster_odr_guard_1.cpp | 7 +++++++ tests/test_type_caster_odr_guard_1.py | 21 +++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/tests/test_type_caster_odr_guard_1.cpp b/tests/test_type_caster_odr_guard_1.cpp index 80deb0478..13a533c82 100644 --- a/tests/test_type_caster_odr_guard_1.cpp +++ b/tests/test_type_caster_odr_guard_1.cpp @@ -89,5 +89,12 @@ TEST_SUBMODULE(type_caster_odr_guard_1, m) { __CUDACC_VER_MINOR__) "." PYBIND11_TOSTRING(__CUDACC_VER_BUILD__); #else py::none(); +#endif + m.attr("NVCOMPILER") = +#if defined(__NVCOMPILER_MAJOR__) + PYBIND11_TOSTRING(__NVCOMPILER_MAJOR__) "." PYBIND11_TOSTRING( + __NVCOMPILER_MINOR__) "." PYBIND11_TOSTRING(__NVCOMPILER_PATCHLEVEL__); +#else + py::none(); #endif } diff --git a/tests/test_type_caster_odr_guard_1.py b/tests/test_type_caster_odr_guard_1.py index dd25b35b7..8b6249043 100644 --- a/tests/test_type_caster_odr_guard_1.py +++ b/tests/test_type_caster_odr_guard_1.py @@ -32,21 +32,22 @@ def test_type_caster_odr_registry_values(): assert "test_type_caster_odr_guard_" in "\n".join(reg_values) +def _count_0_message(tail): + return ( + "type_caster_odr_violation_detected_count() == 0:" + f" {pybind11_tests.compiler_info}, {pybind11_tests.cpp_std}, " + tail + ) + + def test_type_caster_odr_violation_detected_counter(): num_violations = m.type_caster_odr_violation_detected_count() if num_violations is None: pytest.skip("type_caster_odr_violation_detected_count() is None") if num_violations == 0: if m.if_defined__NO_INLINE__: - pytest.skip( - f"type_caster_odr_violation_detected_count() == 0:" - f" {pybind11_tests.compiler_info}, {pybind11_tests.cpp_std}," - " __NO_INLINE__" - ) + pytest.skip(_count_0_message("__NO_INLINE__")) if m.CUDACC is not None: - pytest.skip( - f"type_caster_odr_violation_detected_count() == 0:" - f" {pybind11_tests.compiler_info}, {pybind11_tests.cpp_std}," - " CUDACC = {m.CUDACC}" - ) + pytest.skip(_count_0_message(f"CUDACC = {m.CUDACC}")) + if m.NVCOMPILER is not None: + pytest.skip(_count_0_message(f"NVCOMPILER = {m.NVCOMPILER}")) assert num_violations == 1