From cfc0ef0b6574d931922d5025cb9b79863916872d Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 3 Apr 2023 12:15:14 -0700 Subject: [PATCH] meson: fix tests when zlib is disabled This sometimes shows up in CI if zlib is not found. Signed-off-by: Rosen Penev --- unitTests/meson.build | 7 ++++++- unitTests/test_ImageFactory.cpp | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/unitTests/meson.build b/unitTests/meson.build index ea4c32c7..d5875a83 100644 --- a/unitTests/meson.build +++ b/unitTests/meson.build @@ -23,7 +23,6 @@ test_sources = files( 'test_image_int.cpp', 'test_jp2image.cpp', 'test_jp2image_int.cpp', - 'test_pngimage.cpp', 'test_safe_op.cpp', 'test_slice.cpp', 'test_tiffheader.cpp', @@ -39,6 +38,12 @@ if get_option('video') ) endif +if zlib_dep.found() + test_sources += files( + 'test_pngimage.cpp', + ) +endif + if host_machine.system() == 'windows' and get_option('default_library') != 'static' test_sources += int_lib endif diff --git a/unitTests/test_ImageFactory.cpp b/unitTests/test_ImageFactory.cpp index fb19fec2..2cea548f 100644 --- a/unitTests/test_ImageFactory.cpp +++ b/unitTests/test_ImageFactory.cpp @@ -22,7 +22,9 @@ TEST(TheImageFactory, createsInstancesForFewSupportedTypesInMemory) { EXPECT_NO_THROW(ImageFactory::create(ImageType::jpeg)); EXPECT_NO_THROW(ImageFactory::create(ImageType::exv)); EXPECT_NO_THROW(ImageFactory::create(ImageType::pgf)); +#ifdef EXV_HAVE_LIBZ EXPECT_NO_THROW(ImageFactory::create(ImageType::png)); +#endif } TEST(TheImageFactory, cannotCreateInstancesForMostTypesInMemory) { @@ -66,7 +68,9 @@ TEST(TheImageFactory, createsInstancesForFewSupportedTypesInFiles) { EXPECT_NO_THROW(ImageFactory::create(ImageType::jpeg, filePath)); EXPECT_NO_THROW(ImageFactory::create(ImageType::exv, filePath)); EXPECT_NO_THROW(ImageFactory::create(ImageType::pgf, filePath)); +#ifdef EXV_HAVE_LIBZ EXPECT_NO_THROW(ImageFactory::create(ImageType::png, filePath)); +#endif EXPECT_TRUE(fs::remove(filePath)); } @@ -116,9 +120,11 @@ TEST(TheImageFactory, loadInstancesDifferentImageTypes) { EXPECT_EQ(ImageType::tiff, ImageFactory::getType(imagePath)); EXPECT_NO_THROW(ImageFactory::open(imagePath, false)); +#ifdef EXV_HAVE_LIBZ imagePath = (testData / "exiv2-bug1074.png").string(); EXPECT_EQ(ImageType::png, ImageFactory::getType(imagePath)); EXPECT_NO_THROW(ImageFactory::open(imagePath, false)); +#endif imagePath = (testData / "BlueSquare.xmp").string(); EXPECT_EQ(ImageType::xmp, ImageFactory::getType(imagePath));