From 372edc13bc63bc915709b3ef6ce9330796aee7dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 9 Jul 2025 21:50:10 +0200 Subject: [PATCH] package/ci: exclude GL and Vk sources from code coverage on Windows. I'm giving up there. Both Clang-cl and MinGW GCC report a far bigger set of lines than their Linux / Mac counterparts (block ends, lines containing just `else`, etc etc.), which wouldn't be a problem on its own, if those lines would be covered. But on Windows there isn't a single CI job that runs through GL/Vk codepaths -- as Mesa isn't easy to get there and SwiftShader is utter crap -- which means there are extra lines in GL/Vk codepaths that are reported as uncovered from Windows CI jobs, while the same lines on Linux and Mac arere excluded and thus there isn't anything that could make them green as well. --- package/ci/appveyor-desktop-mingw.bat | 11 ++++++++++- package/ci/appveyor-desktop.bat | 11 ++++++++++- src/Magnum/ImageView.cpp | 8 ++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/package/ci/appveyor-desktop-mingw.bat b/package/ci/appveyor-desktop-mingw.bat index ab892e3b8..7c8d8aa5a 100644 --- a/package/ci/appveyor-desktop-mingw.bat +++ b/package/ci/appveyor-desktop-mingw.bat @@ -85,7 +85,16 @@ rem rem Additionally, MinGW often reports empty lines containing just } as rem uncovered, possibly due to exception handling. Exclude them, and feel free rem to expand the regex to catch more cases if needed. -grcov build -t lcov --source-dir %APPVEYOR_BUILD_FOLDER%/build --keep-only "*/src/Magnum*/*" --ignore "*/src/MagnumExternal/*" --ignore "*/Test/*" --ignore "*/build/src/*" -o coverage.info --excl-line "(LCOV_EXCL_LINE|^\s*}$)" --excl-start LCOV_EXCL_START --excl-stop LCOV_EXCL_STOP || exit /b +rem +rem Also, partially due to the above, where, if a code isn't run through at +rem all, a lot more uncovered lines is reported compared to Linux / Mac, the +rem whole GL and Vk libraries as well as any GL- or Vk-specific files are +rem ignored for code coverage here. They're still built and tested where +rem possible without an actual GL/Vk driver, but the false negatives far +rem outweigh the benefits of having Windows-specific coverage reported for +rem those -- there isn't any Windows-specific code for most of them, after all +rem -- that it's not worth including them. +grcov build -t lcov --source-dir %APPVEYOR_BUILD_FOLDER%/build --keep-only "*/src/Magnum*/*" --ignore "*/src/MagnumExternal/*" --ignore "*/Test/*" --ignore "*/build/src/*" --ignore "*/src/Magnum/GL/*" --ignore "*/src/Magnum/Vk/*" --ignore "*/src/Magnum/Platform/*" --ignore "*GL.cpp" --ignore "*GL.h" --ignore "*Vk.cpp" --ignore "*Vk.h" -o coverage.info --excl-line "(LCOV_EXCL_LINE|^\s*}$)" --excl-start LCOV_EXCL_START --excl-stop LCOV_EXCL_STOP || exit /b rem Official docs say "not needed for public repos", in reality not using the rem token is "extremely flakey". What's best is that if the upload fails, the rem damn thing exits with a success error code, and nobody cares: diff --git a/package/ci/appveyor-desktop.bat b/package/ci/appveyor-desktop.bat index 29f42812d..2cc843ebe 100644 --- a/package/ci/appveyor-desktop.bat +++ b/package/ci/appveyor-desktop.bat @@ -93,7 +93,16 @@ rem rem Additionally, Clang-cl often reports empty lines containing just } as rem uncovered, possibly due to exception handling, similarly to MinGW. Exclude rem them, and feel free to expand the regex to catch more cases if needed. -if "%COMPILER%" == "msvc-clang" if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2022" grcov build -t lcov --keep-only "*/src/Magnum*/*" --ignore "*/src/MagnumExternal/*" --ignore "*/Test/*" --ignore "*/build/src/*" -o coverage.info --excl-line "(LCOV_EXCL_LINE|^\s*}$)" --excl-start LCOV_EXCL_START --excl-stop LCOV_EXCL_STOP || exit /b +rem +rem Also, partially due to the above, where, if a code isn't run through at +rem all, a lot more uncovered lines is reported compared to Linux / Mac, the +rem whole GL and Vk libraries as well as any GL- or Vk-specific files are +rem ignored for code coverage here. They're still built and tested where +rem possible without an actual GL/Vk driver, but the false negatives far +rem outweigh the benefits of having Windows-specific coverage reported for +rem those -- there isn't any Windows-specific code for most of them, after all +rem -- that it's not worth including them. +if "%COMPILER%" == "msvc-clang" if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2022" grcov build -t lcov --keep-only "*/src/Magnum*/*" --ignore "*/src/MagnumExternal/*" --ignore "*/Test/*" --ignore "*/build/src/*" --ignore "*/src/Magnum/GL/*" --ignore "*/src/Magnum/Vk/*" --ignore "*/src/Magnum/Platform/*" --ignore "*GL.cpp" --ignore "*GL.h" --ignore "*Vk.cpp" --ignore "*Vk.h" -o coverage.info --excl-line "(LCOV_EXCL_LINE|^\s*}$)" --excl-start LCOV_EXCL_START --excl-stop LCOV_EXCL_STOP || exit /b rem Official docs say "not needed for public repos", in reality not using the rem token is "extremely flakey". What's best is that if the upload fails, the rem damn thing exits with a success error code, and nobody cares: diff --git a/src/Magnum/ImageView.cpp b/src/Magnum/ImageView.cpp index 754146d05..f1306713f 100644 --- a/src/Magnum/ImageView.cpp +++ b/src/Magnum/ImageView.cpp @@ -35,7 +35,7 @@ template ImageView::ImageView(co template ImageView::ImageView(const PixelStorage storage, const UnsignedInt format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, const Containers::ArrayView data, const ImageFlags flags) noexcept: ImageView{storage, pixelFormatWrap(format), formatExtra, pixelSize, size, data, flags} {} -template ImageView::ImageView(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, const Containers::ArrayView data, const ImageFlags flags) noexcept: _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{UnsignedByte(pixelSize)}, _flags{flags}, _size{size}, _data{static_cast(data.data()), data.size()} { +template ImageView::ImageView(const PixelStorage storage, const PixelFormat format, const UnsignedInt formatExtra, const UnsignedInt pixelSize, const VectorTypeFor& size, const Containers::ArrayView data, const ImageFlags flags) noexcept: _storage{storage}, _format{format}, _formatExtra{formatExtra}, _pixelSize{UnsignedByte(pixelSize)}, _flags{flags}, _size{size}, _data{reinterpret_cast(data.data()), data.size()} { #ifndef CORRADE_NO_ASSERT Implementation::checkPixelSize("ImageView:", pixelSize); CORRADE_ASSERT(Implementation::imageDataSize(*this) <= _data.size(), "ImageView: data too small, got" << _data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); @@ -60,7 +60,7 @@ template std::pair void ImageView::setData(const Containers::ArrayView data) { CORRADE_ASSERT(Implementation::imageDataSize(*this) <= data.size(), "ImageView::setData(): data too small, got" << data.size() << "but expected at least" << Implementation::imageDataSize(*this) << "bytes", ); - _data = {static_cast(data.data()), data.size()}; + _data = {reinterpret_cast(data.data()), data.size()}; } template auto ImageView::pixels() const -> Containers::StridedArrayView { @@ -78,7 +78,7 @@ template CompressedImageView::Co compressedPixelFormatBlockDataSize(format) ), size, data, flags} {} -template CompressedImageView::CompressedImageView(const CompressedPixelStorage storage, const CompressedPixelFormat format, const Vector3i& blockSize, const UnsignedInt blockDataSize, const VectorTypeFor& size, const Containers::ArrayView data, const ImageFlags flags) noexcept: _storage{storage}, _format{format}, _flags{flags}, _blockSize{Vector3ub{blockSize}}, _blockDataSize{UnsignedByte(blockDataSize)}, _size{size}, _data{static_cast(data.data()), data.size()} { +template CompressedImageView::CompressedImageView(const CompressedPixelStorage storage, const CompressedPixelFormat format, const Vector3i& blockSize, const UnsignedInt blockDataSize, const VectorTypeFor& size, const Containers::ArrayView data, const ImageFlags flags) noexcept: _storage{storage}, _format{format}, _flags{flags}, _blockSize{Vector3ub{blockSize}}, _blockDataSize{UnsignedByte(blockDataSize)}, _size{size}, _data{reinterpret_cast(data.data()), data.size()} { #ifndef CORRADE_NO_ASSERT const bool passed = Implementation::checkBlockProperties("CompressedImageView:", blockSize, blockDataSize); @@ -125,7 +125,7 @@ template std::pair void CompressedImageView::setData(const Containers::ArrayView data) { CORRADE_ASSERT(Implementation::compressedImageDataSize(*this) <= data.size(), "CompressedImageView::setData(): data too small, got" << data.size() << "but expected at least" << Implementation::compressedImageDataSize(*this) << "bytes", ); - _data = {static_cast(data.data()), data.size()}; + _data = {reinterpret_cast(data.data()), data.size()}; } template class MAGNUM_EXPORT ImageView<1, const char>;