From 0c3abb21296e25d6b5fd8ccc139d1484524b2033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Mon, 22 Aug 2016 17:57:22 +0200 Subject: [test] Show error message when expected file does not exist --- test/src/mbgl/test/util.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/src/mbgl/test/util.cpp b/test/src/mbgl/test/util.cpp index 393d65b667..a674eafeb4 100644 --- a/test/src/mbgl/test/util.cpp +++ b/test/src/mbgl/test/util.cpp @@ -121,9 +121,23 @@ void checkImage(const std::string& base, } #endif - PremultipliedImage expected = decodeImage(util::read_file(base + "/expected.png")); + std::string expected_image; + try { + expected_image = util::read_file(base + "/expected.png"); + } catch (std::exception& ex) { + Log::Error(Event::Setup, "Failed to load expected image %s: %s", + (base + "/expected.png").c_str(), ex.what()); + throw; + } + + PremultipliedImage expected = decodeImage(expected_image); PremultipliedImage diff { expected.width, expected.height }; + +#if !TEST_READ_ONLY + util::write_file(base + "/actual.png", encodePNG(actual)); +#endif + ASSERT_EQ(expected.width, actual.width); ASSERT_EQ(expected.height, actual.height); @@ -137,7 +151,6 @@ void checkImage(const std::string& base, EXPECT_LE(pixels / (expected.width * expected.height), imageThreshold); #if !TEST_READ_ONLY - util::write_file(base + "/actual.png", encodePNG(actual)); util::write_file(base + "/diff.png", encodePNG(diff)); #endif } -- cgit v1.2.1