From 97e45ea14dec16c2ba4803ffc5eb4fdbda7be585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 26 Feb 2022 20:57:53 +0100 Subject: [PATCH] Adapt tests to changes in Utility::Directory error reporting. Now comparing just the message coming out of our code, ignoring the system-specific message Directory prints. --- .../Test/AbstractConverterTest.cpp | 37 +++++----- .../Text/Test/AbstractFontConverterTest.cpp | 14 ++-- .../Trade/Test/AbstractImageConverterTest.cpp | 73 ++++++++++--------- .../Trade/Test/AbstractSceneConverterTest.cpp | 7 +- 4 files changed, 68 insertions(+), 63 deletions(-) diff --git a/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp b/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp index c20c80ff4..f7438cbc1 100644 --- a/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp +++ b/src/Magnum/ShaderTools/Test/AbstractConverterTest.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -1072,9 +1073,9 @@ void AbstractConverterTest::convertDataToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertDataToFile({}, nullptr, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "ShaderTools::AbstractConverter::convertDataToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "ShaderTools::AbstractConverter::convertDataToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractConverterTest::convertDataToFileNotSupported() { @@ -1228,9 +1229,9 @@ void AbstractConverterTest::convertFileToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertFileToFile({}, Utility::Directory::join(SHADERTOOLS_TEST_DIR, "file.dat"), "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "ShaderTools::AbstractConverter::convertFileToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "ShaderTools::AbstractConverter::convertFileToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractConverterTest::convertFileToFileNotSupported() { @@ -1596,9 +1597,9 @@ void AbstractConverterTest::linkDataToFileThroughDataNotWritable() { Error redirectError{&out}; /* {{}} makes GCC 4.8 warn about zero as null pointer constant */ CORRADE_VERIFY(!converter.linkDataToFile({std::pair>{}}, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "ShaderTools::AbstractConverter::linkDataToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "ShaderTools::AbstractConverter::linkDataToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractConverterTest::linkDataToFileNotSupported() { @@ -1816,9 +1817,9 @@ void AbstractConverterTest::linkFilesToFileThroughDataNotWritable() { CORRADE_VERIFY(!converter.linkFilesToFile({ {{}, Utility::Directory::join(SHADERTOOLS_TEST_DIR, "file.dat")} }, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "ShaderTools::AbstractConverter::linkFilesToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "ShaderTools::AbstractConverter::linkFilesToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractConverterTest::linkFilesToFileNotSupported() { @@ -2633,9 +2634,9 @@ void AbstractConverterTest::setInputFileCallbackConvertFileToFileAsDataNotWritab CORRADE_VERIFY(!converter.convertFileToFile({}, "file.dat", "/some/path/that/does/not/exist")); CORRADE_VERIFY(state.loaded); CORRADE_VERIFY(state.closed); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "ShaderTools::AbstractConverter::convertFileToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "ShaderTools::AbstractConverter::convertFileToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractConverterTest::setInputFileCallbackConvertFileToDataDirectly() { @@ -3147,9 +3148,9 @@ void AbstractConverterTest::setInputFileCallbackLinkFilesToFileAsDataNotWritable "loaded file.dat\n" "closed another.dat\n" "closed file.dat\n"); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "ShaderTools::AbstractConverter::linkFilesToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "ShaderTools::AbstractConverter::linkFilesToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractConverterTest::setInputFileCallbackLinkFilesToDataDirectly() { diff --git a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp index c999f9692..ded762b5f 100644 --- a/src/Magnum/Text/Test/AbstractFontConverterTest.cpp +++ b/src/Magnum/Text/Test/AbstractFontConverterTest.cpp @@ -25,9 +25,11 @@ #include #include +#include #include #include #include +#include #include #include @@ -491,9 +493,9 @@ void AbstractFontConverterTest::exportFontToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.exportFontToFile(dummyFont, dummyGlyphCache, "/some/path/that/does/not/exist", {})); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Text::AbstractFontConverter::exportFontToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Text::AbstractFontConverter::exportFontToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractFontConverterTest::exportGlyphCacheToSingleData() { @@ -789,9 +791,9 @@ void AbstractFontConverterTest::exportGlyphCacheToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.exportGlyphCacheToFile(dummyGlyphCache, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Text::AbstractFontConverter::exportGlyphCacheToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Text::AbstractFontConverter::exportGlyphCacheToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractFontConverterTest::importGlyphCacheFromSingleData() { diff --git a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp index cdcb7589b..f74be49e1 100644 --- a/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractImageConverterTest.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -2290,9 +2291,9 @@ void AbstractImageConverterTest::convert1DToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView1D{PixelFormat::RGBA8Unorm, 1, data}, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convert2DToFileThroughDataNotWritable() { @@ -2308,9 +2309,9 @@ void AbstractImageConverterTest::convert2DToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convert3DToFileThroughDataNotWritable() { @@ -2326,9 +2327,9 @@ void AbstractImageConverterTest::convert3DToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convert1DToFileInvalidImage() { @@ -2635,9 +2636,9 @@ void AbstractImageConverterTest::convertCompressed1DToFileThroughDataNotWritable std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}, "/some/path/that/does/not/exist"); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressed2DToFileThroughDataNotWritable() { @@ -2653,9 +2654,9 @@ void AbstractImageConverterTest::convertCompressed2DToFileThroughDataNotWritable std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}, "/some/path/that/does/not/exist"); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressed3DToFileThroughDataNotWritable() { @@ -2671,9 +2672,9 @@ void AbstractImageConverterTest::convertCompressed3DToFileThroughDataNotWritable std::ostringstream out; Error redirectError{&out}; converter.convertToFile(CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}, "/some/path/that/does/not/exist"); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressed1DToFileInvalidImage() { @@ -3049,9 +3050,9 @@ void AbstractImageConverterTest::convertLevels1DToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView1D{PixelFormat::RGBA8Unorm, 1, data}}, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertLevels2DToFileThroughDataNotWritable() { @@ -3067,9 +3068,9 @@ void AbstractImageConverterTest::convertLevels2DToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView2D{PixelFormat::RGBA8Unorm, {1, 1}, data}}, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertLevels3DToFileThroughDataNotWritable() { @@ -3085,9 +3086,9 @@ void AbstractImageConverterTest::convertLevels3DToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile({ImageView3D{PixelFormat::RGBA8Unorm, {1, 1, 1}, data}}, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertLevels1DToFileInvalidImage() { @@ -3418,9 +3419,9 @@ void AbstractImageConverterTest::convertCompressedLevels1DToFileThroughDataNotWr std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView1D{CompressedPixelFormat::Bc1RGBAUnorm, 4, data}}, "/some/path/that/does/not/exist"); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressedLevels2DToFileThroughDataNotWritable() { @@ -3436,9 +3437,9 @@ void AbstractImageConverterTest::convertCompressedLevels2DToFileThroughDataNotWr std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView2D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4}, data}}, "/some/path/that/does/not/exist"); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressedLevels3DToFileThroughDataNotWritable() { @@ -3454,9 +3455,9 @@ void AbstractImageConverterTest::convertCompressedLevels3DToFileThroughDataNotWr std::ostringstream out; Error redirectError{&out}; converter.convertToFile({CompressedImageView3D{CompressedPixelFormat::Bc1RGBAUnorm, {4, 4, 1}, data}}, "/some/path/that/does/not/exist"); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractImageConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractImageConverterTest::convertCompressedLevels1DToFileInvalidImage() { diff --git a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp index 62a838227..96866b479 100644 --- a/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp +++ b/src/Magnum/Trade/Test/AbstractSceneConverterTest.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -517,9 +518,9 @@ void AbstractSceneConverterTest::convertMeshToFileThroughDataNotWritable() { std::ostringstream out; Error redirectError{&out}; CORRADE_VERIFY(!converter.convertToFile(MeshData{MeshPrimitive::Triangles, 0xef}, "/some/path/that/does/not/exist")); - CORRADE_COMPARE(out.str(), - "Utility::Directory::write(): can't open /some/path/that/does/not/exist\n" - "Trade::AbstractSceneConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n"); + CORRADE_COMPARE_AS(out.str(), + "Trade::AbstractSceneConverter::convertToFile(): cannot write to file /some/path/that/does/not/exist\n", + TestSuite::Compare::StringHasSuffix); } void AbstractSceneConverterTest::convertMeshToFileNotImplemented() {