test_type_caster_odr_guard: pytest.skip(...NVCOMPILER...)

This commit is contained in:
Ralf W. Grosse-Kunstleve 2023-08-07 22:51:41 -07:00
parent b9e956b002
commit 23cd9128de
2 changed files with 18 additions and 10 deletions

View File

@ -89,5 +89,12 @@ TEST_SUBMODULE(type_caster_odr_guard_1, m) {
__CUDACC_VER_MINOR__) "." PYBIND11_TOSTRING(__CUDACC_VER_BUILD__); __CUDACC_VER_MINOR__) "." PYBIND11_TOSTRING(__CUDACC_VER_BUILD__);
#else #else
py::none(); 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 #endif
} }

View File

@ -32,21 +32,22 @@ def test_type_caster_odr_registry_values():
assert "test_type_caster_odr_guard_" in "\n".join(reg_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(): def test_type_caster_odr_violation_detected_counter():
num_violations = m.type_caster_odr_violation_detected_count() num_violations = m.type_caster_odr_violation_detected_count()
if num_violations is None: if num_violations is None:
pytest.skip("type_caster_odr_violation_detected_count() is None") pytest.skip("type_caster_odr_violation_detected_count() is None")
if num_violations == 0: if num_violations == 0:
if m.if_defined__NO_INLINE__: if m.if_defined__NO_INLINE__:
pytest.skip( pytest.skip(_count_0_message("__NO_INLINE__"))
f"type_caster_odr_violation_detected_count() == 0:"
f" {pybind11_tests.compiler_info}, {pybind11_tests.cpp_std},"
" __NO_INLINE__"
)
if m.CUDACC is not None: if m.CUDACC is not None:
pytest.skip( pytest.skip(_count_0_message(f"CUDACC = {m.CUDACC}"))
f"type_caster_odr_violation_detected_count() == 0:" if m.NVCOMPILER is not None:
f" {pybind11_tests.compiler_info}, {pybind11_tests.cpp_std}," pytest.skip(_count_0_message(f"NVCOMPILER = {m.NVCOMPILER}"))
" CUDACC = {m.CUDACC}"
)
assert num_violations == 1 assert num_violations == 1