Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: add output format for gcovr #90

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions cmake/test/Coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ if(NOT CODE_COVERAGE)
message(STATUS "Code coverage disabled by CODE_COVERAGE evaluates to false.")
endif()

set(CODE_COVERAGE_GCOVR_REPORT_FORMAT "lcov")

# Programs to generate coverage tools
find_program(LLVM_COV_PATH llvm-cov)
find_program(LLVM_PROFDATA_PATH llvm-profdata)
Expand Down Expand Up @@ -677,16 +679,24 @@ function(add_code_coverage_all_targets)
list(APPEND _exclude_command "${_rel}")
endforeach()

if(CODE_COVERAGE_GCOVR_REPORT_FORMAT MATCHES "lcov")
set(_gcovr_format_option "--lcov")
set(_gcovr_output_file "coverage.info")
else()
set(_gcovr_format_option "--xml-pretty")
set(_gcovr_output_file "coverage.xml")
endif()

# Generate the coverage report using gcovr
add_custom_target(
ccov-all-capture
COMMAND ${CMAKE_COMMAND} -E rm -f
${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/coverage.info
${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/${_gcovr_output_file}
COMMAND
${GCOVR_PATH} --print-summary -lcov --root ${CMAKE_SOURCE_DIR}
--exclude-noncode-lines --output
${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/coverage.info ${GCOV_OPTION}
${_include_command} ${_exclude_command}
${GCOVR_PATH} --print-summary ${_gcovr_format_option} --root
${CMAKE_SOURCE_DIR} --exclude-noncode-lines --output
${CMAKE_COVERAGE_OUTPUT_DIRECTORY}/${_gcovr_output_file}
${GCOV_OPTION} ${_include_command} ${_exclude_command}
DEPENDS ccov-all-processing)

# Generates HTML output of all targets for perusal
Expand Down
Loading