From a93ed3bcb7910ce740022d25d642af087a4dfbc1 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Tue, 21 Apr 2020 08:15:26 -0400 Subject: Strengthen modifiers test validation, from D7397. Submitting on behalf of Jesse Y (deadpin). In test harness for modifier testing, now run mesh validation on output mesh. Also, fix printing so it interleaves properly. --- tests/python/modules/mesh_test.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/python/modules/mesh_test.py b/tests/python/modules/mesh_test.py index 9fb487bcef9..f188d998884 100644 --- a/tests/python/modules/mesh_test.py +++ b/tests/python/modules/mesh_test.py @@ -41,8 +41,15 @@ import bpy -import os +import functools import inspect +import os + + +# Output from this module and from blender itself will occur during tests. +# We need to flush python so that the output is properly interleaved, otherwise +# blender's output for one test will end up showing in the middle of another test... +print = functools.partial(print, flush=True) class ModifierSpec: @@ -165,8 +172,8 @@ class MeshTest: """ self.operations_stack.append(operator_spec) - def _on_failed_test(self, compare, evaluated_test_object): - if self.update: + def _on_failed_test(self, compare_result, validation_success, evaluated_test_object): + if self.update and validation_success: if self.verbose: print("Test failed expectantly. Updating expected mesh...") @@ -178,8 +185,7 @@ class MeshTest: evaluated_test_object.name = expected_object_name # Save file - blend_file = bpy.data.filepath - bpy.ops.wm.save_as_mainfile(filepath=blend_file) + bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath) self._test_updated = True @@ -188,10 +194,10 @@ class MeshTest: return True else: - blender_file = bpy.data.filepath - print("Test failed with error: {}. Resulting object mesh '{}' did not match expected object '{}' " - "from file blender file {}". - format(compare, evaluated_test_object.name, self.expected_object.name, blender_file)) + print("Test comparison result: {}".format(compare_result)) + print("Test validation result: {}".format(validation_success)) + print("Resulting object mesh '{}' did not match expected object '{}' from file {}". + format(evaluated_test_object.name, self.expected_object.name, bpy.data.filepath)) return False @@ -306,10 +312,13 @@ class MeshTest: print("Comparing expected mesh with resulting mesh...") evaluated_test_mesh = evaluated_test_object.data expected_mesh = self.expected_object.data - compare = evaluated_test_mesh.unit_test_compare(mesh=expected_mesh) - success = (compare == 'Same') + compare_result = evaluated_test_mesh.unit_test_compare(mesh=expected_mesh) + compare_success = (compare_result == 'Same') + + # Also check if invalid geometry (which is never expected) had to be corrected... + validation_success = evaluated_test_mesh.validate(verbose=True) == False - if success: + if compare_success and validation_success: if self.verbose: print("Success!") @@ -321,7 +330,7 @@ class MeshTest: return True else: - return self._on_failed_test(compare, evaluated_test_object) + return self._on_failed_test(compare_result, validation_success, evaluated_test_object) class OperatorTest: -- cgit v1.2.3