Trying a new direction: show compiler info & std for UNEXPECTED: type_caster_odr_violation_detected_count() == 0

This commit is contained in:
Ralf W. Grosse-Kunstleve 2022-06-22 17:11:42 -07:00
parent 0c0f322e23
commit 0d2bf264c8
4 changed files with 16 additions and 12 deletions

View File

@ -546,7 +546,6 @@ add_custom_target(
--suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-python.supp"
--suppressions="${CMAKE_CURRENT_SOURCE_DIR}/valgrind-numpy-scipy.supp"
--gen-suppressions=all
env PYBIND11_TESTING_WITH_VALGRIND=1
${PYTHON_EXECUTABLE} -m pytest ${PYBIND11_ABS_PYTEST_FILES}
DEPENDS ${test_targets}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"

View File

@ -197,9 +197,10 @@ def gc_collect():
def pytest_configure():
print(
"PYBIND11_INTERNALS_ID & C++ Version:",
"C++ Info:",
pybind11_tests.compiler_info,
pybind11_tests.cpp_std,
pybind11_tests.PYBIND11_INTERNALS_ID,
pybind11_tests.cpp_version_in_use,
flush=True,
)
pytest.suppress = suppress

View File

@ -62,7 +62,7 @@ void bind_ConstructorStats(py::module_ &m) {
});
}
const char *cpp_version_in_use() {
const char *cpp_std() {
return
#if defined(PYBIND11_CPP20)
"C++20";
@ -78,7 +78,14 @@ const char *cpp_version_in_use() {
PYBIND11_MODULE(pybind11_tests, m) {
m.doc() = "pybind11 test module";
m.attr("cpp_version_in_use") = cpp_version_in_use();
#if defined(_MSC_FULL_VER)
m.attr("compiler_info") = "MSVC " _MSC_FULL_VER;
#elif defined(__VERSION__)
m.attr("compiler_info") = __VERSION__;
#else
m.attr("compiler_info") = py::none();
#endif
m.attr("cpp_std") = cpp_std();
m.attr("PYBIND11_INTERNALS_ID") = PYBIND11_INTERNALS_ID;
bind_ConstructorStats(m);

View File

@ -1,7 +1,6 @@
import os
import pytest
import pybind11_tests
import pybind11_tests.type_caster_odr_guard_1 as m
@ -37,12 +36,10 @@ 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")
elif (
os.environ.get("PYBIND11_TESTING_WITH_VALGRIND") is not None
and num_violations == 0
):
elif num_violations == 0:
pytest.skip(
"UNEXPECTED: type_caster_odr_violation_detected_count() == 0 (valgrind)"
"UNEXPECTED: type_caster_odr_violation_detected_count() == 0 (%s %s)"
% (pybind11_tests.compiler_info, pybind11_tests.cpp_std)
)
else:
assert num_violations == 1