coverage: 'lcov --remove' need full path

This commit is contained in:
yuangongji 2020-01-14 15:54:14 +08:00 committed by Azat Khuzhin
parent 2c473056ab
commit 1a99f9b25c

View File

@ -74,16 +74,11 @@ ENDIF() # NOT GCOV_PATH
IF(NOT CMAKE_COMPILER_IS_GNUCC) IF(NOT CMAKE_COMPILER_IS_GNUCC)
# Clang version 3.0.0 and greater now supports gcov as well. # Clang version 3.0.0 and greater now supports gcov as well.
MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.") MESSAGE(WARNING "Compiler is not GNU gcc! Clang Version 3.0.0 and greater supports gcov as well, but older versions don't.")
IF(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang" AND NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
IF(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...") MESSAGE(FATAL_ERROR "Compiler is not GNU gcc! Aborting...")
ENDIF() ENDIF()
ENDIF() # NOT CMAKE_COMPILER_IS_GNUCC ENDIF() # NOT CMAKE_COMPILER_IS_GNUCC
IF ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
MESSAGE( WARNING "Code coverage results with an optimized (non-Debug) build may be misleading" )
ENDIF() # NOT CMAKE_BUILD_TYPE STREQUAL "Debug"
# Param _targetname The name of new the custom make target # Param _targetname The name of new the custom make target
# Param _testrunner The name of the target which runs the tests. # Param _testrunner The name of the target which runs the tests.
@ -108,15 +103,15 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
# Cleanup lcov # Cleanup lcov
${LCOV_PATH} --directory . --zerocounters ${LCOV_PATH} --directory . --zerocounters
COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned
# Run tests # Run tests
COMMAND ${_testrunner} ${ARGV3} COMMAND ${_testrunner} ${ARGV3}
# Capturing lcov counters and generating report # Capturing lcov counters and generating report
COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info
COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' --output-file ${_outputname}.info.cleaned COMMAND ${LCOV_PATH} --remove ${_outputname}.info '*/test/*' '/usr/*' --output-file ${CMAKE_BINARY_DIR}/${_outputname}.info.cleaned
COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned
COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_outputname}.info.cleaned
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report."