summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2024-03-06 19:37:37 +0100
committerDominik Holland <dominik.holland@qt.io>2024-03-07 10:27:23 +0000
commitc368a75ff45deca89c48bbb2c0cc87c500878dce (patch)
treecb34f01fd35a32f384c08adc411acc3f32c209e3
parent42512ac9699d3a2e7a102e54b55415e43be59625 (diff)
Improve the code-coverage setup
Instead of making a standalone_test build and referencing the build folder from there, we do the test build together with the module build and run it like on a developer machine. This makes the whole report more reliable and fixes some areas which were marked as not tested at all. Pick-to: 6.7 Change-Id: Ia24c883af55970e0aee27af9a95cda79da1caca7 Reviewed-by: Robert Griebl <robert.griebl@qt.io>
-rw-r--r--CMakeLists.txt17
-rw-r--r--coin/instructions/cmake_module_lcov_code_coverage.yaml4
-rw-r--r--coin/module_config.yaml11
3 files changed, 10 insertions, 22 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d1b49247..0f0cd5dc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,7 +44,7 @@ if(IF_COVERAGE)
set(GCOV_EXCLUDE
'/usr/*'
'${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/*'
- '${CMAKE_CURRENT_LIST_DIR}/tests/*'
+ #'${CMAKE_CURRENT_LIST_DIR}/tests/*'
'${CMAKE_CURRENT_LIST_DIR}/examples/*'
'${CMAKE_CURRENT_LIST_DIR}/src/3rdparty/*'
'moc_*'
@@ -52,12 +52,11 @@ if(IF_COVERAGE)
'${CMAKE_CURRENT_BINARY_DIR}/*'
)
- if(QT_BUILD_STANDALONE_TESTS)
- # Coin splits the build into two separate directories, so we need to merge the coverage info
- set(GCOV_EXTRA_FOLDER "../qtinterfaceframework_build")
- set(LCOV_EXTRA_ARGS -d ${GCOV_EXTRA_FOLDER})
- list(APPEND GCOV_EXCLUDE '/home/qt/work/qt/qtinterfaceframework_build/*')
+ if(QT_SOURCE_TREE AND NOT DEFINED ENV{HOST_OS_COIN})
+ string(REGEX REPLACE "/qtbase$" "" qtSrcDir ${QT_SOURCE_TREE})
+ list(APPEND GCOV_EXCLUDE '${qtSrcDir}/*')
endif()
+
set(COVERAGE_DEPENDS all)
if(QT_WILL_INSTALL)
list(APPEND COVERAGE_DEPENDS tests/auto/install)
@@ -68,10 +67,10 @@ if(IF_COVERAGE)
COMMAND sh -c 'which genhtml >/dev/null || { echo "The genhtml tool is not available." && exit 2 \; }'
COMMAND sh -c 'lcov --version | grep -q "^lcov: LCOV version 2\." || { echo "The lcov tool must be version 2." && exit 2 \; }'
COMMAND find . \\\( -name \"*.gcov-info\" -o -name \"*.gcda\" \\\) -print0 | xargs -0 rm -f
- COMMAND lcov -keep-going -c -i -d . ${LCOV_EXTRA_ARGS} --rc branch_coverage=1 --rc geninfo_auto_base=1 -o "${CMAKE_CURRENT_BINARY_DIR}/base.gcov-info"
+ COMMAND lcov -keep-going -c -i -d . --rc branch_coverage=1 --rc geninfo_auto_base=1 -o "${CMAKE_CURRENT_BINARY_DIR}/base.gcov-info"
COMMAND ctest --test-dir tests/auto --verbose --repeat until-pass:3
- COMMAND lcov -keep-going -c -d . ${LCOV_EXTRA_ARGS} --rc branch_coverage=1 --rc geninfo_auto_base=1 -o "${CMAKE_CURRENT_BINARY_DIR}/test.gcov-info"
- COMMAND lcov -keep-going --rc branch_coverage=1 -o "${CMAKE_CURRENT_BINARY_DIR}/temp.gcov-info" `find . ${GCOV_EXTRA_FOLDER} -name \"*.gcov-info\" | xargs -n1 echo -a`
+ COMMAND lcov -keep-going -c -d . --rc branch_coverage=1 --rc geninfo_auto_base=1 -o "${CMAKE_CURRENT_BINARY_DIR}/test.gcov-info"
+ COMMAND lcov -keep-going --rc branch_coverage=1 -o "${CMAKE_CURRENT_BINARY_DIR}/temp.gcov-info" `find . -name \"*.gcov-info\" | xargs -n1 echo -a`
COMMAND lcov -keep-going --rc branch_coverage=1 -o "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.gcov-info" -r temp.gcov-info ${GCOV_EXCLUDE}
COMMAND rm -f base.gcov-info test.gcov-info temp.gcov-info
COMMAND genhtml -o coverage-report -s -f -t "${PROJECT_NAME}" --legend --branch-coverage --rc branch_coverage=1 --rc geninfo_unexecuted_blocks=1 --demangle-cpp "c++filt" ${PROJECT_NAME}.gcov-info
diff --git a/coin/instructions/cmake_module_lcov_code_coverage.yaml b/coin/instructions/cmake_module_lcov_code_coverage.yaml
index 15056ab9..72c2b0fa 100644
--- a/coin/instructions/cmake_module_lcov_code_coverage.yaml
+++ b/coin/instructions/cmake_module_lcov_code_coverage.yaml
@@ -2,7 +2,7 @@ type: Group
instructions:
- !include "{{qt/qtbase}}/coin_module_test_template_common.yaml"
- type: ChangeDirectory
- directory: "{{.SourceDir}}_standalone_tests"
+ directory: "{{.SourceDir}}_build"
- type: EnvironmentVariable
variableName: CMAKE_BUILD_TIMEOUT
variableValue: "6000"
@@ -39,4 +39,4 @@ instructions:
- type: ScheduleUploadTestResults
- type: EnvironmentVariable
variableName: COIN_CTEST_RESULTSDIR
- variableValue: "{{.SourceDir}}_standalone_tests/upload"
+ variableValue: "{{.SourceDir}}_build/upload"
diff --git a/coin/module_config.yaml b/coin/module_config.yaml
index 5c04c15e..86c30ee2 100644
--- a/coin/module_config.yaml
+++ b/coin/module_config.yaml
@@ -62,13 +62,6 @@ instructions:
condition: property
property: features
contains_value: lcov
- - type: AppendToEnvironmentVariable
- variableName: COMMON_TEST_CMAKE_ARGS
- variableValue: " -DIF_COVERAGE=ON"
- enable_if:
- condition: property
- property: features
- contains_value: lcov
- type: Group
instructions:
- !include "{{qt/qtbase}}/coin_module_build_template_v2.yaml"
@@ -85,7 +78,3 @@ instructions:
instructions:
- !include "{{qt/qtbase}}/coin_module_test_template_v3.yaml"
- !include "{{qt/qtbase}}/coin_module_test_docs.yaml"
- disable_if:
- condition: property
- property: features
- contains_value: lcov