我已经在我的本地机器上设置了 CDash,我正在使用 CTest 将测试结果上传到 CDash - 生成包含分支覆盖信息的 .gcov 文件并将它们预先打包到 gcov.tar (这是来自https的示例的修改版本://blog.kitware.com/additional-coverage-features-in-cdash/):
CMakeLists.txt:
cmake_minimum_required(VERSION 3.2)
project(branch_coverage_example)
add_executable(foo foo.cxx)
include(CTest)
add_test(NAME foo COMMAND foo)
include(BranchCoverage)
Run Code Online (Sandbox Code Playgroud)
我的 CMake 模块路径中的BranchCoverage.cmake:
if(${CMAKE_BUILD_TYPE} STREQUAL "Profiling")
option(ALWAYS_GENERATE_BRANCH_COVERAGE_INFO "Run gcov branch coverage as part of the ALL target" ON)
if(ALWAYS_GENERATE_BRANCH_COVERAGE_INFO)
add_custom_target(BranchCoverage)
add_custom_command(TARGET BranchCoverage
POST_BUILD
COMMAND ${CMAKE_CTEST_COMMAND} -D ExperimentalSubmit -S cdash_tarball.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating gcov.tar containing branch coverage info..."
)
add_dependencies(BranchCoverage Experimental)
endif()
endif()
Run Code Online (Sandbox Code Playgroud)
CTestConfig.cmake:
## This file should be placed in …Run Code Online (Sandbox Code Playgroud)