From 1bb77d9eae191344e1247f9ba22f923561458257 Mon Sep 17 00:00:00 2001 From: Jesse Yurkovich Date: Tue, 18 Apr 2023 03:32:20 +0200 Subject: [PATCH] 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 --- tests/python/bl_imbuf_load.py | 13 +++++++++---- tests/python/modules/imbuf_test.py | 6 ++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/python/bl_imbuf_load.py b/tests/python/bl_imbuf_load.py index 9ccc25168e4..8a2ffca0281 100644 --- a/tests/python/bl_imbuf_load.py +++ b/tests/python/bl_imbuf_load.py @@ -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 diff --git a/tests/python/modules/imbuf_test.py b/tests/python/modules/imbuf_test.py index 55d59b5c302..f5dc7011d34 100644 --- a/tests/python/modules/imbuf_test.py +++ b/tests/python/modules/imbuf_test.py @@ -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 )