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. Pull Request: https://projects.blender.org/blender/blender/pulls/123204
This commit is contained in:
@@ -167,12 +167,20 @@ 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 +192,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 +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)
|
||||
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 +384,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 +407,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 +444,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 +459,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 +739,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__
|
||||
|
||||
Reference in New Issue
Block a user