From f29db6b9f8c5f4505e5f86703934786532668179 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Wed, 14 Jan 2026 17:10:33 +0100 Subject: [PATCH 1/5] [CPyCppyy] Use `XDECREF` on value that might be zero in Pythonize.cxx The `PyObject_CallMethod()` to call `reserve()` might fail, in which case we should not try to decrement the result variable. Use the `Py_XDECREF` macro that does a `nullptr` check. --- bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx b/bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx index a50086dd67646..92e56a05aad02 100644 --- a/bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx +++ b/bindings/pyroot/cppyy/CPyCppyy/src/Pythonize.cxx @@ -323,7 +323,12 @@ static bool FillVector(PyObject* vecin, PyObject* args, ItemGetter* getter) // reserve memory as applicable if (0 < sz) { PyObject* res = PyObject_CallMethod(vecin, (char*)"reserve", (char*)"n", sz); - Py_DECREF(res); + // TODO: Actually this "res" should never be nullptr, but somehow this + // call can fail on Windows 64 bit, resulting in "res" being a nullptr. + // This needs to be fixed, and then we can use again Py_DECREF(res), + // which doesn't do the nullptr check. Alternatively, there should be a + // proper error if calling reserve() fails. + Py_XDECREF(res); } else // i.e. sz == 0, so empty container: done return true; From 740a2ce96e2e3ec796519ee37cd540c50d280934 Mon Sep 17 00:00:00 2001 From: Aaron Jomy Date: Mon, 26 May 2025 20:01:49 +0200 Subject: [PATCH 2/5] [cppyy] Enable tests on windows --- bindings/pyroot/cppyy/cppyy/CMakeLists.txt | 4 +- .../pyroot/cppyy/cppyy/test/CMakeLists.txt | 147 +++++++++--------- .../pyroot/cppyy/cppyy/test/cpp11features.h | 12 -- .../pyroot/cppyy/cppyy/test/pythonizables.cxx | 47 ------ .../pyroot/cppyy/cppyy/test/pythonizables.h | 43 ----- bindings/pyroot/cppyy/cppyy/test/support.py | 20 +-- bindings/pyroot/cppyy/cppyy/test/templates.h | 26 +--- .../cppyy/cppyy/test/test_aclassloader.py | 7 +- .../cppyy/cppyy/test/test_advancedcpp.py | 14 +- .../cppyy/cppyy/test/test_concurrent.py | 3 +- .../cppyy/cppyy/test/test_conversions.py | 13 +- .../cppyy/cppyy/test/test_cpp11features.py | 24 ++- .../cppyy/cppyy/test/test_crossinheritance.py | 13 +- .../pyroot/cppyy/cppyy/test/test_datatypes.py | 13 +- .../cppyy/cppyy/test/test_doc_features.py | 20 ++- .../pyroot/cppyy/cppyy/test/test_fragile.py | 13 +- .../pyroot/cppyy/cppyy/test/test_leakcheck.py | 7 +- .../pyroot/cppyy/cppyy/test/test_lowlevel.py | 12 +- .../pyroot/cppyy/cppyy/test/test_numba.py | 9 +- .../pyroot/cppyy/cppyy/test/test_operators.py | 5 +- .../pyroot/cppyy/cppyy/test/test_overloads.py | 9 +- .../pyroot/cppyy/cppyy/test/test_pythonify.py | 12 +- .../cppyy/cppyy/test/test_pythonization.py | 110 ++++++++++++- .../cppyy/cppyy/test/test_regression.py | 11 +- .../pyroot/cppyy/cppyy/test/test_stltypes.py | 46 +++++- .../pyroot/cppyy/cppyy/test/test_streams.py | 5 +- .../pyroot/cppyy/cppyy/test/test_templates.py | 32 +++- 27 files changed, 376 insertions(+), 301 deletions(-) diff --git a/bindings/pyroot/cppyy/cppyy/CMakeLists.txt b/bindings/pyroot/cppyy/cppyy/CMakeLists.txt index 842ad12df97ed..d5be83297fcd3 100644 --- a/bindings/pyroot/cppyy/cppyy/CMakeLists.txt +++ b/bindings/pyroot/cppyy/cppyy/CMakeLists.txt @@ -34,6 +34,4 @@ install(DIRECTORY ${localruntimedir}/cppyy COMPONENT libraries PATTERN *.so EXCLUDE) -if(NOT MSVC) - ROOT_ADD_TEST_SUBDIRECTORY(test) -endif() +ROOT_ADD_TEST_SUBDIRECTORY(test) diff --git a/bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt b/bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt index ce6cadae0f412..af7346dab41a5 100644 --- a/bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt +++ b/bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt @@ -4,72 +4,7 @@ # For the licensing terms see $ROOTSYS/LICENSE. # For the list of contributors see $ROOTSYS/README/CREDITS. -# Dictionary list -set(CPPYY_TEST_DICTS -advancedcpp -advancedcpp2 -conversions -cpp11features -crossinheritance -datatypes -doc_helper -example01 -fragile -operators -overloads -pythonizables -std_streams -templates -stltypes) - -foreach(DICT ${CPPYY_TEST_DICTS}) - set(CMAKE_ROOTTEST_NOROOTMAP OFF) - # only disable rootmap for all but example01 and stltypes which require them - if(NOT DICT STREQUAL "example01" AND NOT DICT STREQUAL "stltypes") - set(CMAKE_ROOTTEST_NOROOTMAP ON) - endif() - # Generate dictionary for the tests - ROOT_GENERATE_DICTIONARY(G__${DICT}Dict ${CMAKE_CURRENT_SOURCE_DIR}/${DICT}.h LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${DICT}.xml) - # Create necessary shared libraries for the tests - add_library(${DICT}Dict SHARED ${CMAKE_CURRENT_SOURCE_DIR}/${DICT}.cxx G__${DICT}Dict.cxx) - target_include_directories(${DICT}Dict PUBLIC ${Python3_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}/include) - target_link_libraries(${DICT}Dict PUBLIC ROOT::Core) - target_compile_options(${DICT}Dict PRIVATE "-w") - if(MSVC) - target_link_libraries(${DICT}Dict PUBLIC Python3::Python) - elseif(APPLE) - target_link_libraries(${DICT}Dict PUBLIC -Wl,-bind_at_load -Wl,-w -Wl,-undefined -Wl,dynamic_lookup) - else() - target_link_libraries(${DICT}Dict PUBLIC -Wl,--unresolved-symbols=ignore-all) - endif() -endforeach() -unset(CMAKE_ROOTTEST_NOROOTMAP) - -# Tests list -set(CPPYY_TESTS -test_aclassloader -test_advancedcpp -test_api -test_boost -test_conversions -test_crossinheritance -test_datatypes -test_doc_features -test_eigen -test_fragile -# The leakcheck test is disabled due to its sporadic nature, especially fragile on VMs -# test_leakcheck -test_lowlevel -test_numba -test_operators -test_overloads -test_pythonify -test_pythonization -test_regression -test_streams -test_templates -test_concurrent) - +set(enable_test_cpp11features FALSE) if(NOT CMAKE_CXX_STANDARD EQUAL 23) # test_cpp11features crashes when run with C++23 if(APPLE) @@ -79,21 +14,81 @@ if(NOT CMAKE_CXX_STANDARD EQUAL 23) OUTPUT_STRIP_TRAILING_WHITESPACE ) if(MACOS_VERSION VERSION_LESS "26.0") - # Parts of this test suite fail with std::make_unique - list(APPEND CPPYY_TEST_DICTS test_cpp11features) + # Parts of this test suite fail with std::make_unique + set(enable_test_cpp11features TRUE) endif() else() - list(APPEND CPPYY_TESTS test_cpp11features) + set(enable_test_cpp11features TRUE) endif() endif() +if(MSVC) + set(common_args GENERIC PYTHON_DEPS pytest) +else() + set(common_args GENERIC ENVIRONMENT ${ld_library_path}=${CMAKE_CURRENT_BINARY_DIR} PYTHON_DEPS pytest) +endif() + +set(root_cmd $ -b -q -l) + +function(ADD_PYUNITTEST_ACLIC TESTNAME) + set(options) + set(oneValueArgs) + set(multiValueArgs DICTNAME) + cmake_parse_arguments(ARG + "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} + ) + + ROOT_ADD_PYUNITTEST(${TESTNAME} ${TESTNAME}.py ${common_args} + COPY_TO_BUILDDIR ${ARG_DICTNAME}.cxx ${ARG_DICTNAME}.h + PRECMD ${root_cmd} -e ".L ${ARG_DICTNAME}.cxx++" + ) +endfunction() + +ADD_PYUNITTEST_ACLIC(test_conversions DICTNAME conversions) +ADD_PYUNITTEST_ACLIC(test_crossinheritance DICTNAME crossinheritance) +ADD_PYUNITTEST_ACLIC(test_doc_features DICTNAME doc_helper) +ADD_PYUNITTEST_ACLIC(test_fragile DICTNAME fragile) +ADD_PYUNITTEST_ACLIC(test_operators DICTNAME operators) +ADD_PYUNITTEST_ACLIC(test_overloads DICTNAME overloads) +ADD_PYUNITTEST_ACLIC(test_streams DICTNAME std_streams) +ADD_PYUNITTEST_ACLIC(test_templates DICTNAME templates) +ADD_PYUNITTEST_ACLIC(test_pythonization DICTNAME pythonizables) + +ROOT_ADD_PYUNITTEST(test_pythonify test_pythonify.py ${common_args} + COPY_TO_BUILDDIR example01.cxx example01.h + PRECMD ${root_cmd} -e ".L example01.cxx++" + FIXTURES_SETUP example01_dict_fixture +) + +ROOT_ADD_PYUNITTEST(test_advancedcpp test_advancedcpp.py ${common_args} + COPY_TO_BUILDDIR advancedcpp.cxx advancedcpp.h advancedcpp2.cxx advancedcpp2.h + PRECMD ${root_cmd} -e ".L advancedcpp.cxx++" -e ".L advancedcpp2.cxx++" +) + +ROOT_ADD_PYUNITTEST(test_lowlevel test_lowlevel.py ${common_args} + COPY_TO_BUILDDIR datatypes.cxx datatypes.h + PRECMD ${root_cmd} -e ".L datatypes.cxx++" + FIXTURES_SETUP datatypes_dict_fixture +) + +ROOT_ADD_PYUNITTEST(test_aclassloader test_aclassloader.py ${common_args} FIXTURES_REQUIRED example01_dict_fixture) +ROOT_ADD_PYUNITTEST(test_api test_api.py ${common_args}) +ROOT_ADD_PYUNITTEST(test_boost test_boost.py ${common_args}) +ROOT_ADD_PYUNITTEST(test_concurrent test_concurrent.py ${common_args}) +ROOT_ADD_PYUNITTEST(test_datatypes test_datatypes.py ${common_args} FIXTURES_REQUIRED datatypes_dict_fixture) +ROOT_ADD_PYUNITTEST(test_eigen test_eigen.py ${common_args}) +ROOT_ADD_PYUNITTEST(test_numba test_numba.py ${common_args}) +ROOT_ADD_PYUNITTEST(test_regression test_regression.py ${common_args}) + if(NOT APPLE) - # test_stltypes completely fails on OSX - # because it is unable to load the necessary shared libraries - list(APPEND CPPYY_TESTS test_stltypes) + # test_stltypes completely fails on OSX + # because it is unable to load the necessary shared libraries + ADD_PYUNITTEST_ACLIC(test_stltypes DICTNAME stltypes) endif() -# Configure the tests -foreach(TEST ${CPPYY_TESTS}) - ROOT_ADD_PYUNITTEST(${TEST} ${TEST}.py GENERIC ENVIRONMENT LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR} PYTHON_DEPS pytest) -endforeach() +if(enable_test_cpp11features) + ADD_PYUNITTEST_ACLIC(test_cpp11features DICTNAME cpp11features) +endif() + +# The leakcheck test is disabled due to its sporadic nature, especially fragile on VMs +# ROOT_ADD_PYUNITTEST(test_leakcheck test_leakcheck.py ${common_args}) diff --git a/bindings/pyroot/cppyy/cppyy/test/cpp11features.h b/bindings/pyroot/cppyy/cppyy/test/cpp11features.h index 44d8a234af6ce..183ce7082e319 100644 --- a/bindings/pyroot/cppyy/cppyy/test/cpp11features.h +++ b/bindings/pyroot/cppyy/cppyy/test/cpp11features.h @@ -106,15 +106,3 @@ namespace FunctionNS { struct FNTestStruct { FNTestStruct(int i) : t(i) {} int t; }; std::function FNCreateTestStructFunc(); } - - -//=========================================================================== -struct StructWithHash {}; // for std::hash<> testing -struct StructWithoutHash {}; - -namespace std { - template<> - struct hash { - size_t operator()(const StructWithHash&) const { return 17; } - }; -} // namespace std diff --git a/bindings/pyroot/cppyy/cppyy/test/pythonizables.cxx b/bindings/pyroot/cppyy/cppyy/test/pythonizables.cxx index 872906743329f..c2263d9d93778 100644 --- a/bindings/pyroot/cppyy/cppyy/test/pythonizables.cxx +++ b/bindings/pyroot/cppyy/cppyy/test/pythonizables.cxx @@ -1,8 +1,5 @@ #include "pythonizables.h" -#include "Python.h" - - //=========================================================================== pyzables::NakedBuffers::NakedBuffers(int size, double valx, double valy) : m_size(size) { m_Xbuf = new double[size]; @@ -54,47 +51,3 @@ unsigned int pyzables::pass_mine_rp_ref(const Countable& c) { return c.m_check; unsigned int pyzables::pass_mine_rp_ptr(const Countable* c) { return c->m_check; } pyzables::Countable* pyzables::gime_naked_countable() { return new Countable{}; } - - -//=========================================================================== -pyzables::WithCallback1::WithCallback1(int i) : m_int(i) {} - -int pyzables::WithCallback1::get_int() { return m_int; } -void pyzables::WithCallback1::set_int(int i) { m_int = i; } - -static inline void replace_method_name(PyObject* klass, const char* n1, const char* n2) { - PyObject* meth = PyObject_GetAttrString(klass, n1); - PyObject_SetAttrString(klass, n2, meth); - Py_DECREF(meth); - PyObject_DelAttrString(klass, n1); -} - -void pyzables::WithCallback1::WithCallback1::__cppyy_explicit_pythonize__(PyObject* klass, const std::string& name) { -// change methods to camel case - replace_method_name(klass, "get_int", "GetInt"); - replace_method_name(klass, "set_int", "SetInt"); - -// store the provided class name - klass_name = name; -} - -std::string pyzables::WithCallback1::klass_name{"not set"}; - -pyzables::WithCallback2::WithCallback2(int i) : m_int(i) {} - -int pyzables::WithCallback2::get_int() { return m_int; } -void pyzables::WithCallback2::set_int(int i) { m_int = i; } - -void pyzables::WithCallback2::WithCallback2::__cppyy_pythonize__(PyObject* klass, const std::string& name) { -// change methods to camel case - replace_method_name(klass, "get_int", "GetInt"); - replace_method_name(klass, "set_int", "SetInt"); - -// store the provided class name - klass_name = name; -} - -std::string pyzables::WithCallback2::klass_name{"not set"}; - -int pyzables::WithCallback3::get_int() { return 2*m_int; } -void pyzables::WithCallback3::set_int(int i) { m_int = 2*i; } diff --git a/bindings/pyroot/cppyy/cppyy/test/pythonizables.h b/bindings/pyroot/cppyy/cppyy/test/pythonizables.h index 1dc56101beee6..3d843de5fe96d 100644 --- a/bindings/pyroot/cppyy/cppyy/test/pythonizables.h +++ b/bindings/pyroot/cppyy/cppyy/test/pythonizables.h @@ -123,47 +123,4 @@ class IndexableBase { class IndexableDerived : public IndexableBase {}; - -//=========================================================================== -class WithCallback1 { -public: - WithCallback1(int i); - -public: - int get_int(); - void set_int(int i); - -private: - int m_int; - -public: - static void __cppyy_explicit_pythonize__(PyObject* klass, const std::string&); - static std::string klass_name; -}; - -class WithCallback2 { -public: - WithCallback2(int i); - -public: - int get_int(); - void set_int(int i); - -protected: - int m_int; - -public: - static void __cppyy_pythonize__(PyObject* klass, const std::string&); - static std::string klass_name; -}; - -class WithCallback3 : public WithCallback2 { -public: - using WithCallback2::WithCallback2; - -public: - int get_int(); - void set_int(int i); -}; - } // namespace pyzables diff --git a/bindings/pyroot/cppyy/cppyy/test/support.py b/bindings/pyroot/cppyy/cppyy/test/support.py index 6bb33ed58cb93..9d48970a505db 100644 --- a/bindings/pyroot/cppyy/cppyy/test/support.py +++ b/bindings/pyroot/cppyy/cppyy/test/support.py @@ -25,27 +25,29 @@ def setup_make(targetname): pyunicode = unicode maxvalue = sys.maxint -IS_WINDOWS = 0 -if 'win32' in sys.platform: +IS_WINDOWS = 'win32' in sys.platform +WINDOWS_BITS = 0 + +if IS_WINDOWS: import platform if '64' in platform.architecture()[0]: - IS_WINDOWS = 64 + WINDOWS_BITS = 64 maxvalue = 2**31-1 else: - IS_WINDOWS = 32 + WINDOWS_BITS = 32 -IS_MAC_ARM = 0 -IS_MAC_X86 = 0 +IS_MAC_ARM = False +IS_MAC_X86 = False if 'darwin' in sys.platform: import platform if 'arm64' in platform.machine(): - IS_MAC_ARM = 64 + IS_MAC_ARM = True os.environ["CPPYY_UNCAUGHT_QUIET"] = "1" else: - IS_MAC_X86 = 1 + IS_MAC_X86 =True IS_MAC = IS_MAC_ARM or IS_MAC_X86 -IS_LINUX = not (IS_WINDOWS or IS_MAC) +IS_LINUX = not (IS_WINDOWS or IS_MAC) def _register_root_error_counter(): diff --git a/bindings/pyroot/cppyy/cppyy/test/templates.h b/bindings/pyroot/cppyy/cppyy/test/templates.h index addded9bda085..14ff6074f70e5 100644 --- a/bindings/pyroot/cppyy/cppyy/test/templates.h +++ b/bindings/pyroot/cppyy/cppyy/test/templates.h @@ -1,9 +1,10 @@ #ifndef CPPYY_TEST_TEMPLATES_H #define CPPYY_TEST_TEMPLATES_H +#include #include #include -#include +#include #include #ifndef _WIN32 @@ -259,29 +260,6 @@ template using DA_vector = std::vector; namespace using_problem { -template -struct vector { - vector() : m_val(SZ) {} - T m_val; -}; - -template -struct matryoshka { - typedef T type; -}; - -template -struct matryoshka { - typedef vector::type, SZ> type; -}; - -template -using make_vector = typename matryoshka::type; - typedef make_vector iiv_t; -}; - -namespace using_problem { - template class Base { public: diff --git a/bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py b/bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py index 528867dee4bf6..91ba571dc9e39 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_aclassloader.py @@ -1,9 +1,8 @@ -import py, pytest, os +import pytest, os from pytest import raises, mark from support import setup_make, IS_MAC -currpath = os.getcwd() -test_dct = currpath + "/libexample01Dict" +test_dct = "libexample_cxx" class TestACLASSLOADER: @@ -11,7 +10,7 @@ class TestACLASSLOADER: def setup_class(cls): import cppyy - @mark.xfail(condition=IS_MAC, reason="Fails on OSX") + @mark.xfail(reason="rootmap files are a legacy feature") def test01_class_autoloading(self): """Test whether a class can be found through .rootmap.""" import cppyy diff --git a/bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py b/bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py index eb89c416baf92..b0fdf4a4c9e8b 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_advancedcpp.py @@ -1,9 +1,8 @@ -import py, pytest, os +import pytest, os from pytest import mark, raises, skip -from support import setup_make, pylong, IS_WINDOWS, ispypy +from support import setup_make, pylong, IS_WINDOWS, WINDOWS_BITS, ispypy -currpath = os.getcwd() -test_dct = currpath + "/libadvancedcppDict" +test_dct = "advancedcpp_cxx" class TestADVANCEDCPP: @@ -156,7 +155,7 @@ def test03a_namespace_lookup_on_update(self): import cppyy gbl = cppyy.gbl - lib2 = cppyy.load_reflection_info("libadvancedcpp2Dict") + lib2 = cppyy.load_reflection_info("advancedcpp2_cxx") assert gbl.a_ns is gbl.a_ns assert gbl.a_ns.d_ns is gbl.a_ns.d_ns @@ -387,6 +386,7 @@ def test07_pass_by_reference(self): assert gbl.get_d(d) == 44 d.__destruct__() + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test08_void_pointer_passing(self): """Test passing of variants of void pointer arguments""" @@ -401,7 +401,7 @@ def test08_void_pointer_passing(self): assert cppyy.addressof(o) == pp.gime_address_ptr_ptr(o) assert cppyy.addressof(o) == pp.gime_address_ptr_ref(o) - if IS_WINDOWS != 64: + if WINDOWS_BITS != 64: # there is no 8-byte integer type array on Windows 64b import array addressofo = array.array('l', [cppyy.addressof(o)]) @@ -597,6 +597,7 @@ def test14_new_overloader(self): gc.collect() assert cppyy.gbl.new_overloader.s_instances == 0 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test15_template_instantiation_with_vector_of_float(self): """Test template instantiation with a std::vector""" @@ -622,6 +623,7 @@ def test16_template_global_functions(self): assert f(3.) == 3. assert type(f(4.)) == type(4.) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test17_assign_to_return_byref(self): """Test assignment to an instance returned by reference""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_concurrent.py b/bindings/pyroot/cppyy/cppyy/test/test_concurrent.py index e77f3aa530b7e..567aca0a6b8f3 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_concurrent.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_concurrent.py @@ -1,6 +1,6 @@ import pytest from pytest import raises, skip, mark -from support import IS_MAC_ARM +from support import IS_MAC_ARM, IS_WINDOWS class TestCONCURRENT: @@ -91,6 +91,7 @@ def test03_timeout(self): if t.is_alive(): # was timed-out cppyy.gbl.test12_timeout.stopit[0] = True + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows") def test04_cpp_threading_with_exceptions(self): """Threads and Python exceptions""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_conversions.py b/bindings/pyroot/cppyy/cppyy/test/test_conversions.py index 60703dae220c6..8593ca8740f77 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_conversions.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_conversions.py @@ -1,9 +1,8 @@ -import py, pytest, os -from pytest import raises -from support import setup_make +import pytest, os +from pytest import raises, mark +from support import setup_make, IS_WINDOWS, WINDOWS_BITS -currpath = os.getcwd() -test_dct = currpath + "/libconversionsDict" +test_dct = "conversions_cxx" class TestCONVERSIONS: @@ -12,6 +11,7 @@ def setup_class(cls): import cppyy cls.conversion = cppyy.load_reflection_info(cls.test_dct) + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_implicit_vector_conversions(self): """Test implicit conversions of std::vector""" @@ -36,6 +36,7 @@ def test01_implicit_vector_conversions(self): assert CNS.sumit(range(N), v2) == total assert CNS.sumit(range(N), range(M, N)) == total + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test02_memory_handling_of_temporaries(self): """Verify that memory of temporaries is properly cleaned up""" @@ -57,6 +58,7 @@ def test02_memory_handling_of_temporaries(self): gc.collect() assert CC.s_count == 0 + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test03_error_handling(self): """Verify error handling""" @@ -84,6 +86,7 @@ def test03_error_handling(self): gc.collect() assert CC.s_count == 0 + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows") def test04_implicit_conversion_from_tuple(self): """Allow implicit conversions from tuples as arguments {}-like""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py b/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py index 99dd13c065e4c..680101e6d9707 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py @@ -1,10 +1,9 @@ -import py, sys, pytest, os +import sys, pytest, os from pytest import mark, raises -from support import setup_make, ispypy, IS_MAC_ARM +from support import setup_make, ispypy, IS_MAC_ARM, IS_WINDOWS, WINDOWS_BITS -currpath = os.getcwd() -test_dct = currpath + "/libcpp11featuresDict" +test_dct = "cpp11features_cxx" class TestCPP11FEATURES: @@ -264,6 +263,7 @@ def moveit(T): assert cppyy.gbl.TestMoving1.s_instance_counter == 0 assert cppyy.gbl.TestMoving2.s_instance_counter == 0 + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test08_initializer_list(self): """Initializer list construction""" @@ -385,10 +385,24 @@ def test12_stdfunction(self): f = FunctionNS.FNCreateTestStructFunc() assert f(t) == 27 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test13_stdhash(self): """Use of std::hash""" import cppyy + + cppyy.cppdef(""" + struct StructWithHash {}; // for std::hash<> testing + struct StructWithoutHash {}; + + namespace std { + template<> + struct hash { + size_t operator()(const StructWithHash&) const { return 17; } + }; + } // namespace std + """) + from cppyy.gbl import StructWithHash, StructWithoutHash for i in range(3): # to test effect of caching @@ -426,6 +440,7 @@ def test14_shared_ptr_passing(self): gc.collect() assert TestSmartPtr.s_counter == 0 + @mark.xfail(condition=IS_WINDOWS, reason='ValueError: Could not find "make_unique"') def test15_unique_ptr_template_deduction(self): """Argument type deduction with std::unique_ptr""" @@ -445,6 +460,7 @@ def test15_unique_ptr_template_deduction(self): with raises(ValueError): # not an RValue cppyy.gbl.UniqueTempl.returnptr[int](uptr_in) + @mark.xfail(condition=IS_WINDOWS, reason='TypeError: Could not find "make_unique"') def test16_unique_ptr_moves(self): """std::unique_ptr requires moves""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_crossinheritance.py b/bindings/pyroot/cppyy/cppyy/test/test_crossinheritance.py index c9f8128b2e844..416382385b250 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_crossinheritance.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_crossinheritance.py @@ -1,10 +1,8 @@ -import py, os, pytest +import os, pytest from pytest import raises, skip, mark -from support import setup_make, pylong, IS_MAC_ARM +from support import setup_make, pylong, IS_MAC_ARM, IS_WINDOWS - -currpath = os.getcwd() -test_dct = currpath + "/libcrossinheritanceDict" +test_dct = "crossinheritance_cxx" class TestCROSSINHERITANCE: @@ -227,7 +225,7 @@ def get_value(self): p1 = TPyDerived1() assert p1.get_value() == 13 - @mark.xfail(run=False, condition=IS_MAC_ARM, reason = "Crashes on OS X ARM with" \ + @mark.xfail(run=False, condition=IS_MAC_ARM | IS_WINDOWS, reason = "Crashes on OS X ARM with" \ "libc++abi: terminating due to uncaught exception") def test08_error_handling(self): """Python errors should propagate through wrapper""" @@ -290,6 +288,7 @@ def get_value(self): assert raises(TypeError, Base1.call_get_value, d) + @mark.xfail(condition=IS_WINDOWS, reason="TypeError: 'NoneType' object cannot be interpreted as an integer") def test10_python_in_templates(self): """Usage of Python derived objects in std::vector""" @@ -373,6 +372,7 @@ def some_imp(self): assert call_shared(v) == 13 assert v.some_imp() == 13 + @mark.xfail(condition=IS_WINDOWS, reason="assert 0 == (0 + 1)") def test12a_counter_test(self): """Test countable base counting""" @@ -993,6 +993,7 @@ def verify(a, n1, n2, n3): a = MyPyDerived(27, 55, nArgs=2) verify(a, 27, 55, 67) + @mark.xfail(run=False, condition=IS_WINDOWS, reason="TypeError: has no attribute 'npos'.") def test23_const_byvalue_return(self): """Const by-value return in overridden method""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py b/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py index 09d0ed853337a..416dad864dfe4 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_datatypes.py @@ -1,9 +1,8 @@ -import py, sys, pytest, os +import sys, pytest, os from pytest import mark, raises, skip -from support import setup_make, pylong, pyunicode, IS_MAC, IS_MAC_ARM +from support import setup_make, pylong, pyunicode, IS_MAC, IS_MAC_ARM, IS_WINDOWS, WINDOWS_BITS -currpath = os.getcwd() -test_dct = currpath + "/libdatatypesDict" +test_dct = "datatypes_cxx" class TestDATATYPES: @@ -1395,7 +1394,7 @@ def pyd(arg0, arg1): gc.collect() raises(TypeError, c, 3, 3) # lambda gone out of scope - @mark.xfail(run=False, condition=IS_MAC_ARM, reason = "Crashes on OS X ARM with" \ + @mark.xfail(run=False, condition=IS_MAC_ARM or (WINDOWS_BITS == 64), reason = "Crashes on Windows 64 bit or OS X ARM with" \ "libc++abi: terminating due to uncaught exception") def test28_callable_through_function_passing(self): """Passing callables through std::function""" @@ -1469,6 +1468,7 @@ def pyd(arg0, arg1): gc.collect() raises(TypeError, c, 3, 3) # lambda gone out of scope + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test29_std_function_life_lines(self): """Life lines to std::function data members""" @@ -1863,6 +1863,7 @@ def test37_legacy_matrix_of_structs(self): m = ns.create_matrix(N, M) assert ns.destroy_matrix(ns.g_matrix, N, M) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test38_plain_old_data(self): """Initializer construction of PODs""" @@ -1949,6 +1950,7 @@ def test38_plain_old_data(self): assert len(f1.fPtrArr) == 3 assert list(f1.fPtrArr) == [1., 2., 3] + @mark.xfail(condition=IS_WINDOWS, reason="Test doesn't work on Windows") def test39_aggregates(self): """Initializer construction of aggregates""" @@ -2389,6 +2391,7 @@ def test51_polymorphic_types_in_maps(self): else: assert type(v) == gbl.PolymorphicMaps.Derived + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test52_virtual_inheritance(self): import cppyy from cppyy import gbl diff --git a/bindings/pyroot/cppyy/cppyy/test/test_doc_features.py b/bindings/pyroot/cppyy/cppyy/test/test_doc_features.py index fe070747209a8..ad910c8a4dc8c 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_doc_features.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_doc_features.py @@ -1,10 +1,9 @@ -import py, sys, pytest, os +import sys, pytest, os from pytest import mark, raises, skip -from support import setup_make, ispypy, IS_WINDOWS, IS_MAC_ARM +from support import setup_make, ispypy, IS_WINDOWS, IS_MAC_ARM, WINDOWS_BITS -currpath = os.getcwd() -test_dct = currpath + "/libdoc_helperDict" +test_dct = "doc_helper_cxx" class TestDOCFEATURES: @@ -381,6 +380,7 @@ def test_unary_operators(sef): pass + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test_x_inheritance(self): import cppyy from cppyy.gbl import Abstract, Concrete, call_abstract_method @@ -446,7 +446,7 @@ def abstract_method2(self): assert cppyy.gbl.call_abstract_method1(pc) == "first message" assert cppyy.gbl.call_abstract_method2(pc) == "second message" - @mark.xfail(run=False, condition=IS_MAC_ARM, reason = "Crashes on OS X ARM with" \ + @mark.xfail(run=False, condition=IS_MAC_ARM | (WINDOWS_BITS == 64), reason = "Crashes on Windows 64 bit and macOS ARM with" \ "libc++abi: terminating due to uncaught exception") def test_exceptions(self): """Exception throwing and catching""" @@ -568,6 +568,7 @@ def test02_python_introspection(self): assert not isinstance(i, int) assert isinstance(i, Integer1) + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test03_STL_containers(self): """Instantiate STL contaienrs with new class""" @@ -784,6 +785,7 @@ def test02_use_c_void_p(self): Advert02.Picam_OpenFirstCamera(cam) assert Advert02.Picam_CloseCamera(cam) + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows") def test03_use_of_ctypes_and_enum(self): """Use of (opaque) enum through ctypes.c_void_p""" @@ -835,6 +837,7 @@ def test03_use_of_ctypes_and_enum(self): assert list(arr) == [1, 42, 1, 42] cppyy.gbl.free(vp) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test04_ptr_ptr_python_owns(self): """Example of ptr-ptr use where python owns""" @@ -920,6 +923,7 @@ def test06_c_char_p(self): val = createit(ptr) assert destroyit(ptr) == val + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test07_array_of_arrays(self): """Example of array of array usage""" @@ -1073,6 +1077,7 @@ def setup_class(cls): cppyy.gbl.talk_examples + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test_template_instantiation(self): """Run-time template instantiation example""" @@ -1144,6 +1149,7 @@ def test_fallbacks(self): assert CC.passT(2**64-1) == 2**64-1 assert 'unsigned long long' in CC.passT.__doc__ + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test_callbacks(self): """Function callback example""" @@ -1223,8 +1229,8 @@ def test_autocast_and_identiy(self): assert type(b) == CC.Derived assert d is b - @mark.xfail(run=False, condition=IS_MAC_ARM, reason = "Crashes on OS X ARM with" \ - "libc++abi: terminating due to uncaught exception") + @mark.xfail(run=False, condition=IS_MAC_ARM | IS_WINDOWS, reason = "Crashes on OS X ARM with" \ + "libc++abi: terminating due to uncaught exception, and also on Windows") def test_exceptions(self): """Exceptions example""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_fragile.py b/bindings/pyroot/cppyy/cppyy/test/test_fragile.py index 25da1b5e5366f..9047f41e4224e 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_fragile.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_fragile.py @@ -1,11 +1,9 @@ -import py, os, sys, pytest +import os, sys, pytest from pytest import mark, raises, skip from support import setup_make, ispypy, IS_WINDOWS, IS_MAC_ARM -currpath = os.getcwd() -test_dct = currpath + "/libfragileDict" - +test_dct = "fragile_cxx" class TestFRAGILE: def setup_class(cls): @@ -35,7 +33,8 @@ def test02_missing_classes(self): assert cppyy.gbl.fragile == cppyy.gbl.fragile fragile = cppyy.gbl.fragile - raises(AttributeError, getattr, fragile, "no_such_class") + no_such_class = fragile.no_such_class + raises(TypeError, no_such_class) # cannot instantiate incomplete type assert fragile.C is fragile.C assert fragile.C == fragile.C @@ -573,7 +572,7 @@ def test24_asan(self): cppyy.include('sanitizer/asan_interface.h') - @mark.xfail() + @mark.xfail(run=False) def test25_cppdef_error_reporting(self): """Check error reporting of cppyy.cppdef""" @@ -692,7 +691,7 @@ def test30_two_nested_ambiguity(self): p = Test.Family1.Parent() p.children # used to crash - @mark.xfail() + @mark.xfail(run=False) def test31_template_with_class_enum(self): """Template instantiated with class enum""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_leakcheck.py b/bindings/pyroot/cppyy/cppyy/test/test_leakcheck.py index 2b4ffc225591b..a57495b8cfd9e 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_leakcheck.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_leakcheck.py @@ -1,6 +1,6 @@ import py, os, sys, pytest from pytest import mark, skip -from support import setup_make, pylong, pyunicode, IS_MAC, IS_MAC_ARM +from support import setup_make, pylong, pyunicode, IS_MAC, IS_MAC_ARM, WINDOWS_BITS nopsutil = False try: @@ -73,7 +73,7 @@ def check_func(self, scope, func, *args, **kwds): assert fail < M - @mark.xfail(condition=IS_MAC, reason="Fails on OSX") + @mark.xfail(reason="disabled due to its sporadic nature, especially fragile on VMs") def test01_free_functions(self): """Leak test of free functions""" @@ -193,7 +193,7 @@ class MyClass04 { self.check_func(m, 'method_default', b=-99) self.check_func(m, 'method_default', c=-99) - @mark.xfail(condition=IS_MAC_ARM, reason="Fails on OSX-ARM") + @mark.xfail(condition=IS_MAC_ARM or (WINDOWS_BITS == 64), reason="Fails on Windows 64 bit and OSX-ARM") def test05_aggregates(self): """Leak test of aggregate creation""" @@ -235,6 +235,7 @@ def test06_dir(self): self.check_func(cppyy.gbl, '__dir__', cppyy.gbl) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test07_string_handling(self): """Leak check of returning an std::string by value""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py b/bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py index be0c99be74119..0dce4a2a9df50 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_lowlevel.py @@ -1,10 +1,9 @@ -import py, sys, pytest, os +import sys, pytest, os from pytest import mark, raises, skip -from support import setup_make, pylong, pyunicode, IS_WINDOWS, ispypy +from support import setup_make, pylong, pyunicode, IS_WINDOWS, WINDOWS_BITS, ispypy -currpath = os.getcwd() -test_dct = currpath + "/libdatatypesDict" +test_dct = "datatypes_cxx" class TestLOWLEVEL: @@ -45,6 +44,7 @@ def test02_builtin_cpp_casts(self): assert len(ll.reinterpret_cast['int*'](0)) == 0 raises(ReferenceError, ll.reinterpret_cast['int*'](0).__getitem__, 0) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test03_memory(self): """Memory allocation and free-ing""" @@ -82,6 +82,7 @@ def test03_memory(self): mem.__python_owns__ = True assert mem.__python_owns__ + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test04_python_casts(self): """Casts to common Python pointer encapsulations""" @@ -345,6 +346,7 @@ def test09_numpy_bool_array(self): x = np.array([True], dtype=bool) assert cppyy.gbl.convert_bool(x) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test10_array_of_const_char_star(self): """Test passting of const char*[]""" @@ -376,6 +378,7 @@ def py2c(pyargs): with raises(TypeError): cppyy.gbl.ArrayOfCStrings.takes_array_of_cstrings(pyargs, len(pyargs)) + @mark.xfail(run=False, condition=IS_WINDOWS, reason="Windows fatal exception: access violation") def test11_array_of_const_char_ref(self): """Test passting of const char**&""" @@ -687,6 +690,7 @@ def test03_3D_arrays(self): assert arr[i][j][k] == val assert arr[i, j, k] == val + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test04_malloc(self): """Use of malloc to create multi-dim arrays""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_numba.py b/bindings/pyroot/cppyy/cppyy/test/test_numba.py index 13a678bfc04e1..6066def044dc6 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_numba.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_numba.py @@ -1,7 +1,7 @@ import os, pytest import math, time from pytest import mark, raises -from support import setup_make, IS_MAC +from support import setup_make, IS_MAC, IS_WINDOWS try: import numba @@ -222,6 +222,7 @@ def go_fast(a, d): assert((go_fast(x, d) == go_slow(x, d)).all()) assert self.compare(go_slow, go_fast, 10000, x, d) + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows") def test05_multiple_arguments_function(self): """Numba-JITing of functions with multiple arguments""" @@ -248,6 +249,7 @@ def loop_add(x): assert sum == loop_add(x) + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows") def test06_multiple_arguments_template_freefunction(self): """Numba-JITing of a free template function that recieves more than one template arg""" @@ -342,6 +344,7 @@ def go_fast(a): assert((go_fast(x) == go_slow(x)).all()) assert self.compare(go_slow, go_fast, 100000, x) + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows") def test09_non_typed_templates(self): """Numba-JITing of a free template function that recieves multiple template args with non types""" @@ -367,7 +370,7 @@ def tma(x): assert sum == tma(x) - @mark.xfail(condition=IS_MAC, reason="Fails on OSX") + @mark.xfail(condition=IS_MAC | IS_WINDOWS, reason="Fails on macOS and Windows") def test10_returning_a_reference(self): import cppyy import numpy as np @@ -567,6 +570,7 @@ def square_vec_slow(x): assert (np.array(y) == np_square_res).all() assert (np.array(x) == np_add_res).all() + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows") def test13_std_vector_dot_product(self): """Numba-JITing of a dot_product method of a class that stores pointers to std::vectors on the python side""" import cppyy, cppyy.ll @@ -763,6 +767,7 @@ def tsa(a): assert type(tsa(a)) == int assert tsa(a) == 285 + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows") def test02_class_features(self): """Numba support documentation example: class features""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_operators.py b/bindings/pyroot/cppyy/cppyy/test/test_operators.py index ca6cc3e58de73..85f37989032ba 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_operators.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_operators.py @@ -1,10 +1,9 @@ -import py, pytest, os +import pytest, os from pytest import raises, skip, mark from support import setup_make, pylong, maxvalue, IS_WINDOWS, IS_MAC, no_root_errors -currpath = os.getcwd() -test_dct = currpath + "/liboperatorsDict" +test_dct = "operators_cxx" class TestOPERATORS: diff --git a/bindings/pyroot/cppyy/cppyy/test/test_overloads.py b/bindings/pyroot/cppyy/cppyy/test/test_overloads.py index 8635fe2e4272c..39a9c65dac017 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_overloads.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_overloads.py @@ -1,10 +1,9 @@ -import py, pytest, os +import pytest, os from pytest import raises, skip, mark -from support import setup_make, ispypy, IS_WINDOWS, IS_MAC_ARM +from support import setup_make, ispypy, IS_WINDOWS, IS_MAC_ARM, WINDOWS_BITS -currpath = os.getcwd() -test_dct = currpath + "/liboverloadsDict" +test_dct = "overloads_cxx" class TestOVERLOADS: @@ -140,6 +139,7 @@ def test07_mean_overloads(self): a = array.array(l, numbers) assert round(cmean(len(a), a) - mean, 8) == 0 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test08_const_non_const_overloads(self): """Check selectability of const/non-const overloads""" @@ -406,6 +406,7 @@ class Derived : public Base { assert result_instance == result_direct + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test14_disallow_functor_to_function_pointer(self): """Make sure we're no allowing to convert C++ functors to function pointers, extending the C++ language in an unnatural way that can lead diff --git a/bindings/pyroot/cppyy/cppyy/test/test_pythonify.py b/bindings/pyroot/cppyy/cppyy/test/test_pythonify.py index 353e5612c348b..e14943e950183 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_pythonify.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_pythonify.py @@ -1,10 +1,9 @@ -import py, pytest, os -from pytest import raises, skip -from support import setup_make, pylong, ispypy +import pytest, os +from pytest import mark, raises, skip +from support import setup_make, pylong, ispypy, WINDOWS_BITS -currpath = os.getcwd() -test_dct = currpath + "/libexample01Dict" +test_dct = "example01_cxx" class TestPYTHONIFY: @@ -242,6 +241,7 @@ def test09_memory(self): # TODO: need ReferenceError on touching pl_a + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test10_default_arguments(self): """Test propagation of default function arguments""" @@ -376,6 +376,7 @@ def __init__(self, what): assert example01.getCount() == 0 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test17_chaining(self): """Respective return values of temporaries should not go away""" @@ -393,6 +394,7 @@ def test17_chaining(self): assert cppyy.gbl.Lifeline.gime(42).get()[0].get()[0].get()[0].get()[0].x == 42 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test18_keywords(self): """Use of keyword arguments""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_pythonization.py b/bindings/pyroot/cppyy/cppyy/test/test_pythonization.py index 31e68063f85af..a4d7bb8b3cbf3 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_pythonization.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_pythonization.py @@ -1,10 +1,8 @@ -import py, sys, pytest, os +import sys, pytest, os from pytest import mark, raises -from support import setup_make, pylong +from support import setup_make, pylong, WINDOWS_BITS - -currpath = os.getcwd() -test_dct = currpath + "/libpythonizablesDict" +test_dct = "pythonizables_cxx" class TestClassPYTHONIZATION: @@ -224,11 +222,113 @@ def test08_base_class_pythonization(self): # associative container, with 'index' a key, not a counter #raises(IndexError, d.__getitem__, 1) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test09_cpp_side_pythonization(self): """Use of C++ side pythonizations""" import cppyy + # These definitions are not part of pythonizables.h/.cxx, because they + # require "Python.h". It is fragile to link dictionaries against + # libpython, as the right flags depend on the platform. Just declaring + # this code in the Python session is easier, because then Python.h and + # libpython are always available. + cppyy.cppdef("""\ + // as recommended by: + // https://docs.python.org/3/c-api/intro.html#include-files + #define PY_SSIZE_T_CLEAN + #include "Python.h" + + namespace pyzables { + + //=========================================================================== + class WithCallback1 { + public: + WithCallback1(int i); + + public: + int get_int(); + void set_int(int i); + + private: + int m_int; + + public: + static void __cppyy_explicit_pythonize__(PyObject* klass, const std::string&); + static std::string klass_name; + }; + + class WithCallback2 { + public: + WithCallback2(int i); + + public: + int get_int(); + void set_int(int i); + + protected: + int m_int; + + public: + static void __cppyy_pythonize__(PyObject* klass, const std::string&); + static std::string klass_name; + }; + + class WithCallback3 : public WithCallback2 { + public: + using WithCallback2::WithCallback2; + + public: + int get_int(); + void set_int(int i); + }; + + } // namespace pyzables + + //=========================================================================== + pyzables::WithCallback1::WithCallback1(int i) : m_int(i) {} + + int pyzables::WithCallback1::get_int() { return m_int; } + void pyzables::WithCallback1::set_int(int i) { m_int = i; } + + static inline void replace_method_name(PyObject* klass, const char* n1, const char* n2) { + PyObject* meth = PyObject_GetAttrString(klass, n1); + PyObject_SetAttrString(klass, n2, meth); + Py_DECREF(meth); + PyObject_DelAttrString(klass, n1); + } + + void pyzables::WithCallback1::WithCallback1::__cppyy_explicit_pythonize__(PyObject* klass, const std::string& name) { + // change methods to camel case + replace_method_name(klass, "get_int", "GetInt"); + replace_method_name(klass, "set_int", "SetInt"); + + // store the provided class name + klass_name = name; + } + + std::string pyzables::WithCallback1::klass_name{"not set"}; + + pyzables::WithCallback2::WithCallback2(int i) : m_int(i) {} + + int pyzables::WithCallback2::get_int() { return m_int; } + void pyzables::WithCallback2::set_int(int i) { m_int = i; } + + void pyzables::WithCallback2::WithCallback2::__cppyy_pythonize__(PyObject* klass, const std::string& name) { + // change methods to camel case + replace_method_name(klass, "get_int", "GetInt"); + replace_method_name(klass, "set_int", "SetInt"); + + // store the provided class name + klass_name = name; + } + + std::string pyzables::WithCallback2::klass_name{"not set"}; + + int pyzables::WithCallback3::get_int() { return 2*m_int; } + void pyzables::WithCallback3::set_int(int i) { m_int = 2*i; } + """) + # explicit pythonization for kls in [cppyy.gbl.pyzables.WithCallback1, cppyy.gbl.pyzables.WithCallback2]: w = kls(42) diff --git a/bindings/pyroot/cppyy/cppyy/test/test_regression.py b/bindings/pyroot/cppyy/cppyy/test/test_regression.py index eae00fa47b1c0..a681fa88f1984 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_regression.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_regression.py @@ -1,6 +1,6 @@ import os, sys, pytest from pytest import mark, raises, skip -from support import setup_make, IS_WINDOWS, ispypy, IS_MAC_X86, IS_MAC_ARM, IS_MAC +from support import setup_make, IS_WINDOWS, ispypy, IS_MAC_X86, IS_MAC_ARM, IS_MAC, WINDOWS_BITS class TestREGRESSION: @@ -308,6 +308,7 @@ def test13_char_star_over_char(self): assert cppyy.gbl.csoc3.call('0') == 'string' assert cppyy.gbl.csoc3.call('00') == 'string' + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test14_struct_direct_definition(self): """Struct defined directly in a scope miseed scope in renormalized name""" @@ -349,6 +350,7 @@ class Bar { f = sds.Foo() assert f.bar.x == 5 + @mark.xfail(run=False, condition=IS_WINDOWS, reason="Fails on Windows") def test15_vector_vs_initializer_list(self): """Prefer vector in template and initializer_list in formal arguments""" @@ -523,6 +525,7 @@ class SignedCharRefGetter { assert obj.getter() == 'c' + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test21_temporaries_and_vector(self): """Extend a life line to references into a vector if needed""" @@ -535,6 +538,7 @@ def test21_temporaries_and_vector(self): l = [e for e in cppyy.gbl.get_some_temporary_vector()] assert l == ['x', 'y', 'z'] + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test22_initializer_list_and_temporary(self): """Conversion rules when selecting intializer_list v.s. temporary""" @@ -1057,6 +1061,7 @@ def test36_ctypes_sizeof(self): assert cppyy.sizeof(param) == ctypes.sizeof(param) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test37_array_of_pointers_argument(self): """Passing an array of pointers used to crash""" @@ -1082,6 +1087,7 @@ def test37_array_of_pointers_argument(self): assert cppyy.addressof(res) == cppyy.addressof(arr) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test38_char16_arrays(self): """Access to fixed-size char16 arrays as data members""" @@ -1137,6 +1143,7 @@ def test38_char16_arrays(self): assert ai.name[:5] == u'hello' cppyy.ll.array_delete(aa) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test39_vector_of_pointers_conversion(self): """vector's const T*& used to be T**, now T*""" @@ -1363,7 +1370,7 @@ def test45_typedef_resolution(self): assert cppyy.gbl.CppyyLegacy.TClassEdit.ResolveTypedef("my_custom_type_t") == "const int" assert cppyy.gbl.CppyyLegacy.TClassEdit.ResolveTypedef("cmy_custom_type_t") == "const int" - @mark.xfail(run=False, condition=IS_MAC_ARM, reason = "Crashes on OS X ARM with" \ + @mark.xfail(run=False, condition=IS_MAC_ARM | WINDOWS_BITS == 64, reason = "Crashes on Windows 64 bit and macOS ARM with" \ "libc++abi: terminating due to uncaught exception") def test46_exception_narrowing(self): """Exception narrowing to C++ exception of all overloads""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py b/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py index c10a1a0103b76..b174051195a3a 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_stltypes.py @@ -1,10 +1,9 @@ # -*- coding: UTF-8 -*- -import py, sys, pytest, os +import sys, pytest, os from pytest import mark, raises, skip -from support import setup_make, pylong, pyunicode, maxvalue, ispypy, no_root_errors +from support import setup_make, pylong, pyunicode, maxvalue, ispypy, no_root_errors, IS_WINDOWS, WINDOWS_BITS -currpath = os.getcwd() -test_dct = currpath + "/libstltypesDict" +test_dct = "stltypes_cxx" global_n = 5 @@ -190,6 +189,7 @@ def getslice_cpython_test(type2test): assert a[3::maxvalue] == type2test([3]) +@mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") class TestSTLVECTOR: def setup_class(cls): cls.test_dct = test_dct @@ -197,6 +197,7 @@ def setup_class(cls): cls.stltypes = cppyy.load_reflection_info(cls.test_dct) cls.N = global_n + @mark.xfail(run=False, condition=IS_WINDOWS, reason="Fails on Windows") def test01_builtin_type_vector_types(self): """Test access to std::vector/std::vector""" @@ -252,6 +253,7 @@ def test01_builtin_type_vector_types(self): assert v.size() == self.N assert len(v) == self.N + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test02_user_type_vector_type(self): """Test access to an std::vector""" @@ -284,6 +286,7 @@ def test02_user_type_vector_type(self): assert len(v) == self.N v.__destruct__() + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test03_empty_vector_type(self): """Test behavior of empty std::vector<>""" @@ -298,6 +301,7 @@ def test03_empty_vector_type(self): for x in cppyy.gbl.std.vector["std::string*"](): pass + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test04_vector_iteration(self): """Test iteration over an std::vector""" @@ -323,6 +327,7 @@ def test04_vector_iteration(self): v.__destruct__() + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test05_push_back_iterables_with_iadd(self): """Test usage of += of iterable on push_back-able container""" @@ -361,6 +366,7 @@ def test05_push_back_iterables_with_iadd(self): v += [] assert len(v) == sz + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test06_vector_indexing(self): """Test python-style indexing to an std::vector""" @@ -388,6 +394,7 @@ def test06_vector_indexing(self): assert v2[-1] == v[-2] assert v2[self.N-4] == v[-2] + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test07_vector_bool(self): """Usability of std::vector which can be a specialization""" @@ -406,6 +413,7 @@ def test07_vector_bool(self): assert len(vb[4:8]) == 4 assert list(vb[4:8]) == [False]*3+[True] + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test08_vector_enum(self): """Usability of std::vector<> of some enums""" @@ -439,6 +447,7 @@ def test09_vector_of_string(self): raises(TypeError, cppyy.gbl.std.vector["std::string"], "abc") + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test10_vector_std_distance(self): """Use of std::distance with vector""" @@ -450,6 +459,7 @@ def test10_vector_std_distance(self): assert std.distance(v.begin(), v.end()) == v.size() assert std.distance[type(v).iterator](v.begin(), v.end()) == v.size() + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test11_vector_of_pair(self): """Use of std::vector""" @@ -526,6 +536,7 @@ def test12_vector_lifeline(self): for val in l: assert hasattr(val, '__lifeline') + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test13_vector_smartptr_iteration(self): """Iteration over smart pointers""" @@ -559,6 +570,7 @@ def test13_vector_smartptr_iteration(self): i += 1 assert i == len(result) + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test14_vector_of_vector_of_(self): """Nested vectors""" @@ -574,6 +586,7 @@ def test14_vector_of_vector_of_(self): assert vv[1][0] == 3 assert vv[1][1] == 4 + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test15_vector_slicing(self): """Advanced test of vector slicing""" @@ -600,6 +613,7 @@ def test15_vector_slicing(self): # additional test from CPython's test suite getslice_cpython_test(vector[int]) + @mark.xfail(run=False, condition=IS_WINDOWS, reason="Fails on Windows") def test16_vector_construction(self): """Vector construction following CPython's sequence""" @@ -616,7 +630,7 @@ def test17_vector_cpp17_style(self): v = cppyy.gbl.std.vector(l) assert list(l) == l - @mark.xfail + @mark.xfail(run=False) def test18_array_interface(self): """Test usage of __array__ from numpy""" @@ -851,6 +865,7 @@ def setup_class(cls): import cppyy cls.stltypes = cppyy.load_reflection_info(cls.test_dct) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_string_argument_passing(self): """Test mapping of python strings and std::[w]string""" @@ -933,8 +948,6 @@ def test04_array_of_strings(self): assert tuple(cppyy.gbl.str_array_1) == ('a', 'b', 'c') str_array_2 = cppyy.gbl.str_array_2 - # fix up the size - str_array_2.size = 4 assert tuple(str_array_2) == ('d', 'e', 'f', 'g') assert tuple(str_array_2) == ('d', 'e', 'f', 'g') @@ -953,6 +966,7 @@ def test04_array_of_strings(self): for k in range(2): assert str_array_4[i][j][k] == vals[i*4+j*2+k] + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test05_stlstring_and_unicode(self): """Mixing unicode and std::string""" @@ -1045,6 +1059,7 @@ def test08_string_operators(self): assert s1+s2 == "Hello, World!" assert s2+s1 == ", World!Hello" + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test09_string_as_str_bytes(self): """Python-style methods of str/bytes on std::string""" @@ -1151,6 +1166,7 @@ def setup_class(cls): cls.stltypes = cppyy.load_reflection_info(cls.test_dct) cls.N = 13 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_builtin_list_type(self): """Test access to a list""" @@ -1267,6 +1283,7 @@ def setup_class(cls): cls.stltypes = cppyy.load_reflection_info(cls.test_dct) cls.N = 13 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_builtin_map_type(self): """Test access to a map""" @@ -1305,6 +1322,7 @@ def test01_builtin_map_type(self): assert key == self.N-1 assert value == (self.N-1)*(self.N-1) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test02_keyed_maptype(self): """Test access to a map""" @@ -1397,6 +1415,7 @@ def test07_map_cpp17_style(self): assert m['1'] == 2 assert m['2'] == 1 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test08_map_derived_objects(self): """Enter derived objects through an initializer list""" @@ -1444,6 +1463,7 @@ def setup_class(cls): import cppyy cls.stltypes = cppyy.load_reflection_info(cls.test_dct) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_builtin_vector_iterators(self): """Test iterator comparison with operator== reflected""" @@ -1471,6 +1491,7 @@ def test01_builtin_vector_iterators(self): assert b1 != b2 assert b1 == e2 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test02_STL_like_class_iterators(self): """Test the iterator protocol mapping for an STL like class""" @@ -1606,6 +1627,7 @@ def setup_class(cls): import cppyy cls.stltypes = cppyy.load_reflection_info(cls.test_dct) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_array_of_basic_types(self): """Usage of std::array of basic types""" @@ -1618,6 +1640,7 @@ def test01_array_of_basic_types(self): a[i] = i assert a[i] == i + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test02_array_of_pods(self): """Usage of std::array of PODs""" @@ -1641,6 +1664,7 @@ def test02_array_of_pods(self): assert a[2].px == 6 assert a[2].py == 7 + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test03_array_of_pointer_to_pods(self): """Usage of std::array of pointer to PODs""" @@ -1671,6 +1695,7 @@ def test03_array_of_pointer_to_pods(self): assert gbl.ArrayTest.get_pa_px(a.data(), i) == 13*i assert gbl.ArrayTest.get_pa_py(a.data(), i) == 42*i + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test04_array_from_aggregate(self): """Initialize an array from an aggregate contructor""" @@ -1693,6 +1718,7 @@ def setup_class(cls): import cppyy cls.stltypes = cppyy.load_reflection_info(cls.test_dct) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_string_through_string_view(self): """Usage of std::string_view as formal argument""" @@ -1756,6 +1782,7 @@ def setup_class(cls): cls.stltypes = cppyy.load_reflection_info(cls.test_dct) cls.N = global_n + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_deque_byvalue_regression(self): """Return by value of a deque used to crash""" @@ -1783,6 +1810,7 @@ def setup_class(cls): cls.stltypes = cppyy.load_reflection_info(cls.test_dct) cls.N = global_n + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_set_iteration(self): """Iterate over a set""" @@ -1800,6 +1828,7 @@ def test01_set_iteration(self): assert i in s assert i in r + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test02_set_iterators(self): """Access to set iterators and their comparisons""" @@ -1883,6 +1912,7 @@ def setup_class(cls): cls.stltypes = cppyy.load_reflection_info(cls.test_dct) cls.N = global_n + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test01_tuple_creation_and_access(self): """Create tuples and access their elements""" @@ -1917,6 +1947,7 @@ def test01_tuple_creation_and_access(self): # TODO: should be easy enough to add iterators over std::tuple? + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test02_tuple_size(self): """Usage of tuple_size helper class""" @@ -2114,6 +2145,7 @@ def run_raiseit(t1, t2): gc.collect() assert cppyy.gbl.GetMyErrorCount() == 0 + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test04_from_cpp(self): """Catch C++ exceptiosn from C++""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_streams.py b/bindings/pyroot/cppyy/cppyy/test/test_streams.py index d55de2d55ebc3..abf717948d5d7 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_streams.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_streams.py @@ -1,10 +1,9 @@ -import py, pytest, os +import pytest, os from pytest import mark, raises from support import setup_make -currpath = os.getcwd() -test_dct = currpath + "/libstd_streamsDict" +test_dct = "std_streams_cxx" class TestSTDStreams: diff --git a/bindings/pyroot/cppyy/cppyy/test/test_templates.py b/bindings/pyroot/cppyy/cppyy/test/test_templates.py index 8dddc7461d00c..6b16223a1fc3d 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_templates.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_templates.py @@ -1,10 +1,9 @@ -import py, pytest, os +import pytest, os from pytest import mark, raises -from support import setup_make, pylong +from support import setup_make, pylong, IS_WINDOWS, WINDOWS_BITS -currpath = os.getcwd() -test_dct = currpath + "/libtemplatesDict" +test_dct = "templates_cxx" class TestTEMPLATES: @@ -69,6 +68,7 @@ def test02_non_type_template_args(self): assert cppyy.gbl.nt_templ_args[1]() == 1 assert cppyy.gbl.nt_templ_args[256]() == 256 + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test03_templated_function(self): """Templated global and static functions lookup and calls""" @@ -185,6 +185,7 @@ def test07_type_deduction(self): assert issubclass(select_template_arg[0, int, float].argument, int) assert issubclass(select_template_arg[1, int, float].argument, float) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test08_using_of_static_data(self): """Derived class using static data of base""" @@ -294,6 +295,25 @@ def test12_template_aliases(self): assert iavec[5] == 5 # with variadic template + cppyy.cppdef(""" + namespace using_problem { + + template + struct matryoshka { + typedef T type; + }; + + template + struct matryoshka { + typedef vector::type, SZ> type; + }; + + template + using make_vector = typename matryoshka::type; + typedef make_vector iiv_t; + }; + """) + assert nsup.matryoshka[int, 3].type assert nsup.matryoshka[int, 3, 4].type assert nsup.make_vector[int , 3] @@ -442,6 +462,7 @@ def test17_empty_body(self): assert f_T[int]() is None assert cppyy.gbl.T_WithEmptyBody.side_effect == "side effect" + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test18_greedy_overloads(self): """void*/void** should not pre-empt template instantiations""" @@ -509,6 +530,7 @@ class C { assert cppyy.gbl.TemplatedCtor.C(0) + @mark.xfail(run=False, condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test21_type_deduction_with_conversion(self): """Template instantiation with [] -> std::vector conversion""" @@ -547,6 +569,7 @@ def test21_type_deduction_with_conversion(self): assert l2v.test3[int]([d1]) == 1 assert l2v.test3[int]([d1, d1]) == 2 + @mark.xfail(condition=IS_WINDOWS, reason="Fails on Windows: TypeError: Template method resolution failed: Python int too large to convert to C long") def test22_type_deduction_of_proper_integer_size(self): """Template type from integer arg should be big enough""" @@ -562,6 +585,7 @@ def test22_type_deduction_of_proper_integer_size(self): for val in [2**64, -2**63-1]: raises(OverflowError, PassSomeInt, val) + @mark.xfail(condition=WINDOWS_BITS == 64, reason="Fails on Windows 64 bit") def test23_overloaded_setitem(self): """Template with overloaded non-templated and templated setitem""" From 5e077033c41d65f001b10bf4521c83ff0db782a2 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Thu, 8 Jan 2026 13:24:38 +0100 Subject: [PATCH 3/5] [roottest] Delete Python operator tests They are now part of the cppyy tests that are run on all platforms. The only test that is kept is a ROOT-specific one, which is moved to a different file. --- roottest/python/basic/CMakeLists.txt | 7 - roottest/python/basic/Operators.C | 114 ------------- roottest/python/basic/PyROOT_operatortests.py | 161 ------------------ .../python/basic/PyROOT_operatortests.ref | 11 -- .../regression/PyROOT_regressiontests.py | 16 ++ 5 files changed, 16 insertions(+), 293 deletions(-) delete mode 100644 roottest/python/basic/Operators.C delete mode 100644 roottest/python/basic/PyROOT_operatortests.py delete mode 100644 roottest/python/basic/PyROOT_operatortests.ref diff --git a/roottest/python/basic/CMakeLists.txt b/roottest/python/basic/CMakeLists.txt index 31e0ba7b698bd..8fee72d7b8ab6 100644 --- a/roottest/python/basic/CMakeLists.txt +++ b/roottest/python/basic/CMakeLists.txt @@ -15,14 +15,7 @@ if(NOT MSVC OR win_broken_tests) MACRO PyROOT_datatypetest_numpy.py FIXTURES_REQUIRED python-basic-datatype-fixture PYTHON_DEPS numpy) -endif() - - ROOTTEST_ADD_TEST(operator - MACRO PyROOT_operatortests.py - COPY_TO_BUILDDIR Operators.C - PRECMD ${ROOT_root_CMD} -b -q -l -e .L\ Operators.C+) -if(NOT MSVC OR win_broken_tests) ROOTTEST_ADD_TEST(overload MACRO PyROOT_overloadtests.py COPY_TO_BUILDDIR Overloads.C Overloads.h diff --git a/roottest/python/basic/Operators.C b/roottest/python/basic/Operators.C deleted file mode 100644 index 22b9eaf73f36b..0000000000000 --- a/roottest/python/basic/Operators.C +++ /dev/null @@ -1,114 +0,0 @@ -/* - File: roottest/python/basic/Operators.C - Author: WLavrijsen@lbl.gov - Created: 04/15/05 - Last: 05/20/10 -*/ - -class Number { -public: - Number() { m_int = 0; } - Number( int i ) { m_int = i; } - - int AsInt() { return m_int; } - - Number operator+( const Number& n ) const { return Number( m_int + n.m_int ); } - Number operator+( int n ) const { return Number( m_int + n ); } - Number operator-( const Number& n ) const { return Number( m_int - n.m_int ); } - Number operator-( int n ) const { return Number( m_int - n ); } - Number operator*( const Number& n ) const { return Number( m_int * n.m_int ); } - Number operator*( int n ) const { return Number( m_int * n ); } - Number operator/( const Number& n ) const { return Number( m_int / n.m_int ); } - Number operator/( int n ) const { return Number( m_int / n ); } - Number operator%( const Number& n ) const { return Number( m_int % n.m_int ); } - Number operator%( int n ) const { return Number( m_int % n ); } - - Number& operator+=( const Number& n ) { m_int += n.m_int; return *this; } - Number& operator-=( const Number& n ) { m_int -= n.m_int; return *this; } - Number& operator*=( const Number& n ) { m_int *= n.m_int; return *this; } - Number& operator/=( const Number& n ) { m_int /= n.m_int; return *this; } - Number& operator%=( const Number& n ) { m_int %= n.m_int; return *this; } - - Number operator-() { return Number( -m_int ); } - - bool operator<( const Number& n ) const { return m_int < n.m_int; } - bool operator>( const Number& n ) const { return m_int > n.m_int; } - bool operator<=( const Number& n ) const { return m_int <= n.m_int; } - bool operator>=( const Number& n ) const { return m_int >= n.m_int; } - bool operator!=( const Number& n ) const { return m_int != n.m_int; } - bool operator==( const Number& n ) const { return m_int == n.m_int; } - - operator bool() { return m_int != 0; } - - Number operator&( const Number& n ) const { return Number( m_int & n.m_int ); } - Number operator|( const Number& n ) const { return Number( m_int | n.m_int ); } - Number operator^( const Number& n ) const { return Number( m_int ^ n.m_int ); } - - Number& operator&=( const Number& n ) { m_int &= n.m_int; return *this; } - Number& operator|=( const Number& n ) { m_int |= n.m_int; return *this; } - Number& operator^=( const Number& n ) { m_int ^= n.m_int; return *this; } - - Number operator<<( int i ) const { return Number( m_int << i ); } - Number operator>>( int i ) const { return Number( m_int >> i ); } - -private: - int m_int; -}; - -//---------------------------------------------------------------------------- -struct OperatorCharStar { - OperatorCharStar() : m_str( (char*)"OperatorCharStar" ) {} - operator char*() { return m_str; } - char* m_str; -}; - -struct OperatorConstCharStar { - OperatorConstCharStar() : m_str( "OperatorConstCharStar" ) {} - operator const char*() { return m_str; } - const char* m_str; -}; - -struct OperatorInt { - operator int() { return m_int; } - int m_int; -}; - -struct OperatorLong { -#ifdef _WIN64 - operator int64_t() { return m_long; } - int64_t m_long; -#else - operator long() { return m_long; } - long m_long; -#endif -}; - -struct OperatorDouble { - operator double() { return m_double; } - double m_double; -}; - -struct OperatorShort { - operator short() { return m_short; } - unsigned short m_short; -}; - -struct OperatorUnsignedInt { - operator unsigned int() { return m_uint; } - unsigned int m_uint; -}; - -struct OperatorUnsignedLong { -#ifdef _WIN64 - operator uint64_t() { return m_ulong; } - uint64_t m_ulong; -#else - operator unsigned long() { return m_ulong; } - unsigned long m_ulong; -#endif -}; - -struct OperatorFloat { - operator float() { return m_float; } - float m_float; -}; diff --git a/roottest/python/basic/PyROOT_operatortests.py b/roottest/python/basic/PyROOT_operatortests.py deleted file mode 100644 index ed6197cc15e6c..0000000000000 --- a/roottest/python/basic/PyROOT_operatortests.py +++ /dev/null @@ -1,161 +0,0 @@ -# File: roottest/python/basic/PyROOT_operatortests.py -# Author: Wim Lavrijsen (LBNL, WLavrijsen@lbl.gov) -# Created: 06/04/05 -# Last: 05/05/15 - -"""C++ operators interface unit tests for PyROOT package.""" - -import sys, os, unittest -sys.path.append(os.path.dirname( os.path.dirname(__file__))) - -if not os.path.exists('Operators.C'): - os.chdir(os.path.dirname(__file__)) - -import ROOT -from ROOT import gROOT -from common import * - -__all__ = [ - 'Cpp1OperatorsTestCase', - 'Cpp2ConverterOperatorsTestCase', - 'Cpp3TemplatedMathOperatorsTestCase' -] - -gROOT.LoadMacro( "Operators.C+" ) -Number = ROOT.Number -OperatorCharStar = ROOT.OperatorCharStar -OperatorShort = ROOT.OperatorShort -OperatorConstCharStar = ROOT.OperatorConstCharStar -OperatorUnsignedInt = ROOT.OperatorUnsignedInt -OperatorInt = ROOT.OperatorInt -OperatorUnsignedLong = ROOT.OperatorUnsignedLong -OperatorLong = ROOT.OperatorLong -OperatorFloat = ROOT.OperatorFloat -OperatorDouble = ROOT.OperatorDouble - - -### C++ operators overloading test cases ===================================== -class Cpp1OperatorsTestCase( MyTestCase ): - def test1MathOperators( self ): - """Test overloading of math operators""" - - self.assertEqual( Number(20) + Number(10), Number(30) ) - self.assertEqual( Number(20) + 10 , Number(30) ) - self.assertEqual( Number(20) - Number(10), Number(10) ) - self.assertEqual( Number(20) - 10 , Number(10) ) - self.assertEqual( Number(20) / Number(10), Number(2) ) - self.assertEqual( Number(20) / 10 , Number(2) ) - self.assertEqual( Number(20) * Number(10), Number(200) ) - self.assertEqual( Number(20) * 10 , Number(200) ) - self.assertEqual( Number(20) % 10 , Number(0) ) - self.assertEqual( Number(20) % Number(10), Number(0) ) - self.assertEqual( Number(5) & Number(14), Number(4) ) - self.assertEqual( Number(5) | Number(14), Number(15) ) - self.assertEqual( Number(5) ^ Number(14), Number(11) ) - self.assertEqual( Number(5) << 2, Number(20) ) - self.assertEqual( Number(20) >> 2, Number(5) ) - - def test2UnaryMathOperators( self ): - """Test overloading of unary math operators""" - - n = Number(20) - n += Number(10) - n -= Number(10) - n *= Number(10) - n /= Number(2) - self.assertEqual( n, Number(100) ) - - nn = -n; - self.assertEqual( nn, Number( -100 ) ) - - def test3ComparisonOperators( self ): - """Test overloading of comparison operators""" - - self.assertEqual( Number(20) > Number(10), 1 ) - self.assertEqual( Number(20) < Number(10), 0 ) - self.assertEqual( Number(20) >= Number(20), 1 ) - self.assertEqual( Number(20) <= Number(10), 0 ) - self.assertEqual( Number(20) != Number(10), 1 ) - self.assertEqual( Number(20) == Number(10), 0 ) - - def test4BooleanOperator( self ): - """Test implementation of operator bool""" - - n = Number(20) - self.assertTrue( n ) - - n = Number( 0 ) - self.assertTrue( not n ) - - -### Instance to builtin type converters test cases =========================== -class Cpp2ConverterOperatorsTestCase( MyTestCase ): - def test1ExactTypes( self ): - """Test converter operators of exact types""" - - o = OperatorCharStar() - self.assertEqual( o.m_str, 'OperatorCharStar' ) - self.assertIn( 'OperatorCharStar', repr(o) ) - - o = OperatorConstCharStar() - self.assertEqual( o.m_str, 'OperatorConstCharStar' ) - self.assertIn( 'OperatorConstCharStar', repr(o) ) - - o = OperatorInt(); o.m_int = -13 - self.assertEqual( o.m_int, -13 ) - self.assertEqual( int( o ), -13 ) - - o = OperatorLong(); o.m_long = 42 - self.assertEqual( o.m_long, 42 ) - self.assertEqual( pylong( o ), 42 ) - - o = OperatorDouble(); o.m_double = 3.1415 - self.assertEqual( o.m_double, 3.1415 ) - self.assertEqual( float( o ), 3.1415 ) - - def test2ApproximateTypes( self ): - """Test converter operators of approximate types""" - - o = OperatorShort(); o.m_short = 256 - self.assertEqual( o.m_short, 256 ) - self.assertEqual( int( o ), 256 ) - - o = OperatorUnsignedInt(); o.m_uint = 2147483647 + 32 - self.assertEqual( o.m_uint, 2147483647 + 32 ) - self.assertEqual( pylong( o ), 2147483647 + 32 ) - - o = OperatorUnsignedLong(); o.m_ulong = maxvalue + 128 - self.assertEqual( o.m_ulong, maxvalue + 128 ) - self.assertEqual( pylong( o ), maxvalue + 128 ) - - o = OperatorFloat(); o.m_float = 3.14 - self.assertEqual( round( o.m_float - 3.14, 5 ), 0. ) - self.assertEqual( round( float( o ) - 3.14, 5 ), 0. ) - - -### Templated math operators ================================================= -class Cpp3TemplatedMathOperatorsTestCase( MyTestCase ): - def test01LorentzVector( self ): - """Templated method operator+/-""" - - v1 = ROOT.Math.LorentzVector('ROOT::Math::PxPyPzE4D')(1, 2, 3, 4) - v2 = ROOT.Math.LorentzVector('ROOT::Math::PxPyPzE4D')(4, 3, 2, 1) - - v3 = v1.__add__( v2 ) - self.assertEqual( v3.X(), v1.X() + v2.X() ) - v4 = v1 + v2 - self.assertEqual( v4.X(), v1.X() + v2.X() ) - self.assertEqual( v3, v4 ) - - -## actual test run -if __name__ == '__main__': - from MyTextTestRunner import MyTextTestRunner - - loader = unittest.TestLoader() - testSuite = loader.loadTestsFromModule( sys.modules[ __name__ ] ) - - runner = MyTextTestRunner( verbosity = 2 ) - result = not runner.run( testSuite ).wasSuccessful() - - sys.exit( result ) diff --git a/roottest/python/basic/PyROOT_operatortests.ref b/roottest/python/basic/PyROOT_operatortests.ref deleted file mode 100644 index 5a8c03073df69..0000000000000 --- a/roottest/python/basic/PyROOT_operatortests.ref +++ /dev/null @@ -1,11 +0,0 @@ -Test overloading of math operators ... ok -Test overloading of unary math operators ... ok -Test overloading of comparison operators ... ok -Test implementation of operator bool ... ok -Test converter operators of exact types ... ok -Test converter operators of approximate types ... ok -Templated method operator+/- ... ok - ----------------------------------------------------------------------- - -OK diff --git a/roottest/python/regression/PyROOT_regressiontests.py b/roottest/python/regression/PyROOT_regressiontests.py index 3b6762261a301..6e98713a7aa9a 100644 --- a/roottest/python/regression/PyROOT_regressiontests.py +++ b/roottest/python/regression/PyROOT_regressiontests.py @@ -51,6 +51,7 @@ def WEXITSTATUS(arg): return arg 'Regression16NestedNamespace', 'Regression17MatrixD', 'Regression18FailingDowncast', + "Cpp3TemplatedMathOperatorsTestCase", ] @@ -915,6 +916,21 @@ def test1CheckImplicitSmartPtrOverload(self): self.assertEqual(ROOT.regression27.foo(ROOT.std.move(c)), 2) # we expect the second overload +### Templated math operators ================================================= +class Cpp3TemplatedMathOperatorsTestCase(MyTestCase): + def test01LorentzVector(self): + """Templated method operator+/-""" + + v1 = ROOT.Math.LorentzVector("ROOT::Math::PxPyPzE4D")(1, 2, 3, 4) + v2 = ROOT.Math.LorentzVector("ROOT::Math::PxPyPzE4D")(4, 3, 2, 1) + + v3 = v1.__add__(v2) + self.assertEqual(v3.X(), v1.X() + v2.X()) + v4 = v1 + v2 + self.assertEqual(v4.X(), v1.X() + v2.X()) + self.assertEqual(v3, v4) + + ## actual test run if __name__ == '__main__': from MyTextTestRunner import MyTextTestRunner From f2d7dd3a8f7b45eea53707faf9c349303ce7c19b Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 13 Jan 2026 21:24:10 +0100 Subject: [PATCH 4/5] [roottest] Absorb PyROOT_cpp11tests in cppyy test suite Most tests were already present in the cppyy test suite, except for the `std::tuple_element` test introduced in the following commit: https://github.com/root-project/roottest/commit/c0e6d2002f9c79dbab9a48f3f5ab834c7e03f56b --- .../cppyy/cppyy/test/test_cpp11features.py | 18 +++ roottest/python/cpp/CMakeLists.txt | 6 - roottest/python/cpp/Cpp11Features.C | 40 ------- roottest/python/cpp/PyROOT_cpp11tests.py | 110 ------------------ roottest/python/cpp/PyROOT_cpp11tests.ref | 7 -- 5 files changed, 18 insertions(+), 163 deletions(-) delete mode 100644 roottest/python/cpp/Cpp11Features.C delete mode 100644 roottest/python/cpp/PyROOT_cpp11tests.py delete mode 100644 roottest/python/cpp/PyROOT_cpp11tests.ref diff --git a/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py b/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py index 680101e6d9707..0f55450652517 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py @@ -577,6 +577,24 @@ def pyfunc() -> std.shared_ptr[ns.Dummy]: assert ns.call_creator(pyfunc) + def test20_tuple_element(self): + """ + Check that std::tuple_element works. + + See: https://github.com/root-project/root/issues/14232. + """ + + import cppyy + + cppyy.cppdef(""" + #include + #include + using ATuple = std::tuple; + """) + from cppyy.gbl import ATuple + + cppyy.gbl.std.tuple_element[1, ATuple].type + if __name__ == "__main__": exit(pytest.main(args=['-sv', '-ra', __file__])) diff --git a/roottest/python/cpp/CMakeLists.txt b/roottest/python/cpp/CMakeLists.txt index 1b1dc56327a7c..bbb80869027fa 100644 --- a/roottest/python/cpp/CMakeLists.txt +++ b/roottest/python/cpp/CMakeLists.txt @@ -13,10 +13,4 @@ if(NOT MSVC OR win_broken_tests) PRECMD ${ROOT_root_CMD} -b -q -l -e .L\ AdvancedCpp.C+ -e .L\ Template.C+) endif() - - ROOTTEST_ADD_TEST(cpp11 - MACRO PyROOT_cpp11tests.py - COPY_TO_BUILDDIR Cpp11Features.C - PRECMD ${ROOT_root_CMD} -b -q -l -e .L\ Cpp11Features.C+) - endif() diff --git a/roottest/python/cpp/Cpp11Features.C b/roottest/python/cpp/Cpp11Features.C deleted file mode 100644 index 5dcc4acf5f7ca..0000000000000 --- a/roottest/python/cpp/Cpp11Features.C +++ /dev/null @@ -1,40 +0,0 @@ -/* - File: roottest/python/cpp/Cpp11Features.C - Author: WLavrijsen@lbl.gov - Created: 11/25/13 - Last: 11/26/13 -*/ - -#if defined(__GXX_EXPERIMENTAL_CXX0X) || __cplusplus >= 201103L - -#include - - -// for shared_ptr testing -class MyCounterClass { -public: - static int counter; - -public: - MyCounterClass() { ++counter; } - MyCounterClass( const MyCounterClass& ) { ++counter; } - ~MyCounterClass() { --counter; } -}; - -int MyCounterClass::counter = 0; - -std::shared_ptr< MyCounterClass > CreateMyCounterClass() { - return std::shared_ptr< MyCounterClass >( new MyCounterClass ); -} - - -// from gcc's ext/concurrence.h, typed enum static defined in header -namespace PyTest { - - enum _Lock_policy { _S_single, _S_mutex, _S_atomic }; - static const _Lock_policy __default_lock_policy = _S_mutex; - -} // PyTest namespace - - -#endif diff --git a/roottest/python/cpp/PyROOT_cpp11tests.py b/roottest/python/cpp/PyROOT_cpp11tests.py deleted file mode 100644 index 131c9b7643953..0000000000000 --- a/roottest/python/cpp/PyROOT_cpp11tests.py +++ /dev/null @@ -1,110 +0,0 @@ -# File: roottest/python/cpp11/PyROOT_cpptests.py -# Author: Wim Lavrijsen (LBNL, WLavrijsen@lbl.gov) -# Created: 11/25/13 -# Last: 11/26/13 - -"""C++11 language interface unit tests for PyROOT package.""" - -import sys, os, unittest -sys.path.append(os.path.dirname(os.path.dirname(__file__))) - -import ROOT -from ROOT import TGraphErrors, gROOT -from common import * - -__all__ = [ - 'Cpp1Cpp11StandardClassesTestCase', - 'Cpp2Cpp11LanguageConstructsTestCase' -] - -gROOT.LoadMacro( "Cpp11Features.C+" ) - -MyCounterClass = ROOT.MyCounterClass -CreateMyCounterClass = ROOT.CreateMyCounterClass - -### C++11 standard library classes =========================================== -class Cpp1Cpp11StandardClassesTestCase( MyTestCase ): - def test01SharedPtr( self ): - """Test usage and access of std::shared_ptr<>""" - - # proper memory accounting - self.assertEqual( MyCounterClass.counter, 0 ) - - ptr1 = CreateMyCounterClass() - self.assertTrue( not not ptr1 ) - self.assertEqual( MyCounterClass.counter, 1 ) - - ptr2 = CreateMyCounterClass() - self.assertTrue( not not ptr2 ) - self.assertEqual( MyCounterClass.counter, 2 ) - - del ptr2, ptr1 - import gc; gc.collect() - self.assertEqual( MyCounterClass.counter, 0 ) - - def test02TupleElement(self): - """ - Check that std::tuple_element works in PyROOT. - - See: https://github.com/root-project/root/issues/14232. - """ - - ROOT.gInterpreter.LoadText(""" - #include - #include - using ATuple = std::tuple; - """) - from ROOT import ATuple - - ROOT.std.tuple_element[1, ATuple].type - - def test03InitializerList(self): - """ - Check if we can convert a list of strings to a C++ initializer list. - - Reproducer of https://github.com/root-project/root/issues/11411 - """ - - ROOT.gInterpreter.Declare(""" - void foo(std::initializer_list const& columns) {} - """) - ROOT.foo(["x"]) - - -### C++11 language constructs test cases ===================================== -class Cpp2Cpp11LanguageConstructsTestCase( MyTestCase ): - def test01StaticEnum( self ): - """Test usage and access of a const static enum defined in header""" - - # TODO: this will fail - # self.assertTrue( hasattr( PyTest, '_Lock_policy' ) ) - if not FIXCLING: - self.assertTrue( hasattr( PyTest, '_S_single' ) ) - self.assertTrue( hasattr( PyTest, '__default_lock_policy' ) ) - - def test02NULLPtrPassing( self ): - """Allow the programmer to pass NULL in certain cases""" - - nullptr = ROOT.nullptr - - self.assertNotEqual( nullptr, 0 ) - if os.environ.get('LEGACY_PYROOT') == 'True': - # In new Cppyy, TGraphErrors(0,0,0) is accepted. - # I.e. it is allowed to pass 0 when the argument is of pointer type. - self.assertRaises( TypeError, TGraphErrors, 0, 0, 0 ) - - g = TGraphErrors( 0, nullptr, nullptr ) - self.assertEqual( round( g.GetMean(), 8 ), 0.0 ) - - -## actual test run -if __name__ == '__main__': - from MyTextTestRunner import MyTextTestRunner - - loader = unittest.TestLoader() - testSuite = loader.loadTestsFromModule( sys.modules[ __name__ ] ) - - runner = MyTextTestRunner( verbosity = 2 ) - result = not runner.run( testSuite ).wasSuccessful() - - sys.exit( result ) diff --git a/roottest/python/cpp/PyROOT_cpp11tests.ref b/roottest/python/cpp/PyROOT_cpp11tests.ref deleted file mode 100644 index efd8f402bbab0..0000000000000 --- a/roottest/python/cpp/PyROOT_cpp11tests.ref +++ /dev/null @@ -1,7 +0,0 @@ -Test usage and access of std::shared_ptr<> ... ok -Test usage and access of a const static enum defined in header ... ok -Allow the programmer to pass NULL in certain cases ... ok - ----------------------------------------------------------------------- - -OK From 67495c2e07d0daf0645026f543b828622624210c Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Tue, 13 Jan 2026 18:48:00 +0100 Subject: [PATCH 5/5] [cppyy] Don't exclude any tests at the CMake level We should be more granular and consistent when disabling tests. --- .../pyroot/cppyy/cppyy/test/CMakeLists.txt | 42 ++++--------------- .../cppyy/cppyy/test/test_cpp11features.py | 4 +- .../pyroot/cppyy/cppyy/test/test_leakcheck.py | 7 +++- 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt b/bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt index af7346dab41a5..69aaa6ce76447 100644 --- a/bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt +++ b/bindings/pyroot/cppyy/cppyy/test/CMakeLists.txt @@ -4,28 +4,10 @@ # For the licensing terms see $ROOTSYS/LICENSE. # For the list of contributors see $ROOTSYS/README/CREDITS. -set(enable_test_cpp11features FALSE) -if(NOT CMAKE_CXX_STANDARD EQUAL 23) - # test_cpp11features crashes when run with C++23 - if(APPLE) - execute_process( - COMMAND sw_vers -productVersion - OUTPUT_VARIABLE MACOS_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(MACOS_VERSION VERSION_LESS "26.0") - # Parts of this test suite fail with std::make_unique - set(enable_test_cpp11features TRUE) - endif() - else() - set(enable_test_cpp11features TRUE) - endif() -endif() +set(common_args GENERIC PYTHON_DEPS pytest) -if(MSVC) - set(common_args GENERIC PYTHON_DEPS pytest) -else() - set(common_args GENERIC ENVIRONMENT ${ld_library_path}=${CMAKE_CURRENT_BINARY_DIR} PYTHON_DEPS pytest) +if(NOT MSVC) + list(APPEND common_args ENVIRONMENT ${ld_library_path}=${CMAKE_CURRENT_BINARY_DIR}) endif() set(root_cmd $ -b -q -l) @@ -45,14 +27,16 @@ function(ADD_PYUNITTEST_ACLIC TESTNAME) endfunction() ADD_PYUNITTEST_ACLIC(test_conversions DICTNAME conversions) +ADD_PYUNITTEST_ACLIC(test_cpp11features DICTNAME cpp11features) ADD_PYUNITTEST_ACLIC(test_crossinheritance DICTNAME crossinheritance) ADD_PYUNITTEST_ACLIC(test_doc_features DICTNAME doc_helper) ADD_PYUNITTEST_ACLIC(test_fragile DICTNAME fragile) ADD_PYUNITTEST_ACLIC(test_operators DICTNAME operators) ADD_PYUNITTEST_ACLIC(test_overloads DICTNAME overloads) +ADD_PYUNITTEST_ACLIC(test_pythonization DICTNAME pythonizables) +ADD_PYUNITTEST_ACLIC(test_stltypes DICTNAME stltypes) ADD_PYUNITTEST_ACLIC(test_streams DICTNAME std_streams) ADD_PYUNITTEST_ACLIC(test_templates DICTNAME templates) -ADD_PYUNITTEST_ACLIC(test_pythonization DICTNAME pythonizables) ROOT_ADD_PYUNITTEST(test_pythonify test_pythonify.py ${common_args} COPY_TO_BUILDDIR example01.cxx example01.h @@ -77,18 +61,6 @@ ROOT_ADD_PYUNITTEST(test_boost test_boost.py ${common_args}) ROOT_ADD_PYUNITTEST(test_concurrent test_concurrent.py ${common_args}) ROOT_ADD_PYUNITTEST(test_datatypes test_datatypes.py ${common_args} FIXTURES_REQUIRED datatypes_dict_fixture) ROOT_ADD_PYUNITTEST(test_eigen test_eigen.py ${common_args}) +ROOT_ADD_PYUNITTEST(test_leakcheck test_leakcheck.py ${common_args}) ROOT_ADD_PYUNITTEST(test_numba test_numba.py ${common_args}) ROOT_ADD_PYUNITTEST(test_regression test_regression.py ${common_args}) - -if(NOT APPLE) - # test_stltypes completely fails on OSX - # because it is unable to load the necessary shared libraries - ADD_PYUNITTEST_ACLIC(test_stltypes DICTNAME stltypes) -endif() - -if(enable_test_cpp11features) - ADD_PYUNITTEST_ACLIC(test_cpp11features DICTNAME cpp11features) -endif() - -# The leakcheck test is disabled due to its sporadic nature, especially fragile on VMs -# ROOT_ADD_PYUNITTEST(test_leakcheck test_leakcheck.py ${common_args}) diff --git a/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py b/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py index 0f55450652517..a67a31d528c94 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_cpp11features.py @@ -440,7 +440,7 @@ def test14_shared_ptr_passing(self): gc.collect() assert TestSmartPtr.s_counter == 0 - @mark.xfail(condition=IS_WINDOWS, reason='ValueError: Could not find "make_unique"') + @mark.xfail(condition=IS_WINDOWS | IS_MAC_ARM, reason='ValueError: Could not find "make_unique"') def test15_unique_ptr_template_deduction(self): """Argument type deduction with std::unique_ptr""" @@ -460,7 +460,7 @@ def test15_unique_ptr_template_deduction(self): with raises(ValueError): # not an RValue cppyy.gbl.UniqueTempl.returnptr[int](uptr_in) - @mark.xfail(condition=IS_WINDOWS, reason='TypeError: Could not find "make_unique"') + @mark.xfail(condition=IS_WINDOWS | IS_MAC_ARM, reason='TypeError: Could not find "make_unique"') def test16_unique_ptr_moves(self): """std::unique_ptr requires moves""" diff --git a/bindings/pyroot/cppyy/cppyy/test/test_leakcheck.py b/bindings/pyroot/cppyy/cppyy/test/test_leakcheck.py index a57495b8cfd9e..15305c8ff081b 100644 --- a/bindings/pyroot/cppyy/cppyy/test/test_leakcheck.py +++ b/bindings/pyroot/cppyy/cppyy/test/test_leakcheck.py @@ -73,7 +73,7 @@ def check_func(self, scope, func, *args, **kwds): assert fail < M - @mark.xfail(reason="disabled due to its sporadic nature, especially fragile on VMs") + @mark.skip(reason="disabled due to its sporadic nature, especially fragile on VMs") def test01_free_functions(self): """Leak test of free functions""" @@ -126,6 +126,7 @@ class MyClass02 { self.check_func(m, 'static_method_ol', 42., tmpl_args='float') self.check_func(m, 'static_method_ret') + @mark.skip(reason="disabled due to its sporadic nature, especially fragile on VMs") def test03_test_methods(self): """Leak test of methods""" @@ -152,6 +153,7 @@ class MyClass03 { self.check_func(m, 'method_ol', 42., tmpl_args='float') self.check_func(m, 'method_ret') + @mark.skip(reason="disabled due to its sporadic nature, especially fragile on VMs") def test04_default_arguments(self): """Leak test for functions with default arguments""" @@ -193,7 +195,7 @@ class MyClass04 { self.check_func(m, 'method_default', b=-99) self.check_func(m, 'method_default', c=-99) - @mark.xfail(condition=IS_MAC_ARM or (WINDOWS_BITS == 64), reason="Fails on Windows 64 bit and OSX-ARM") + @mark.skip(reason="disabled due to its sporadic nature, especially fragile on VMs") def test05_aggregates(self): """Leak test of aggregate creation""" @@ -257,6 +259,7 @@ class Leaker { obj = ns.Leaker() self.check_func(obj, 'leak_string', 2048) + @mark.skip(reason="disabled due to its sporadic nature, especially fragile on VMs") def test08_list_creation(self): """Leak check of creating a python list from an std::list"""