Skip to content

Commit

Permalink
update for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp committed Jan 12, 2025
1 parent ca024ca commit 85fc0e9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Prepare coverage
run: |
lcov --ignore-errors mismatch --directory . --capture --output-file coverage.info
lcov --ignore-errors gcov,mismatch --directory . --capture --output-file coverage.info
lcov --remove coverage.info '*/test/*' '*/examples/*' '*gtest*' '*gmock*' '/usr/*' '*/converter/*' '*/FuzzTargets/*' '*/webserver/*' --output-file coverage.info
lcov --list coverage.info
working-directory: build
Expand Down
25 changes: 21 additions & 4 deletions ThirdParty/cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
# - Added the option for users to set the GCOVR_ADDITIONAL_ARGS variable to supply additional
# flags to the gcovr command
#
# 2020-05-04, Mihchael Davis
# 2020-05-04, Michael Davis
# - Add -fprofile-abs-path to make gcno files contain absolute paths
# - Fix BASE_DIRECTORY not working when defined
# - Change BYPRODUCT from folder to index.html to stop ninja from complaining about double defines
Expand Down Expand Up @@ -270,6 +270,8 @@ function(setup_target_for_coverage_lcov)
${Coverage_LCOV_ARGS}
--gcov-tool
${GCOV_PATH}
--ignore-errors
mismatch
-directory
.
-b
Expand All @@ -281,6 +283,8 @@ function(setup_target_for_coverage_lcov)
${Coverage_LCOV_ARGS}
--gcov-tool
${GCOV_PATH}
--ignore-errors
mismatch
-c
-i
-d
Expand All @@ -302,6 +306,8 @@ function(setup_target_for_coverage_lcov)
-b
${BASEDIR}
--capture
--ignore-errors
mismatch,gcov
--output-file
${Coverage_NAME}.capture)
# add baseline counters
Expand All @@ -314,6 +320,8 @@ function(setup_target_for_coverage_lcov)
${Coverage_NAME}.base
-a
${Coverage_NAME}.capture
--ignore-errors
mismatch,gcov
--output-file
${Coverage_NAME}.total)
# filter collected data to final coverage report
Expand All @@ -322,14 +330,23 @@ function(setup_target_for_coverage_lcov)
${Coverage_LCOV_ARGS}
--gcov-tool
${GCOV_PATH}
--ignore-errors
mismatch,mismatch,gcov
--remove
${Coverage_NAME}.total
${LCOV_EXCLUDES}
--output-file
${Coverage_NAME}.info)
# Generate HTML output
set(LCOV_GEN_HTML_CMD ${GENHTML_PATH} ${GENHTML_EXTRA_ARGS} ${Coverage_GENHTML_ARGS} -o
${Coverage_NAME} ${Coverage_NAME}.info)
set(LCOV_GEN_HTML_CMD
${GENHTML_PATH}
${GENHTML_EXTRA_ARGS}
--ignore-errors
mismatch,mismatch
${Coverage_GENHTML_ARGS}
-o
${Coverage_NAME}
${Coverage_NAME}.info)
if(${Coverage_SONARQUBE})
# Generate SonarQube output
set(GCOVR_XML_CMD
Expand All @@ -347,7 +364,7 @@ function(setup_target_for_coverage_lcov)
COMMENT "SonarQube code coverage info report saved in ${Coverage_NAME}_sonarqube.xml.")
endif()

if(CODE_COVERAGE_VERBOSE)
if(CODE_COVERAGE_VERBOSE OR 1)
message(STATUS "Executed command report")
message(STATUS "Command to clean up lcov: ")
string(REPLACE ";" " " LCOV_CLEAN_CMD_SPACED "${LCOV_CLEAN_CMD}")
Expand Down

0 comments on commit 85fc0e9

Please sign in to comment.