From cfd222ebdf248b7d3093b0a8de6adba4b1d56db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20=C5=A0im=C3=A1=C4=8Dek?= Date: Tue, 8 Oct 2024 19:44:24 +0200 Subject: [PATCH] Skip GC-dependent tests on GraalPy (#5401) --- tests/test_class_sh_property.py | 4 +++- tests/test_class_sh_trampoline_shared_from_this.py | 4 ++-- tests/test_class_sh_trampoline_shared_ptr_cpp_arg.py | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/test_class_sh_property.py b/tests/test_class_sh_property.py index 6b288650b6..9bd2fbfbf8 100644 --- a/tests/test_class_sh_property.py +++ b/tests/test_class_sh_property.py @@ -11,7 +11,9 @@ pytest.skip("smart_holder not available.", allow_module_level=True) -@pytest.mark.xfail("env.PYPY", reason="gc after `del field` is apparently deferred") +@pytest.mark.skipif( + "env.PYPY or env.GRAALPY", reason="gc after `del field` is apparently deferred" +) @pytest.mark.parametrize("m_attr", ["m_valu_readonly", "m_valu_readwrite"]) def test_valu_getter(m_attr): # Reduced from PyCLIF test: diff --git a/tests/test_class_sh_trampoline_shared_from_this.py b/tests/test_class_sh_trampoline_shared_from_this.py index 197e72ce38..9b0d122b40 100644 --- a/tests/test_class_sh_trampoline_shared_from_this.py +++ b/tests/test_class_sh_trampoline_shared_from_this.py @@ -212,10 +212,10 @@ def test_multiple_registered_instances_for_same_pointee_recursive(): del obj_next assert obj.history == "PySft" del obj0 - if not env.PYPY: + if not env.PYPY and not env.GRAALPY: assert obj0_wr() is not None del obj # This releases the chain recursively. - if not env.PYPY: + if not env.PYPY and not env.GRAALPY: assert obj0_wr() is None break # Comment out for manual leak checking (use `top` command). diff --git a/tests/test_class_sh_trampoline_shared_ptr_cpp_arg.py b/tests/test_class_sh_trampoline_shared_ptr_cpp_arg.py index 7de9d0690e..7a44a602d4 100644 --- a/tests/test_class_sh_trampoline_shared_ptr_cpp_arg.py +++ b/tests/test_class_sh_trampoline_shared_ptr_cpp_arg.py @@ -2,12 +2,14 @@ import pytest +import env # noqa: F401 import pybind11_tests.class_sh_trampoline_shared_ptr_cpp_arg as m if not m.defined_PYBIND11_SMART_HOLDER_ENABLED: pytest.skip("smart_holder not available.", allow_module_level=True) +@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC") def test_shared_ptr_cpp_arg(): import weakref @@ -32,6 +34,7 @@ def is_base_used(self): assert tester.get_object() is objref() +@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC") def test_shared_ptr_cpp_prop(): class PyChild(m.SpBase): def is_base_used(self): @@ -50,6 +53,7 @@ def is_base_used(self): assert tester.obj.has_python_instance() is True +@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC") def test_shared_ptr_arg_identity(): import weakref @@ -68,6 +72,7 @@ def test_shared_ptr_arg_identity(): assert tester.has_python_instance() is False +@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC") def test_shared_ptr_alias_nonpython(): tester = m.SpBaseTester() @@ -110,6 +115,7 @@ def test_shared_ptr_alias_nonpython(): assert new_tester.has_python_instance() is False +@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC") def test_shared_ptr_goaway(): import weakref