Cleanup: Better logging for imbuf tests

Recent failures requiring investigation have exposed some shortcomings
that this addresses:
- When creating the diff image for offline comparison, use a higher
  threshold to prevent idiff from printing more output which will often
  contradict the primary failure output just above it (very confusing)
- For metadata failures, make sure these get printed so it's obvious
  what kind of failure we're dealing with

Pull Request: https://projects.blender.org/blender/blender/pulls/107058
This commit is contained in:
Jesse Yurkovich 2023-04-18 03:32:20 +02:00 committed by Jesse Yurkovich
parent 302eb1e0d7
commit 1bb77d9eae
2 changed files with 13 additions and 6 deletions

View File

@ -32,6 +32,7 @@ class ImBufTest(AbstractImBufTest):
colorspace = img.colorspace_settings.name
alpha_mode = img.alpha_mode
actual_metadata = f"{channels=} {is_float=} {colorspace=} {alpha_mode=}"
expected_metadata = ""
# Save actual metadata
out_metadata_path.write_text(actual_metadata, encoding="utf-8")
@ -52,10 +53,14 @@ class ImBufTest(AbstractImBufTest):
failed = True
if failed and self.update:
# Update reference if requested.
ref_metadata_path.write_text(actual_metadata, encoding="utf-8")
failed = False
if failed:
if self.update:
# Update reference if requested.
ref_metadata_path.write_text(actual_metadata, encoding="utf-8")
failed = False
else:
print_message(
"Expected [{}] but got [{}]".format(expected_metadata, actual_metadata))
return not failed

View File

@ -73,12 +73,14 @@ class AbstractImBufTest(unittest.TestCase):
shutil.copy(out_filepath, ref_filepath)
failed = False
# Generate diff image.
# Generate diff image (set fail thresholds high to reduce output spam).
diff_img = str(self.diff_dir.joinpath(out_name + ".diff.png"))
command = (
str(self.idiff),
"-o", diff_img,
"-fail", "1",
"-failpercent", "100",
"-abs", "-scale", "16",
"-o", diff_img,
ref_filepath,
out_filepath
)