Tests: Include test URL in fuzzy mismatch reports

The test logs tend to get a bit mixed together, so this makes it
possible to identify which values correspond to which test when multiple
are failing at once.
This commit is contained in:
Sam Atkins 2025-08-06 12:20:30 +01:00 committed by Jelle Raaijmakers
commit 9b6c26e347
Notes: github-actions[bot] 2025-08-06 11:52:49 +00:00
3 changed files with 6 additions and 6 deletions

View file

@ -13,7 +13,7 @@
namespace TestWeb { namespace TestWeb {
// https://web-platform-tests.org/writing-tests/reftests.html#fuzzy-matching // https://web-platform-tests.org/writing-tests/reftests.html#fuzzy-matching
bool fuzzy_screenshot_match(URL::URL const& reference, Gfx::Bitmap const& bitmap_a, Gfx::Bitmap const& bitmap_b, bool fuzzy_screenshot_match(URL::URL const& test_url, URL::URL const& reference, Gfx::Bitmap const& bitmap_a, Gfx::Bitmap const& bitmap_b,
Vector<FuzzyMatch> const& fuzzy_matches) Vector<FuzzyMatch> const& fuzzy_matches)
{ {
// If the bitmaps are identical, we don't perform fuzzy matching. // If the bitmaps are identical, we don't perform fuzzy matching.
@ -28,18 +28,18 @@ bool fuzzy_screenshot_match(URL::URL const& reference, Gfx::Bitmap const& bitmap
return true; return true;
}); });
if (!fuzzy_match.has_value()) { if (!fuzzy_match.has_value()) {
warnln("Screenshot mismatch: pixel error count {}, with maximum error {}. (No fuzzy config defined)", diff.pixel_error_count, diff.maximum_error); warnln("{}: Screenshot mismatch: pixel error count {}, with maximum error {}. (No fuzzy config defined)", test_url, diff.pixel_error_count, diff.maximum_error);
return false; return false;
} }
// Apply fuzzy matching. // Apply fuzzy matching.
auto color_error_matches = fuzzy_match->color_value_error.contains(diff.maximum_error); auto color_error_matches = fuzzy_match->color_value_error.contains(diff.maximum_error);
if (!color_error_matches) if (!color_error_matches)
warnln("Fuzzy mismatch: maximum error {} is outside {}", diff.maximum_error, fuzzy_match->color_value_error); warnln("{}: Fuzzy mismatch: maximum error {} is outside {}", test_url, diff.maximum_error, fuzzy_match->color_value_error);
auto pixel_error_matches = fuzzy_match->pixel_error_count.contains(diff.pixel_error_count); auto pixel_error_matches = fuzzy_match->pixel_error_count.contains(diff.pixel_error_count);
if (!pixel_error_matches) if (!pixel_error_matches)
warnln("Fuzzy mismatch: pixel error count {} is outside {}", diff.pixel_error_count, fuzzy_match->pixel_error_count); warnln("{}: Fuzzy mismatch: pixel error count {} is outside {}", test_url, diff.pixel_error_count, fuzzy_match->pixel_error_count);
return color_error_matches && pixel_error_matches; return color_error_matches && pixel_error_matches;
} }

View file

@ -28,7 +28,7 @@ struct FuzzyMatch {
FuzzyRange pixel_error_count; FuzzyRange pixel_error_count;
}; };
bool fuzzy_screenshot_match(URL::URL const& reference, Gfx::Bitmap const&, Gfx::Bitmap const&, Vector<FuzzyMatch> const&); bool fuzzy_screenshot_match(URL::URL const& test_url, URL::URL const& reference, Gfx::Bitmap const&, Gfx::Bitmap const&, Vector<FuzzyMatch> const&);
ErrorOr<FuzzyMatch> parse_fuzzy_match(Optional<URL::URL const&> reference, String const&); ErrorOr<FuzzyMatch> parse_fuzzy_match(Optional<URL::URL const&> reference, String const&);
ErrorOr<FuzzyRange> parse_fuzzy_range(String const&); ErrorOr<FuzzyRange> parse_fuzzy_range(String const&);

View file

@ -369,7 +369,7 @@ static void run_ref_test(TestWebView& view, Test& test, URL::URL const& url, int
VERIFY(test.ref_test_expectation_type.has_value()); VERIFY(test.ref_test_expectation_type.has_value());
auto should_match = test.ref_test_expectation_type == RefTestExpectationType::Match; auto should_match = test.ref_test_expectation_type == RefTestExpectationType::Match;
auto screenshot_matches = fuzzy_screenshot_match( auto screenshot_matches = fuzzy_screenshot_match(
view.url(), *test.actual_screenshot, *test.expectation_screenshot, test.fuzzy_matches); url, view.url(), *test.actual_screenshot, *test.expectation_screenshot, test.fuzzy_matches);
if (should_match == screenshot_matches) if (should_match == screenshot_matches)
return TestResult::Pass; return TestResult::Pass;