From f8954836b276d3d8d5f787216bc89c906fc0575e Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Mon, 14 Jul 2025 13:46:32 +0200 Subject: [PATCH 1/3] changes with updates printing policy --- python/cppyy/_typemap.py | 2 +- test/test_doc_features.py | 12 ++++++------ test/test_fragile.py | 10 +++++----- test/test_pythonization.py | 15 +++++++++++++-- test/test_regression.py | 19 ++++++++++++++----- test/test_templates.py | 4 ++-- 6 files changed, 41 insertions(+), 21 deletions(-) diff --git a/python/cppyy/_typemap.py b/python/cppyy/_typemap.py index 3aefbf4e..8263b1e5 100644 --- a/python/cppyy/_typemap.py +++ b/python/cppyy/_typemap.py @@ -104,4 +104,4 @@ def voidp_init(self, arg=0): import cppyy, ctypes if arg == cppyy.nullptr: arg = 0 ctypes.c_void_p.__init__(self, arg) - tm['void*'] = _create_mapper(ctypes.c_void_p, {'__init__' : voidp_init}) + tm['void *'] = _create_mapper(ctypes.c_void_p, {'__init__' : voidp_init}) diff --git a/test/test_doc_features.py b/test/test_doc_features.py index fdf940d8..b9e9ca4e 100644 --- a/test/test_doc_features.py +++ b/test/test_doc_features.py @@ -131,7 +131,7 @@ class Abstract2 { template C multiply(A a, B b) { - return C{a*b}; + return static_cast(a * b); } //----- @@ -253,8 +253,8 @@ def test_keyword_arguments(self): def test_doc_strings(self): import cppyy from cppyy.gbl import Concrete - assert 'void Concrete::array_method(int* ad, int size)' in Concrete.array_method.__doc__ - assert 'void Concrete::array_method(double* ad, int size)' in Concrete.array_method.__doc__ + assert 'void Concrete::array_method(int * ad, int size)' in Concrete.array_method.__doc__ + assert 'void Concrete::array_method(double * ad, int size)' in Concrete.array_method.__doc__ def test_enums(self): import cppyy @@ -682,7 +682,7 @@ def test08_shared_ptr(self): assert type(Zoo.free_lion).__name__ == 'Lion' smart_lion = Zoo.free_lion.__smartptr__() - assert type(smart_lion).__name__ in ['shared_ptr', 'std::shared_ptr'] + assert type(smart_lion).__name__ in ['shared_ptr', 'std::shared_ptr', 'shared_ptr', 'std::shared_ptr'] assert Zoo.identify_animal(Zoo.free_lion) == "the animal is a lion" assert Zoo.identify_animal_smart(Zoo.free_lion) == "the animal is a lion" @@ -698,9 +698,9 @@ def test09_templated_function(self): assert 'multiply' in cppyy.gbl.__dict__ assert mul(1, 2) == 2 - assert 'multiply' in cppyy.gbl.__dict__ + assert 'multiply' in cppyy.gbl.__dict__ assert mul(1., 5) == 5. - assert 'multiply' in cppyy.gbl.__dict__ + assert 'multiply' in cppyy.gbl.__dict__ assert mul[int] (1, 1) == 1 assert 'multiply' in cppyy.gbl.__dict__ diff --git a/test/test_fragile.py b/test/test_fragile.py index 7fc90355..a3fd72a6 100644 --- a/test/test_fragile.py +++ b/test/test_fragile.py @@ -193,11 +193,11 @@ def test10_documentation(self): # likewise there are still minor differences in descriptiveness of messages assert "fragile::D::overload()" in str(e) assert "TypeError: takes at most 0 arguments (1 given)" in str(e) - assert "fragile::D::overload(fragile::no_such_class*)" in str(e) + assert "fragile::D::overload(fragile::no_such_class *)" in str(e) #assert "no converter available for 'fragile::no_such_class*'" in str(e) assert "void fragile::D::overload(char, int i = 0)" in str(e) #assert "char or small int type expected" in str(e) - assert "void fragile::D::overload(int, fragile::no_such_class* p = 0)" in str(e) + assert "void fragile::D::overload(int, fragile::no_such_class * p = 0)" in str(e) #assert "int/long conversion expects an integer object" in str(e) j = fragile.J() @@ -243,9 +243,9 @@ def test11_dir(self): namespace Cppyy { - typedef size_t TCppScope_t; + typedef void* TCppScope_t; - CPPYY_IMPORT TCppScope_t GetScope(const std::string& scope_name); + CPPYY_IMPORT TCppScope_t GetScope(const std::string& scope_name, TCppScope_t parent_scope = nullptr); CPPYY_IMPORT void GetAllCppNames(TCppScope_t scope, std::set& cppnames); }""") @@ -399,7 +399,7 @@ def test15_const_in_name(self): assert cppyy.gbl.myvar3 assert cppyy.gbl.myvar4 - @mark.xfail + @mark.xfail(run=False, reason="Crashes sometimes; might have been caused by https://github.com/compiler-research/CPyCppyy/pull/109") def test16_opaque_handle(self): """Support use of opaque handles""" diff --git a/test/test_pythonization.py b/test/test_pythonization.py index c0d97343..57dcb071 100644 --- a/test/test_pythonization.py +++ b/test/test_pythonization.py @@ -55,13 +55,24 @@ def pythonizor(klass, name): assert cppyy.gbl.pyzables.SomeDummy2.test == 3 + cppyy.cppdef(""" + namespace pyzables { + class TObjString { + public: + std::string s; + TObjString(std::string ss) : s(ss) {} + size_t Sizeof() { return s.size() + 1; } + }; + } + """) + def root_pythonizor(klass, name): - if name == 'CppyyLegacy::TObjString': + if name == 'pyzables::TObjString': klass.__len__ = klass.Sizeof cppyy.py.add_pythonization(root_pythonizor) - assert len(cppyy.gbl.CppyyLegacy.TObjString("aap")) == 4 # include '\0' + assert len(cppyy.gbl.pyzables.TObjString("aap")) == 4 # include '\0' def test01_size_mapping(self): """Use composites to map GetSize() onto buffer returns""" diff --git a/test/test_regression.py b/test/test_regression.py index b2e158cf..b8495b34 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -54,15 +54,24 @@ def test02_dir(self): import cppyy, pydoc - assert not '__abstractmethods__' in dir(cppyy.gbl.cling.runtime.gCling) - assert '__class__' in dir(cppyy.gbl.cling.runtime.gCling) + cppyy.cppdef(""" + namespace docs { + struct MyDocs { + void fn() {} + } s; + MyDocs *ptrDocs = &s; + } + """) + + assert not '__abstractmethods__' in dir(cppyy.gbl.docs.ptrDocs) + assert '__class__' in dir(cppyy.gbl.docs.ptrDocs) self.__class__.helpout = [] - pydoc.doc(cppyy.gbl.cling.runtime.gCling) + pydoc.doc(cppyy.gbl.docs.ptrDocs) helptext = ''.join(self.__class__.helpout) - assert 'TInterpreter' in helptext + assert 'MyDocs' in helptext assert 'CPPInstance' in helptext - assert 'AddIncludePath' in helptext + assert 'fn' in helptext cppyy.cppdef("namespace cppyy_regression_test { void iii() {}; }") diff --git a/test/test_templates.py b/test/test_templates.py index db919820..19455550 100644 --- a/test/test_templates.py +++ b/test/test_templates.py @@ -1190,13 +1190,13 @@ def test01_using(self): assert 'in_type' in dir(tct[int, dum, 4]) assert in_type.__name__ == 'in_type' - assert in_type.__cpp_name__ == 'TemplatedTypedefs::DerivedWithUsing::in_type' + assert in_type.__cpp_name__ == 'TemplatedTypedefs::DerivedWithUsing::in_type' # XXX: may need to custom printing instead of depending on clang (for default template args) in_type_tt = tct[int, dum, 4].in_type_tt assert 'in_type_tt' in dir(tct[int, dum, 4]) assert in_type_tt.__name__ == 'in_type_tt' - assert in_type_tt.__cpp_name__ == 'TemplatedTypedefs::DerivedWithUsing::in_type_tt' + assert in_type_tt.__cpp_name__ == 'TemplatedTypedefs::DerivedWithUsing::in_type_tt' @mark.xfail def test02_mapped_type_as_internal(self): From 8a34e0fc88fa0ddd1d03cbcc05f47c5c8bdc2910 Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Mon, 14 Jul 2025 14:56:16 +0200 Subject: [PATCH 2/3] [test] update tags --- test/test_advancedcpp.py | 5 ++--- test/test_boost.py | 4 ++-- test/test_crossinheritance.py | 2 +- test/test_datatypes.py | 6 +----- test/test_doc_features.py | 12 ++++-------- test/test_fragile.py | 11 ++++------- test/test_leakcheck.py | 1 - test/test_lowlevel.py | 4 ---- test/test_pythonization.py | 2 +- test/test_regression.py | 5 ++--- test/test_stltypes.py | 2 +- test/test_templates.py | 17 +++++------------ 12 files changed, 23 insertions(+), 48 deletions(-) diff --git a/test/test_advancedcpp.py b/test/test_advancedcpp.py index d59ba37f..ecf3be1e 100644 --- a/test/test_advancedcpp.py +++ b/test/test_advancedcpp.py @@ -1,6 +1,6 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, pylong, IS_WINDOWS, IS_MAC, IS_LINUX, ispypy, IS_CLANG_REPL, IS_MAC_ARM, IS_MAC_X86, IS_VALGRIND +from .support import setup_make, pylong, IS_WINDOWS, IS_MAC, IS_LINUX, ispypy, IS_CLANG_REPL, IS_MAC_ARM, IS_MAC_X86, IS_VALGRIND, IS_CLING currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("advancedcppDict")) @@ -688,7 +688,7 @@ def test20_overload_order_with_proper_return(self): assert cppyy.gbl.overload_one_way().gime() == 1 assert cppyy.gbl.overload_the_other_way().gime() == "aap" - @mark.xfail(run=not IS_VALGRIND, condition = (IS_CLANG_REPL or IS_LINUX), reason="Fails on both Cling and Clang-Repl, Valgrind issue on Clang-Repl") + @mark.xfail(run=not IS_VALGRIND, condition =(IS_LINUX and IS_CLING), reason="Fails on Linux Cling") def test21_access_to_global_variables(self): """Access global_variables_and_pointers""" @@ -842,7 +842,6 @@ def test26_using_directive(self): assert cppyy.gbl.UserDirs.bar() == cppyy.gbl.UsedSpace2.bar() assert cppyy.gbl.UserDirs.foo2() == cppyy.gbl.UsedSpace1.inner.foo2() - @mark.xfail(reason="See https://github.com/compiler-research/CppInterOp/pull/93") def test27_shadowed_typedef(self): """Test that typedefs are not shadowed""" diff --git a/test/test_boost.py b/test/test_boost.py index a3eb38f1..63e75cf6 100644 --- a/test/test_boost.py +++ b/test/test_boost.py @@ -28,7 +28,7 @@ def test01_any_class(self): assert std.list[any] - @mark.skip + @mark.xfail(run=False) def test02_any_usage(self): """boost::any assignment and casting""" @@ -101,7 +101,7 @@ def setup_class(cls): cppyy.include("boost/variant/variant.hpp") cppyy.include("boost/variant/get.hpp") - @mark.skip + @mark.xfail(run=False) def test01_variant_usage(self): """boost::variant usage""" diff --git a/test/test_crossinheritance.py b/test/test_crossinheritance.py index 3e1c847b..b9d93092 100644 --- a/test/test_crossinheritance.py +++ b/test/test_crossinheritance.py @@ -1720,7 +1720,7 @@ def __del__(self): del o1 assert Derived.was_py_deleted == True - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test37_deep_tree(self): """Find overridable methods deep in the tree""" diff --git a/test/test_datatypes.py b/test/test_datatypes.py index 65360bdd..b60ffe12 100644 --- a/test/test_datatypes.py +++ b/test/test_datatypes.py @@ -192,7 +192,6 @@ def test01_instance_data_read_access(self): c.__destruct__() - @mark.xfail def test02_instance_data_write_access(self): """Test write access to instance public data and verify values""" @@ -1270,7 +1269,7 @@ def run(self, f, buf, total): if self.has_byte: run(self, cppyy.gbl.sum_byte_data, buf, total) - @mark.xfail(run=not(IS_MAC), reason="Crashes on OS X") + @mark.xfail(run=False, condition=IS_MAC, reason="Crashes on OSX") def test26_function_pointers(self): """Function pointer passing""" @@ -2224,7 +2223,6 @@ def test45_const_ref_data(self): b = ns.B() assert b.body1.name == b.body2.name - @mark.xfail def test46_small_int_enums(self): """Proper typing of small int enums""" @@ -2279,7 +2277,6 @@ def test46_small_int_enums(self): assert ns.func_int8() == -1 assert ns.func_uint8() == 255 - @mark.xfail def test47_hidden_name_enum(self): """Usage of hidden name enum""" @@ -2315,7 +2312,6 @@ def test47_hidden_name_enum(self): }""") #ns.bar(ns.Foo.FOO) - @mark.xfail def test48_bool_typemap(self): """Test mapping of bool type typedefs""" diff --git a/test/test_doc_features.py b/test/test_doc_features.py index b9e9ca4e..196a58ae 100644 --- a/test/test_doc_features.py +++ b/test/test_doc_features.py @@ -1,6 +1,6 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, ispypy, IS_WINDOWS, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC, IS_MAC_X86, IS_MAC_ARM, IS_LINUX_ARM +from .support import setup_make, ispypy, IS_WINDOWS, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC, IS_MAC_X86, IS_MAC_ARM, IS_LINUX_ARM, IS_VALGRIND currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("doc_helperDict")) @@ -249,7 +249,6 @@ def test_keyword_arguments(self): c = Concrete(**kwds) assert c.m_int == 18 - @mark.xfail def test_doc_strings(self): import cppyy from cppyy.gbl import Concrete @@ -661,7 +660,7 @@ def test07_run_zoo(self): assert Zoo.identify_animal(mouse) == "the animal is a mouse" assert Zoo.identify_animal(lion) == "the animal is a lion" - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test08_shared_ptr(self): """Shared pointer transparency""" @@ -687,7 +686,6 @@ def test08_shared_ptr(self): assert Zoo.identify_animal(Zoo.free_lion) == "the animal is a lion" assert Zoo.identify_animal_smart(Zoo.free_lion) == "the animal is a lion" - @mark.xfail def test09_templated_function(self): """Templated free function""" @@ -722,7 +720,7 @@ def test09_templated_function(self): assert mul['double, double, double'](1., 5) == 5. - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test10_stl_algorithm(self): """STL algorithm on std::string""" @@ -763,7 +761,6 @@ def pythonize_A(klass, name): assert Advert01.A(1) raises(TypeError, Advert01.A, 1.) - @mark.xfail def test02_use_c_void_p(self): """Use of opaque handles and ctypes.c_void_p""" @@ -798,7 +795,6 @@ def test02_use_c_void_p(self): Advert02.Picam_OpenFirstCamera(cam) assert Advert02.Picam_CloseCamera(cam) - @mark.xfail def test03_use_of_ctypes_and_enum(self): """Use of (opaque) enum through ctypes.c_void_p""" @@ -1193,7 +1189,7 @@ def f(val): assert CC.callPtr(lambda i: 5*i, 4) == 20 assert CC.callFun(lambda i: 6*i, 4) == 24 - @mark.xfail + @mark.xfail(run=False, condition=IS_VALGRIND and IS_LINUX_ARM, reason="Crashes on Valgrind-ARM") def test_templated_callback(self): """Templated callback example""" diff --git a/test/test_fragile.py b/test/test_fragile.py index a3fd72a6..9455435e 100644 --- a/test/test_fragile.py +++ b/test/test_fragile.py @@ -27,7 +27,6 @@ def test01_load_failure(self): except RuntimeError as e: assert "does_not_exist" in str(e) - @mark.xfail def test02_missing_classes(self): """Test (non-)access to missing classes""" @@ -39,7 +38,9 @@ def test02_missing_classes(self): assert cppyy.gbl.fragile == cppyy.gbl.fragile fragile = cppyy.gbl.fragile - raises(AttributeError, getattr, fragile, "no_such_class") + # FIXME: Should be fixed with root dictionary + # look at https://github.com/wlav/cppyy/discussions/306 + # raises(AttributeError, getattr, fragile, "no_such_class") assert fragile.C is fragile.C assert fragile.C == fragile.C @@ -167,7 +168,6 @@ def test09_operator_bool(self): g = cppyy.gbl.fragile.gI assert not g - @mark.xfail def test10_documentation(self): """Check contents of documentation""" @@ -213,7 +213,7 @@ def test10_documentation(self): except TypeError as e: assert "cannot instantiate abstract class 'fragile::O'" in str(e) - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test11_dir(self): """Test __dir__ method""" @@ -448,7 +448,6 @@ def test17_interactive(self): finally: sys.path = oldsp - @mark.xfail def test18_overload(self): """Test usage of __overload__""" @@ -694,7 +693,6 @@ def test01_stl_in_std(self): v = cppyy.gbl.vector() assert cppyy.gbl.vector is not cppyy.gbl.std.vector - @mark.xfail def test02_ctypes_in_both(self): """Standard int types live in both global and std::""" @@ -708,7 +706,6 @@ def test02_ctypes_in_both(self): assert cppyy.gbl.std.int8_t(-42) == cppyy.gbl.int8_t(-42) assert cppyy.gbl.std.uint8_t(42) == cppyy.gbl.uint8_t(42) - @mark.xfail def test03_clashing_using_in_global(self): """Redefines of std:: typedefs should be possible in global""" diff --git a/test/test_leakcheck.py b/test/test_leakcheck.py index 837e3d73..0a676618 100644 --- a/test/test_leakcheck.py +++ b/test/test_leakcheck.py @@ -185,7 +185,6 @@ class MyClass04 { self.check_func(m, 'method_default', b=-99) self.check_func(m, 'method_default', c=-99) - @mark.skip(reason="Crashes when run with whole test suite") def test05_aggregates(self): """Leak test of aggregate creation""" diff --git a/test/test_lowlevel.py b/test/test_lowlevel.py index 6a151b9e..b6a9c48d 100644 --- a/test/test_lowlevel.py +++ b/test/test_lowlevel.py @@ -473,7 +473,6 @@ def test13_array_interface(self): a[0] = 5 assert b[0] == 5 - @mark.xfail def test14_templated_arrays(self): """Use of arrays in template types""" @@ -536,7 +535,6 @@ def setup_class(cls): def _data_m(self, lbl): return [('m_'+tp.replace(' ', '_')+lbl, tp) for tp in self.numeric_builtin_types] - @mark.xfail def test01_2D_arrays(self): """Access and use of 2D data members""" @@ -579,7 +577,6 @@ def test01_2D_arrays(self): assert arr[i][j] == val assert arr[i, j] == val - @mark.xfail def test02_assign_2D_arrays(self): """Direct assignment of 2D arrays""" @@ -632,7 +629,6 @@ def test02_assign_2D_arrays(self): arr[2][3] = 10 assert arr[2][3] == 10 - @mark.xfail def test03_3D_arrays(self): """Access and use of 3D data members""" diff --git a/test/test_pythonization.py b/test/test_pythonization.py index 57dcb071..9c1f3255 100644 --- a/test/test_pythonization.py +++ b/test/test_pythonization.py @@ -15,7 +15,7 @@ def setup_class(cls): import cppyy cls.pyzables = cppyy.load_reflection_info(cls.test_dct) - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test00_api(self): """Test basic semantics of the pythonization API""" diff --git a/test/test_regression.py b/test/test_regression.py index b8495b34..507432af 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -45,7 +45,6 @@ def test01_kdcraw(self): assert 'KDcraw' in helptext assert 'CPPInstance' in helptext - @mark.xfail def test02_dir(self): """For the same reasons as test01_kdcraw, this used to crash.""" @@ -194,7 +193,7 @@ def test07_class_refcounting(self): assert sys.getrefcount(x) == old_refcnt - @mark.xfail(run=not(IS_MAC and IS_CLING)) + @mark.xfail(run=False, condition=IS_MAC and IS_CLING, reason="Crahes on OSX-Cling") def test08_typedef_identity(self): """Nested typedefs should retain identity""" @@ -357,7 +356,7 @@ class Bar { f = sds.Foo() assert f.bar.x == 5 - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test15_vector_vs_initializer_list(self): """Prefer vector in template and initializer_list in formal arguments""" diff --git a/test/test_stltypes.py b/test/test_stltypes.py index 59fe8064..003c11ca 100644 --- a/test/test_stltypes.py +++ b/test/test_stltypes.py @@ -927,7 +927,7 @@ def test08_string_operators(self): assert s1+s2 == "Hello, World!" assert s2+s1 == ", World!Hello" - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test09_string_as_str_bytes(self): """Python-style methods of str/bytes on std::string""" diff --git a/test/test_templates.py b/test/test_templates.py index 19455550..ab00c626 100644 --- a/test/test_templates.py +++ b/test/test_templates.py @@ -23,7 +23,6 @@ def test00_template_back_reference(self): v1 = cppyy.gbl.std.vector[int] assert v1.__cpp_template__[int] is v1 - @mark.xfail def test01_template_member_functions(self): """Template member functions lookup and calls""" @@ -153,7 +152,7 @@ def test05_variadic_overload(self): assert cppyy.gbl.isSomeInt() == False assert cppyy.gbl.isSomeInt(1, 2, 3) == False - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test06_variadic_sfinae(self): """Attribute testing through SFINAE""" @@ -170,7 +169,6 @@ def test06_variadic_sfinae(self): assert call_has_var1(move(Obj1())) == True assert call_has_var1(move(Obj2())) == False - @mark.xfail def test07_type_deduction(self): """Traits/type deduction""" @@ -225,7 +223,6 @@ def test08_using_of_static_data(self): # assert b2.ref_value == 42 assert b2.m_value == 42 - @mark.xfail def test09_templated_callable(self): """Test that templated operator() translates to __call__""" @@ -435,7 +432,7 @@ def get_tn(ns): b.b_T['int'](1, 1., 'a') assert get_tn(ns).find("int(some_variadic::B::*)(int&&,double&&,std::") == 0 - @mark.xfail + @mark.xfail(condition=IS_MAC, reason="Fails on OSX") def test17_empty_body(self): """Use of templated function with empty body""" @@ -447,7 +444,6 @@ def test17_empty_body(self): assert f_T[int]() is None assert cppyy.gbl.T_WithEmptyBody.side_effect == "side effect" - @mark.xfail def test18_greedy_overloads(self): """void*/void** should not pre-empt template instantiations""" @@ -606,7 +602,7 @@ def callback(x): assert cppyy.gbl.std.function['double(std::vector)'] - @mark.xfail(run=(IS_MAC and IS_CLANG_REPL)) + @mark.xfail(run=False, condition=IS_VALGRIND and IS_LINUX_ARM, reason="Crashes on Valgrind-ARM") def test25_stdfunction_ref_and_ptr_args(self): """Use of std::function with reference or pointer args""" @@ -793,7 +789,7 @@ def test28_enum_in_constructor(self): assert ns.FS('i', ns.ST.TI.I32, ns.FS.R.EQ, 10) - @mark.xfail + @mark.xfail(run=False, condition=IS_VALGRIND and IS_LINUX_ARM, reason="Crashes on Valgrind-ARM") def test29_function_ptr_as_template_arg(self): """Function pointers as template arguments""" @@ -905,7 +901,7 @@ class Templated: public NonTemplated { ns.Templated() # used to crash - @mark.xfail(run=IS_CLANG_REPL, reason="Crashed with Cling") + @mark.xfail(run=False, condition=IS_CLING, reason="Crashed with Cling") def test31_ltlt_in_template_name(self): """Verify lookup of template names with << in the name""" @@ -1198,7 +1194,6 @@ def test01_using(self): assert in_type_tt.__name__ == 'in_type_tt' assert in_type_tt.__cpp_name__ == 'TemplatedTypedefs::DerivedWithUsing::in_type_tt' - @mark.xfail def test02_mapped_type_as_internal(self): """Test that mapped types can be used as builtin""" @@ -1242,7 +1237,6 @@ def test03_mapped_type_as_template_arg(self): assert tct['long double', dum, 4] is tct[in_type, dum, 4] assert tct['double', dum, 4] is not tct[in_type, dum, 4] - @mark.xfail def test04_type_deduction(self): """Usage of type reducer""" @@ -1258,7 +1252,6 @@ def test04_type_deduction(self): three = w.whatis(3) assert three == 3 - @mark.xfail def test05_type_deduction_and_extern(self): """Usage of type reducer with extern template""" From d578ddb9c4f8bb3f5d8857bc3b30acc690dfce7d Mon Sep 17 00:00:00 2001 From: Vipul Cariappa Date: Wed, 22 Jan 2025 13:23:21 +0530 Subject: [PATCH 3/3] Debug XFails --- .github/workflows/MacOS.yml | 38 +++-------------------------------- .github/workflows/Ubuntu.yml | 14 +------------ test/support.py | 9 +++++++++ test/test_aclassloader.py | 4 +++- test/test_advancedcpp.py | 5 ++++- test/test_api.py | 4 +++- test/test_boost.py | 5 ++++- test/test_concurrent.py | 4 +++- test/test_conversions.py | 5 ++++- test/test_cpp11features.py | 4 +++- test/test_crossinheritance.py | 4 +++- test/test_datatypes.py | 4 +++- test/test_doc_features.py | 5 ++++- test/test_eigen.py | 5 ++++- test/test_fragile.py | 5 ++++- test/test_leakcheck.py | 5 ++++- test/test_lowlevel.py | 5 ++++- test/test_numba.py | 5 ++++- test/test_operators.py | 5 ++++- test/test_overloads.py | 5 ++++- test/test_pythonify.py | 5 ++++- test/test_pythonization.py | 4 +++- test/test_regression.py | 3 ++- test/test_stltypes.py | 5 ++++- test/test_streams.py | 5 ++++- test/test_templates.py | 5 ++++- 26 files changed, 96 insertions(+), 71 deletions(-) diff --git a/.github/workflows/MacOS.yml b/.github/workflows/MacOS.yml index 2362b0c6..2279caac 100644 --- a/.github/workflows/MacOS.yml +++ b/.github/workflows/MacOS.yml @@ -534,7 +534,7 @@ jobs: run: | # Run the tests source ${{ github.workspace }}/CppInterOp/.venv/bin/activate - cd ${{ github.workspace }}/test/ + cd ${{ github.workspace }}/test echo ::group::Prepare For Testing make all python -m pip install --upgrade pip @@ -542,44 +542,12 @@ jobs: python -m pip install pytest-xdist python -m pip install numba echo ::endgroup:: - echo ::group::Run complete test suite - set -o pipefail - python -m pytest -sv -ra | tee complete_testrun.log 2>&1 - set +o pipefail echo ::group::Crashing Test Logs - # See if we don't have a crash that went away - # Comment out all xfails but the ones that have a run=False condition. - find . -name "*.py" -exec sed -i '/run=False/!s/^ *@mark.xfail\(.*\)/#&/' {} \; - python -m pytest -n 1 -m "xfail" --runxfail -sv -ra --max-worker-restart 512 | tee test_crashed.log 2>&1 || true - git checkout . + python -m pytest -n 1 -v -ra --max-worker-restart 512 | tee test_crashed.log 2>&1 || true echo ::endgroup:: - echo ::group::XFAIL Test Logs - # Rewrite all xfails that have a run clause to skipif. This way we will - # avoid conditionally crashing xfails - find . -name "*.py" -exec gsed -i -E 's/(^ *)@mark.xfail\(run=(.*)/\1@mark.skipif(condition=not \2/g' {} \; - # See if we don't have an xfail that went away - python -m pytest --runxfail -sv -ra | tee test_xfailed.log 2>&1 || true - git checkout . - echo ::endgroup:: - echo ::group::Passing Test Logs - - # Run the rest of the non-crashing tests. - declare -i RETCODE=0 - - set -o pipefail - export RETCODE=+$? - echo ::endgroup:: - - RETCODE=+$? - echo "Complete Test Suite Summary: \n" - tail -n1 complete_testrun.log - echo "Crashing Summary: \n" + echo "Crashing Summary:" tail -n1 test_crashed.log - echo "XFAIL Summary:" - tail -n1 test_xfailed.log - echo "Return Code: ${RETCODE}" - exit $RETCODE - name: Show debug info if: ${{ failure() }} diff --git a/.github/workflows/Ubuntu.yml b/.github/workflows/Ubuntu.yml index de578072..a8c32938 100644 --- a/.github/workflows/Ubuntu.yml +++ b/.github/workflows/Ubuntu.yml @@ -620,10 +620,6 @@ jobs: python -m uv pip install numba python -m uv pip install psutil echo ::endgroup:: - echo ::group::Run complete test suite - set -o pipefail - python -m pytest -sv -ra | tee complete_testrun.log 2>&1 - set +o pipefail echo ::group::Crashing Test Logs # See if we don't have a crash that went away # Comment out all xfails but the ones that have a run=False condition. @@ -666,16 +662,8 @@ jobs: unset IS_VALGRIND echo ::endgroup:: - RETCODE=+$? - - echo "Complete Test Suite Summary: \n" - tail -n1 complete_testrun.log - echo "Crashing Summary: \n" + echo "Crashing Summary:" tail -n1 test_crashed.log - echo "XFAIL Summary:" - tail -n1 test_xfailed.log - echo "Return Code: ${RETCODE}" - exit $RETCODE - name: Show debug info if: ${{ failure() }} diff --git a/test/support.py b/test/support.py index ae856400..60cee7c1 100644 --- a/test/support.py +++ b/test/support.py @@ -75,3 +75,12 @@ def setup_make(targetname): #endif\n""") == 1) IS_CLING = not IS_CLANG_REPL IS_VALGRIND = True if os.getenv("IS_VALGRIND") else False + +from pytest import mark + +proxy = mark.xfail +def monkey_patch(*args, **kwargs): + if "run" in kwargs: + del kwargs["run"] + + return proxy(*args, **kwargs) diff --git a/test/test_aclassloader.py b/test/test_aclassloader.py index 16c21176..c08d4368 100644 --- a/test/test_aclassloader.py +++ b/test/test_aclassloader.py @@ -1,6 +1,8 @@ import py, os, sys from pytest import raises, mark -from .support import setup_make +from .support import setup_make, monkey_patch + +mark.xfail = monkey_patch currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("example01Dict")) diff --git a/test/test_advancedcpp.py b/test/test_advancedcpp.py index ecf3be1e..29f5accc 100644 --- a/test/test_advancedcpp.py +++ b/test/test_advancedcpp.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, pylong, IS_WINDOWS, IS_MAC, IS_LINUX, ispypy, IS_CLANG_REPL, IS_MAC_ARM, IS_MAC_X86, IS_VALGRIND, IS_CLING +from .support import setup_make, pylong, IS_WINDOWS, IS_MAC, IS_LINUX, ispypy, IS_CLANG_REPL, IS_MAC_ARM, IS_MAC_X86, IS_VALGRIND, IS_CLING, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("advancedcppDict")) diff --git a/test/test_api.py b/test/test_api.py index 24509945..ab7da4f0 100644 --- a/test/test_api.py +++ b/test/test_api.py @@ -1,6 +1,8 @@ import py, os, sys from pytest import raises, skip, mark -from .support import ispypy, IS_MAC, IS_LINUX_ARM +from .support import ispypy, IS_MAC, IS_LINUX_ARM, monkey_patch + +mark.xfail = monkey_patch class TestAPI: diff --git a/test/test_boost.py b/test/test_boost.py index 63e75cf6..03846f97 100644 --- a/test/test_boost.py +++ b/test/test_boost.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import mark, raises, skip -from .support import setup_make, IS_CLANG_REPL, IS_MAC_X86, IS_MAC_ARM +from .support import setup_make, IS_CLANG_REPL, IS_MAC_X86, IS_MAC_ARM, monkey_patch + +mark.xfail = monkey_patch + noboost = False if not (os.path.exists(os.path.join(os.path.sep, 'usr', 'include', 'boost')) or \ diff --git a/test/test_concurrent.py b/test/test_concurrent.py index 5d74d0cd..31f87504 100644 --- a/test/test_concurrent.py +++ b/test/test_concurrent.py @@ -1,6 +1,8 @@ import py, os, sys from pytest import raises, skip, mark -from .support import IS_MAC_ARM, IS_MAC_X86, IS_LINUX_ARM +from .support import IS_MAC_ARM, IS_MAC_X86, IS_LINUX_ARM, monkey_patch + +mark.xfail = monkey_patch class TestCONCURRENT: diff --git a/test/test_conversions.py b/test/test_conversions.py index 6953ff55..a012cd04 100644 --- a/test/test_conversions.py +++ b/test/test_conversions.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, mark -from .support import setup_make, IS_LINUX, IS_CLANG_REPL, IS_CLING, IS_MAC +from .support import setup_make, IS_LINUX, IS_CLANG_REPL, IS_CLING, IS_MAC, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("conversionsDict")) diff --git a/test/test_cpp11features.py b/test/test_cpp11features.py index e64a2ffd..9018693c 100644 --- a/test/test_cpp11features.py +++ b/test/test_cpp11features.py @@ -1,6 +1,8 @@ import py, os, sys from pytest import raises, mark -from .support import setup_make, ispypy, IS_CLANG_REPL, IS_LINUX_ARM, IS_LINUX, IS_MAC, IS_CLING, IS_VALGRIND +from .support import setup_make, ispypy, IS_CLANG_REPL, IS_LINUX_ARM, IS_LINUX, IS_MAC, IS_CLING, IS_VALGRIND, monkey_patch + +mark.xfail = monkey_patch currpath = py.path.local(__file__).dirpath() diff --git a/test/test_crossinheritance.py b/test/test_crossinheritance.py index b9d93092..5003c9e3 100644 --- a/test/test_crossinheritance.py +++ b/test/test_crossinheritance.py @@ -1,6 +1,8 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, pylong, IS_MAC_ARM, IS_MAC, IS_CLANG_REPL, IS_CLANG_DEBUG, IS_LINUX_ARM, IS_LINUX, IS_CLING, IS_VALGRIND +from .support import setup_make, pylong, IS_MAC_ARM, IS_MAC, IS_CLANG_REPL, IS_CLANG_DEBUG, IS_LINUX_ARM, IS_LINUX, IS_CLING, IS_VALGRIND, monkey_patch + +mark.xfail = monkey_patch currpath = py.path.local(__file__).dirpath() diff --git a/test/test_datatypes.py b/test/test_datatypes.py index b60ffe12..538c8e44 100644 --- a/test/test_datatypes.py +++ b/test/test_datatypes.py @@ -1,6 +1,8 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, pylong, pyunicode, IS_CLANG_REPL, IS_CLING, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_LINUX +from .support import setup_make, pylong, pyunicode, IS_CLANG_REPL, IS_CLING, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_LINUX, monkey_patch + +mark.xfail = monkey_patch IS_MAC = IS_MAC_X86 or IS_MAC_ARM diff --git a/test/test_doc_features.py b/test/test_doc_features.py index 196a58ae..faffaf6f 100644 --- a/test/test_doc_features.py +++ b/test/test_doc_features.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, ispypy, IS_WINDOWS, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC, IS_MAC_X86, IS_MAC_ARM, IS_LINUX_ARM, IS_VALGRIND +from .support import setup_make, ispypy, IS_WINDOWS, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC, IS_MAC_X86, IS_MAC_ARM, IS_LINUX_ARM, IS_VALGRIND, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("doc_helperDict")) diff --git a/test/test_eigen.py b/test/test_eigen.py index 9c04a103..5517d7c2 100644 --- a/test/test_eigen.py +++ b/test/test_eigen.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import mark, raises -from .support import setup_make, IS_CLANG_REPL, IS_CLING, IS_MAC_X86 +from .support import setup_make, IS_CLANG_REPL, IS_CLING, IS_MAC_X86, monkey_patch + +mark.xfail = monkey_patch + inc_paths = [os.path.join(os.path.sep, 'usr', 'include'), os.path.join(os.path.sep, 'usr', 'local', 'include')] diff --git a/test/test_fragile.py b/test/test_fragile.py index 9455435e..700a9a9e 100644 --- a/test/test_fragile.py +++ b/test/test_fragile.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, ispypy, IS_LINUX, IS_WINDOWS, IS_MAC_ARM, IS_CLANG_REPL, IS_MAC +from .support import setup_make, ispypy, IS_LINUX, IS_WINDOWS, IS_MAC_ARM, IS_CLANG_REPL, IS_MAC, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() diff --git a/test/test_leakcheck.py b/test/test_leakcheck.py index 0a676618..189e3096 100644 --- a/test/test_leakcheck.py +++ b/test/test_leakcheck.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import mark, skip -from .support import setup_make, pylong, pyunicode, IS_CLANG_REPL +from .support import setup_make, pylong, pyunicode, IS_CLANG_REPL, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("datatypesDict")) diff --git a/test/test_lowlevel.py b/test/test_lowlevel.py index b6a9c48d..ca488309 100644 --- a/test/test_lowlevel.py +++ b/test/test_lowlevel.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, pylong, pyunicode, IS_WINDOWS, ispypy, IS_CLING, IS_MAC, IS_VALGRIND +from .support import setup_make, pylong, pyunicode, IS_WINDOWS, ispypy, IS_CLING, IS_MAC, IS_VALGRIND, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("datatypesDict")) diff --git a/test/test_numba.py b/test/test_numba.py index 5077fdc4..a1634305 100644 --- a/test/test_numba.py +++ b/test/test_numba.py @@ -1,7 +1,10 @@ import py, os, sys import math, time from pytest import mark, raises -from .support import setup_make +from .support import setup_make, monkey_patch + +mark.xfail = monkey_patch + try: import numba diff --git a/test/test_operators.py b/test/test_operators.py index 7cad02d5..7e66c5b7 100644 --- a/test/test_operators.py +++ b/test/test_operators.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, pylong, maxvalue, IS_WINDOWS, IS_MAC, IS_CLANG_REPL, IS_CLING +from .support import setup_make, pylong, maxvalue, IS_WINDOWS, IS_MAC, IS_CLANG_REPL, IS_CLING, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("operatorsDict")) diff --git a/test/test_overloads.py b/test/test_overloads.py index 67b85ac0..ce59df9d 100644 --- a/test/test_overloads.py +++ b/test/test_overloads.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, ispypy, IS_WINDOWS, IS_MAC, IS_MAC_ARM +from .support import setup_make, ispypy, IS_WINDOWS, IS_MAC, IS_MAC_ARM, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("overloadsDict")) diff --git a/test/test_pythonify.py b/test/test_pythonify.py index b3cf3892..5aebeeb1 100644 --- a/test/test_pythonify.py +++ b/test/test_pythonify.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, pylong, ispypy, IS_CLANG_REPL, IS_CLING, IS_MAC_ARM, IS_MAC_X86, IS_MAC +from .support import setup_make, pylong, ispypy, IS_CLANG_REPL, IS_CLING, IS_MAC_ARM, IS_MAC_X86, IS_MAC, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("example01Dict")) diff --git a/test/test_pythonization.py b/test/test_pythonization.py index 9c1f3255..c0c9bf65 100644 --- a/test/test_pythonization.py +++ b/test/test_pythonization.py @@ -1,6 +1,8 @@ import py, os, sys from pytest import raises, mark -from .support import setup_make, pylong, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_CLANG_REPL, IS_LINUX_ARM, IS_VALGRIND +from .support import setup_make, pylong, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_CLANG_REPL, IS_LINUX_ARM, IS_VALGRIND, monkey_patch + +mark.xfail = monkey_patch currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("pythonizablesDict")) diff --git a/test/test_regression.py b/test/test_regression.py index 507432af..525203fb 100644 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -1,7 +1,8 @@ import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, IS_WINDOWS, ispypy, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC +from .support import setup_make, IS_WINDOWS, ispypy, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC, monkey_patch +mark.xfail = monkey_patch class TestREGRESSION: helpout = [] diff --git a/test/test_stltypes.py b/test/test_stltypes.py index 003c11ca..056bf658 100644 --- a/test/test_stltypes.py +++ b/test/test_stltypes.py @@ -1,7 +1,10 @@ # -*- coding: UTF-8 -*- import py, os, sys from pytest import raises, skip, mark -from .support import setup_make, pylong, pyunicode, maxvalue, ispypy, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_VALGRIND, IS_LINUX_ARM +from .support import setup_make, pylong, pyunicode, maxvalue, ispypy, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_VALGRIND, IS_LINUX_ARM, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("stltypesDict")) diff --git a/test/test_streams.py b/test/test_streams.py index d120c645..3a05117d 100644 --- a/test/test_streams.py +++ b/test/test_streams.py @@ -1,6 +1,9 @@ import py, os, sys from pytest import raises, mark -from .support import setup_make, IS_MAC, IS_CLANG_REPL +from .support import setup_make, IS_MAC, IS_CLANG_REPL, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("std_streamsDict")) diff --git a/test/test_templates.py b/test/test_templates.py index ab00c626..2ae85ac5 100644 --- a/test/test_templates.py +++ b/test/test_templates.py @@ -1,6 +1,9 @@ import py, os from pytest import raises, mark -from .support import setup_make, pylong, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_LINUX_ARM, IS_VALGRIND +from .support import setup_make, pylong, IS_CLANG_REPL, IS_CLING, IS_CLANG_DEBUG, IS_MAC_X86, IS_MAC_ARM, IS_MAC, IS_LINUX_ARM, IS_VALGRIND, monkey_patch + +mark.xfail = monkey_patch + currpath = py.path.local(__file__).dirpath() test_dct = str(currpath.join("templatesDict"))