From 2d997edb07f52c6b9222b01f261cdcd09475c387 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 13 Jun 2024 14:15:59 -0400 Subject: [PATCH 1/2] Tests: Add option to allow index changes for certain mesh comparison tests Currently the mesh boolean code is producing a different index order on the latest version of XCode on macOS. This is proving very difficult to investigate, and it's preventing developers from spending time on more important things. As a compromise for now, allow configuring certain geometry nodes tests to make meshes with a different index order still pass the test. This can be done by adding a boolean custom property with the name `allow_index_change` to the test object and setting it to "True". Allow the index change on different platforms is unfortunate, spending time on working on a replacement exact boolean algorithm is a more valuable use of time currently. After this commit lands, someone who can reproduce the failing test on their computer should update tests to include that custom property as necessary. --- tests/python/modules/mesh_test.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/python/modules/mesh_test.py b/tests/python/modules/mesh_test.py index 67578636a0e..e5d1ae5543d 100644 --- a/tests/python/modules/mesh_test.py +++ b/tests/python/modules/mesh_test.py @@ -167,12 +167,13 @@ class MeshTest(ABC): A mesh testing Abstract class that hold common functionalities for testting operations. """ - def __init__(self, test_object_name, exp_object_name, test_name=None, threshold=None, do_compare=True): + def __init__(self, test_object_name, exp_object_name, test_name=None, threshold=None, allow_index_change=False, do_compare=True): """ :arg test_object_name: str - Name of object of mesh type to run the operations on. :arg exp_object_name: str - Name of object of mesh type that has the expected geometry after running the operations. :arg test_name: str - Name of the test. + :arg allow_index_change: Allow the test to pass even if the mesh element indices are different. :arg threshold: exponent: To allow variations and accept difference to a certain degree. :arg do_compare: bool - True if we want to compare the test and expected objects, False otherwise. """ @@ -184,6 +185,7 @@ class MeshTest(ABC): filepath = bpy.data.filepath self.test_name = bpy.path.display_name_from_filepath(filepath) self.threshold = threshold + self.allow_index_change = allow_index_change self.do_compare = do_compare self.update = os.getenv("BLENDER_TEST_UPDATE") is not None self.verbose = os.getenv("BLENDER_VERBOSE") is not None @@ -254,7 +256,7 @@ class MeshTest(ABC): print("Compare evaluated and expected object in Blender.\n") return False - result = self.compare_meshes(self.evaluated_object, self.expected_object, self.threshold) + result = self.compare_meshes(self.evaluated_object, self.expected_object, self.threshold, self.allow_index_change) # Initializing with True to get correct resultant of result_code booleans. success = True @@ -371,7 +373,7 @@ class MeshTest(ABC): self.expected_object = self.evaluated_object @staticmethod - def compare_meshes(evaluated_object, expected_object, threshold): + def compare_meshes(evaluated_object, expected_object, threshold, allow_index_change): """ Compares evaluated object mesh with expected object mesh. @@ -394,6 +396,8 @@ class MeshTest(ABC): if result_mesh == "Same": result_codes['Mesh Comparison'] = (True, result_mesh) + elif allow_index_change and result_mesh == "The meshes are the same up to a change of indices": + result_codes['Mesh Comparison'] = (True, result_mesh) else: result_codes['Mesh Comparison'] = (False, result_mesh) @@ -429,7 +433,8 @@ class SpecMeshTest(MeshTest): exp_object_name, operations_stack=None, apply_modifier=True, - threshold=None): + threshold=None, + allow_index_change=False): """ Constructor for SpecMeshTest. @@ -443,7 +448,7 @@ class SpecMeshTest(MeshTest): This affects operations of type ModifierSpec and DeformModifierSpec. """ - super().__init__(test_object_name, exp_object_name, test_name, threshold) + super().__init__(test_object_name, exp_object_name, test_name, threshold, allow_index_change) self.test_name = test_name if operations_stack is None: self.operations_stack = [] @@ -723,6 +728,11 @@ class BlendFileTest(MeshTest): blend file i.e. without adding them from scratch or without adding specifications. """ + def __init__(self, test_object_name, exp_object_name, threshold=None): + super().__init__(test_object_name, exp_object_name, threshold) + if bpy.data.objects[test_object_name].get("allow_index_change"): + self.allow_index_change = True + def apply_operations(self, evaluated_test_object_name): BlendFileTest.apply_operations.__doc__ = MeshTest.apply_operations.__doc__ -- 2.30.2 From c146d863c42638c77a28322083f936ea2041c85d Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 13 Jun 2024 14:16:50 -0400 Subject: [PATCH 2/2] Formatting --- tests/python/modules/mesh_test.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/python/modules/mesh_test.py b/tests/python/modules/mesh_test.py index e5d1ae5543d..a544417d766 100644 --- a/tests/python/modules/mesh_test.py +++ b/tests/python/modules/mesh_test.py @@ -167,7 +167,14 @@ class MeshTest(ABC): A mesh testing Abstract class that hold common functionalities for testting operations. """ - def __init__(self, test_object_name, exp_object_name, test_name=None, threshold=None, allow_index_change=False, do_compare=True): + def __init__( + self, + test_object_name, + exp_object_name, + test_name=None, + threshold=None, + allow_index_change=False, + do_compare=True): """ :arg test_object_name: str - Name of object of mesh type to run the operations on. :arg exp_object_name: str - Name of object of mesh type that has the expected @@ -256,7 +263,11 @@ class MeshTest(ABC): print("Compare evaluated and expected object in Blender.\n") return False - result = self.compare_meshes(self.evaluated_object, self.expected_object, self.threshold, self.allow_index_change) + result = self.compare_meshes( + self.evaluated_object, + self.expected_object, + self.threshold, + self.allow_index_change) # Initializing with True to get correct resultant of result_code booleans. success = True -- 2.30.2