forked from bartvdbraak/blender
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.
This commit is contained in:
parent
9528fa2c46
commit
a93ed3bcb7
@ -41,8 +41,15 @@
|
|||||||
|
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import os
|
import functools
|
||||||
import inspect
|
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:
|
class ModifierSpec:
|
||||||
@ -165,8 +172,8 @@ class MeshTest:
|
|||||||
"""
|
"""
|
||||||
self.operations_stack.append(operator_spec)
|
self.operations_stack.append(operator_spec)
|
||||||
|
|
||||||
def _on_failed_test(self, compare, evaluated_test_object):
|
def _on_failed_test(self, compare_result, validation_success, evaluated_test_object):
|
||||||
if self.update:
|
if self.update and validation_success:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print("Test failed expectantly. Updating expected mesh...")
|
print("Test failed expectantly. Updating expected mesh...")
|
||||||
|
|
||||||
@ -178,8 +185,7 @@ class MeshTest:
|
|||||||
evaluated_test_object.name = expected_object_name
|
evaluated_test_object.name = expected_object_name
|
||||||
|
|
||||||
# Save file
|
# Save file
|
||||||
blend_file = bpy.data.filepath
|
bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath)
|
||||||
bpy.ops.wm.save_as_mainfile(filepath=blend_file)
|
|
||||||
|
|
||||||
self._test_updated = True
|
self._test_updated = True
|
||||||
|
|
||||||
@ -188,10 +194,10 @@ class MeshTest:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
blender_file = bpy.data.filepath
|
print("Test comparison result: {}".format(compare_result))
|
||||||
print("Test failed with error: {}. Resulting object mesh '{}' did not match expected object '{}' "
|
print("Test validation result: {}".format(validation_success))
|
||||||
"from file blender file {}".
|
print("Resulting object mesh '{}' did not match expected object '{}' from file {}".
|
||||||
format(compare, evaluated_test_object.name, self.expected_object.name, blender_file))
|
format(evaluated_test_object.name, self.expected_object.name, bpy.data.filepath))
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -306,10 +312,13 @@ class MeshTest:
|
|||||||
print("Comparing expected mesh with resulting mesh...")
|
print("Comparing expected mesh with resulting mesh...")
|
||||||
evaluated_test_mesh = evaluated_test_object.data
|
evaluated_test_mesh = evaluated_test_object.data
|
||||||
expected_mesh = self.expected_object.data
|
expected_mesh = self.expected_object.data
|
||||||
compare = evaluated_test_mesh.unit_test_compare(mesh=expected_mesh)
|
compare_result = evaluated_test_mesh.unit_test_compare(mesh=expected_mesh)
|
||||||
success = (compare == 'Same')
|
compare_success = (compare_result == 'Same')
|
||||||
|
|
||||||
if success:
|
# Also check if invalid geometry (which is never expected) had to be corrected...
|
||||||
|
validation_success = evaluated_test_mesh.validate(verbose=True) == False
|
||||||
|
|
||||||
|
if compare_success and validation_success:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
print("Success!")
|
print("Success!")
|
||||||
|
|
||||||
@ -321,7 +330,7 @@ class MeshTest:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return self._on_failed_test(compare, evaluated_test_object)
|
return self._on_failed_test(compare_result, validation_success, evaluated_test_object)
|
||||||
|
|
||||||
|
|
||||||
class OperatorTest:
|
class OperatorTest:
|
||||||
|
Loading…
Reference in New Issue
Block a user