ci: skipping test for Windows Clang failure (#5062)

* ci: trying things for Windows Clang failure

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* WIP: try using older clang

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* tests: skip broken test

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* tests: try to skip test in tests

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* fix(tests): Prefer __version__ over MSVC

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* chore: avoid warning on Clang

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Update tests/test_exceptions.py

* Update tests/test_exceptions.py

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
Henry Schreiner 2024-03-21 02:27:58 -04:00 committed by GitHub
parent 8b48ff878c
commit ec73bdaf1f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 22 additions and 8 deletions

View File

@ -67,9 +67,14 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
// `Py_LIMITED_API` anyway. // `Py_LIMITED_API` anyway.
# if PYBIND11_INTERNALS_VERSION > 4 # if PYBIND11_INTERNALS_VERSION > 4
# define PYBIND11_TLS_KEY_REF Py_tss_t & # define PYBIND11_TLS_KEY_REF Py_tss_t &
# if defined(__GNUC__) && !defined(__INTEL_COMPILER) # if defined(__clang__)
// Clang on macOS warns due to `Py_tss_NEEDS_INIT` not specifying an initializer # define PYBIND11_TLS_KEY_INIT(var) \
// for every field. _Pragma("clang diagnostic push") /**/ \
_Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"") /**/ \
Py_tss_t var \
= Py_tss_NEEDS_INIT; \
_Pragma("clang diagnostic pop")
# elif defined(__GNUC__) && !defined(__INTEL_COMPILER)
# define PYBIND11_TLS_KEY_INIT(var) \ # define PYBIND11_TLS_KEY_INIT(var) \
_Pragma("GCC diagnostic push") /**/ \ _Pragma("GCC diagnostic push") /**/ \
_Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") /**/ \ _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") /**/ \

View File

@ -520,11 +520,15 @@ set(PYBIND11_TEST_PREFIX_COMMAND
"" ""
CACHE STRING "Put this before pytest, use for checkers and such") CACHE STRING "Put this before pytest, use for checkers and such")
set(PYBIND11_PYTEST_ARGS
""
CACHE STRING "Extra arguments for pytest")
# A single command to compile and run the tests # A single command to compile and run the tests
add_custom_target( add_custom_target(
pytest pytest
COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest
${PYBIND11_ABS_PYTEST_FILES} ${PYBIND11_ABS_PYTEST_FILES} ${PYBIND11_PYTEST_ARGS}
DEPENDS ${test_targets} DEPENDS ${test_targets}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
USES_TERMINAL) USES_TERMINAL)

View File

@ -80,10 +80,10 @@ PYBIND11_MODULE(pybind11_tests, m) {
// Intentionally kept minimal to not create a maintenance chore // Intentionally kept minimal to not create a maintenance chore
// ("just enough" to be conclusive). // ("just enough" to be conclusive).
#if defined(_MSC_FULL_VER) #if defined(__VERSION__)
m.attr("compiler_info") = "MSVC " PYBIND11_TOSTRING(_MSC_FULL_VER);
#elif defined(__VERSION__)
m.attr("compiler_info") = __VERSION__; m.attr("compiler_info") = __VERSION__;
#elif defined(_MSC_FULL_VER)
m.attr("compiler_info") = "MSVC " PYBIND11_TOSTRING(_MSC_FULL_VER);
#else #else
m.attr("compiler_info") = py::none(); m.attr("compiler_info") = py::none();
#endif #endif

View File

@ -4,7 +4,7 @@ import pytest
import env import env
import pybind11_cross_module_tests as cm import pybind11_cross_module_tests as cm
import pybind11_tests # noqa: F401 import pybind11_tests
from pybind11_tests import exceptions as m from pybind11_tests import exceptions as m
@ -248,6 +248,11 @@ def test_nested_throws(capture):
assert str(excinfo.value) == "this is a helper-defined translated exception" assert str(excinfo.value) == "this is a helper-defined translated exception"
# TODO: Investigate this crash, see pybind/pybind11#5062 for background
@pytest.mark.skipif(
sys.platform.startswith("win32") and "Clang" in pybind11_tests.compiler_info,
reason="Started segfaulting February 2024",
)
def test_throw_nested_exception(): def test_throw_nested_exception():
with pytest.raises(RuntimeError) as excinfo: with pytest.raises(RuntimeError) as excinfo:
m.throw_nested_exception() m.throw_nested_exception()