Skip to content

Commit

Permalink
Add code coverage ignore file (#279)
Browse files Browse the repository at this point in the history
Signed-off-by: youhy <haoyuan2019@outlook.com>
Signed-off-by: Jenn Nguyen <jenn@openrobotics.org>

Co-authored-by: Jenn Nguyen <jenn@openrobotics.org>
  • Loading branch information
AzulRadio and jennuine authored Jul 25, 2022
1 parent d2f67a6 commit c876ec4
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmake/IgnCodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ FUNCTION(ign_setup_target_for_coverage)
MESSAGE(FATAL_ERROR "genhtml not found! Aborting...")
ENDIF() # NOT GENHTML_PATH

# Read ignore file list
if (EXISTS "${PROJECT_SOURCE_DIR}/coverage.ignore.in")
configure_file("${PROJECT_SOURCE_DIR}/coverage.ignore.in"
${PROJECT_BINARY_DIR}/coverage.ignore)
file (STRINGS "${PROJECT_BINARY_DIR}/coverage.ignore" IGNORE_LIST_RAW)
string(REGEX REPLACE "([^;]+)" "'${PROJECT_SOURCE_DIR}/\\1'" IGNORE_LIST "${IGNORE_LIST_RAW}")
message(STATUS "Ignore coverage additions: " ${IGNORE_LIST})
else()
set(IGNORE_LIST "")
endif()

# Setup target
ADD_CUSTOM_TARGET(${_targetname}

Expand All @@ -132,8 +143,8 @@ FUNCTION(ign_setup_target_for_coverage)
# Remove negative counts
COMMAND sed -i '/,-/d' ${_outputname}.info
COMMAND ${LCOV_PATH} ${_branch_flags} -q
--remove ${_outputname}.info '*/test/*' '/usr/*' '*_TEST*' '*.cxx' 'moc_*.cpp' 'qrc_*.cpp' '*.pb.*' --output-file ${_outputname}.info.cleaned
COMMAND ${GENHTML_PATH} ${_branch_flags} -q
--remove ${_outputname}.info '*/test/*' '/usr/*' '*_TEST*' '*.cxx' 'moc_*.cpp' 'qrc_*.cpp' '*.pb.*' '*/build/*' '*/install/*' ${IGNORE_LIST} --output-file ${_outputname}.info.cleaned
COMMAND ${GENHTML_PATH} ${_branch_flags} -q --prefix ${PROJECT_SOURCE_DIR}
--legend -o ${_outputname} ${_outputname}.info.cleaned
COMMAND ${LCOV_PATH} --summary ${_outputname}.info.cleaned 2>&1 | grep "lines" | cut -d ' ' -f 4 | cut -d '%' -f 1 > ${_outputname}/lines.txt
COMMAND ${LCOV_PATH} --summary ${_outputname}.info.cleaned 2>&1 | grep "functions" | cut -d ' ' -f 4 | cut -d '%' -f 1 > ${_outputname}/functions.txt
Expand Down

0 comments on commit c876ec4

Please sign in to comment.