Skip to content

Commit ec73bda

Browse files
authored
ci: skipping test for Windows Clang failure (#5062)
* ci: trying things for Windows Clang failure Signed-off-by: Henry Schreiner <[email protected]> * WIP: try using older clang Signed-off-by: Henry Schreiner <[email protected]> * tests: skip broken test Signed-off-by: Henry Schreiner <[email protected]> * tests: try to skip test in tests Signed-off-by: Henry Schreiner <[email protected]> * fix(tests): Prefer __version__ over MSVC Signed-off-by: Henry Schreiner <[email protected]> * chore: avoid warning on Clang Signed-off-by: Henry Schreiner <[email protected]> * Update tests/test_exceptions.py * Update tests/test_exceptions.py --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 8b48ff8 commit ec73bda

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

include/pybind11/detail/internals.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,14 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
6767
// `Py_LIMITED_API` anyway.
6868
# if PYBIND11_INTERNALS_VERSION > 4
6969
# define PYBIND11_TLS_KEY_REF Py_tss_t &
70-
# if defined(__GNUC__) && !defined(__INTEL_COMPILER)
71-
// Clang on macOS warns due to `Py_tss_NEEDS_INIT` not specifying an initializer
72-
// for every field.
70+
# if defined(__clang__)
71+
# define PYBIND11_TLS_KEY_INIT(var) \
72+
_Pragma("clang diagnostic push") /**/ \
73+
_Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"") /**/ \
74+
Py_tss_t var \
75+
= Py_tss_NEEDS_INIT; \
76+
_Pragma("clang diagnostic pop")
77+
# elif defined(__GNUC__) && !defined(__INTEL_COMPILER)
7378
# define PYBIND11_TLS_KEY_INIT(var) \
7479
_Pragma("GCC diagnostic push") /**/ \
7580
_Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") /**/ \

tests/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,11 +520,15 @@ set(PYBIND11_TEST_PREFIX_COMMAND
520520
""
521521
CACHE STRING "Put this before pytest, use for checkers and such")
522522

523+
set(PYBIND11_PYTEST_ARGS
524+
""
525+
CACHE STRING "Extra arguments for pytest")
526+
523527
# A single command to compile and run the tests
524528
add_custom_target(
525529
pytest
526530
COMMAND ${PYBIND11_TEST_PREFIX_COMMAND} ${PYTHON_EXECUTABLE} -m pytest
527-
${PYBIND11_ABS_PYTEST_FILES}
531+
${PYBIND11_ABS_PYTEST_FILES} ${PYBIND11_PYTEST_ARGS}
528532
DEPENDS ${test_targets}
529533
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
530534
USES_TERMINAL)

tests/pybind11_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ PYBIND11_MODULE(pybind11_tests, m) {
8080

8181
// Intentionally kept minimal to not create a maintenance chore
8282
// ("just enough" to be conclusive).
83-
#if defined(_MSC_FULL_VER)
84-
m.attr("compiler_info") = "MSVC " PYBIND11_TOSTRING(_MSC_FULL_VER);
85-
#elif defined(__VERSION__)
83+
#if defined(__VERSION__)
8684
m.attr("compiler_info") = __VERSION__;
85+
#elif defined(_MSC_FULL_VER)
86+
m.attr("compiler_info") = "MSVC " PYBIND11_TOSTRING(_MSC_FULL_VER);
8787
#else
8888
m.attr("compiler_info") = py::none();
8989
#endif

tests/test_exceptions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import env
66
import pybind11_cross_module_tests as cm
7-
import pybind11_tests # noqa: F401
7+
import pybind11_tests
88
from pybind11_tests import exceptions as m
99

1010

@@ -248,6 +248,11 @@ def pycatch(exctype, f, *args): # noqa: ARG001
248248
assert str(excinfo.value) == "this is a helper-defined translated exception"
249249

250250

251+
# TODO: Investigate this crash, see pybind/pybind11#5062 for background
252+
@pytest.mark.skipif(
253+
sys.platform.startswith("win32") and "Clang" in pybind11_tests.compiler_info,
254+
reason="Started segfaulting February 2024",
255+
)
251256
def test_throw_nested_exception():
252257
with pytest.raises(RuntimeError) as excinfo:
253258
m.throw_nested_exception()

0 commit comments

Comments
 (0)