ci: enable coverage for Qt Tests

This commit is contained in:
sithlord48
2025-05-09 13:10:38 -04:00
committed by Nick Bolton
parent 81392fe758
commit 49173b11b9
2 changed files with 17 additions and 4 deletions

View File

@ -51,16 +51,20 @@ jobs:
run: |
build-wrapper-linux-x86-64 --out-dir bw-output cmake --build build -j${CPU_CORE_COUNT}
- name: Legacy tests coverage
- name: Test coverage
shell: bash
env:
QT_QPA_PLATFORM: offscreen
run: cmake --build build --target coverage-legacytests
run: |
tests=(`cmake --build build --target help | grep -o "^coverage-[^:]*"`)
for i in "${tests[@]}"; do
cmake --build build --target "$i"
done
- name: Get coverage report paths
id: coverage-paths
run: |
legacytests=$(find build -name coverage-legacytests.xml)
paths="${legacytests}"
paths=$(ls -w 0 -m build/coverage-*.xml | sed 's/ //g')
if [ -z "$paths" ]; then
echo "Error: No coverage files found"
exit 1

View File

@ -39,6 +39,15 @@ function(create_test)
set_tests_properties(${m_NAME} PROPERTIES DEPENDS ${m_DEPENDS})
set_property(GLOBAL APPEND PROPERTY ${CMAKE_PROJECT_NAME}_tests ${m_NAME})
if(ENABLE_COVERAGE)
setup_target_for_coverage_gcovr_xml(
NAME coverage-${m_NAME}
EXECUTABLE ${m_NAME}
BASE_DIRECTORY ${CMAKE_SOURCE_DIR}/src
EXCLUDE subprojects/* ${CMAKE_BINARY_DIR}/* src/unittest/*
)
endif()
endfunction()
enable_testing()