Fix the indent in the coverage.cmake file
[skip-ci]
This commit is contained in:
@@ -47,23 +47,23 @@
|
|||||||
#
|
#
|
||||||
# 3. Set compiler flags to turn off optimization and enable coverage:
|
# 3. Set compiler flags to turn off optimization and enable coverage:
|
||||||
# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
|
# SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
|
||||||
# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
|
# SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
|
||||||
#
|
#
|
||||||
# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
|
# 3. Use the function SETUP_TARGET_FOR_COVERAGE to create a custom make target
|
||||||
# which runs your test executable and produces a lcov code coverage report:
|
# which runs your test executable and produces a lcov code coverage report:
|
||||||
# Example:
|
# Example:
|
||||||
# SETUP_TARGET_FOR_COVERAGE(
|
# SETUP_TARGET_FOR_COVERAGE(
|
||||||
# my_coverage_target # Name for custom target.
|
# my_coverage_target # Name for custom target.
|
||||||
# test_driver # Name of the test driver executable that runs the tests.
|
# test_driver # Name of the test driver executable that runs the tests.
|
||||||
# # NOTE! This should always have a ZERO as exit code
|
# # NOTE! This should always have a ZERO as exit code
|
||||||
# # otherwise the coverage generation will not complete.
|
# # otherwise the coverage generation will not complete.
|
||||||
# coverage # Name of output directory.
|
# coverage # Name of output directory.
|
||||||
# )
|
# )
|
||||||
#
|
#
|
||||||
# 4. Build a Debug build:
|
# 4. Build a Debug build:
|
||||||
# cmake -DCMAKE_BUILD_TYPE=Debug ..
|
# cmake -DCMAKE_BUILD_TYPE=Debug ..
|
||||||
# make
|
# make
|
||||||
# make my_coverage_target
|
# make my_coverage_target
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
@@ -76,9 +76,9 @@ FIND_PROGRAM( GCOVR_PATH gcovr PATHS ${CMAKE_SOURCE_DIR}/tests)
|
|||||||
# Display an error when the target is called. If no error is found, this
|
# Display an error when the target is called. If no error is found, this
|
||||||
# function will be overridden by the real one later in this file
|
# function will be overridden by the real one later in this file
|
||||||
FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
|
FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
|
||||||
ADD_CUSTOM_TARGET(${_targetname}
|
ADD_CUSTOM_TARGET(${_targetname}
|
||||||
COMMAND echo "Coverage is not available: ${ERROR_MSG}"
|
COMMAND echo "Coverage is not available: ${ERROR_MSG}"
|
||||||
)
|
)
|
||||||
ENDFUNCTION()
|
ENDFUNCTION()
|
||||||
|
|
||||||
IF(NOT GCOV_PATH)
|
IF(NOT GCOV_PATH)
|
||||||
@@ -130,50 +130,50 @@ 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.
|
||||||
# MUST return ZERO always, even on errors.
|
# MUST return ZERO always, even on errors.
|
||||||
# If not, no coverage report will be created!
|
# If not, no coverage report will be created!
|
||||||
# Param _outputname lcov output is generated as _outputname.info
|
# Param _outputname lcov output is generated as _outputname.info
|
||||||
# HTML report is generated in _outputname/index.html
|
# HTML report is generated in _outputname/index.html
|
||||||
# Optional fifth parameter is passed as arguments to _testrunner
|
# Optional fifth parameter is passed as arguments to _testrunner
|
||||||
# Pass them in list form, e.g.: "-j;2" for -j 2
|
# Pass them in list form, e.g.: "-j;2" for -j 2
|
||||||
FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
|
FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
|
||||||
|
|
||||||
# Setup target
|
# Setup target
|
||||||
ADD_CUSTOM_TARGET(${_targetname}
|
ADD_CUSTOM_TARGET(${_targetname}
|
||||||
|
|
||||||
# Cleanup lcov
|
# Cleanup lcov
|
||||||
COMMAND ${LCOV_PATH} --directory . --zerocounters
|
COMMAND ${LCOV_PATH} --directory . --zerocounters
|
||||||
|
|
||||||
# Create baseline coverage data file
|
# Create baseline coverage data file
|
||||||
COMMAND ${LCOV_PATH} -c -i -d . -o ${_outputname}.baseline.info -q
|
COMMAND ${LCOV_PATH} -c -i -d . -o ${_outputname}.baseline.info -q
|
||||||
|
|
||||||
# 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 -q
|
COMMAND ${LCOV_PATH} --directory . --capture --output-file ${_outputname}.info -q
|
||||||
# Combine the baseline and the test data
|
# Combine the baseline and the test data
|
||||||
COMMAND ${LCOV_PATH} -a ${_outputname}.info -a ${_outputname}.baseline.info -o ${_outputname}.info -q
|
COMMAND ${LCOV_PATH} -a ${_outputname}.info -a ${_outputname}.baseline.info -o ${_outputname}.info -q
|
||||||
|
|
||||||
# Remove information about source files that are not part of
|
# Remove information about source files that are not part of
|
||||||
# the test (system file, external libraries, etc)
|
# the test (system file, external libraries, etc)
|
||||||
COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' 'external/*' 'build/*' --output-file ${_outputname}.info.cleaned -q
|
COMMAND ${LCOV_PATH} --remove ${_outputname}.info 'tests/*' '/usr/*' 'external/*' 'build/*' --output-file ${_outputname}.info.cleaned -q
|
||||||
|
|
||||||
# Generate the report
|
# Generate the report
|
||||||
COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned
|
COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned
|
||||||
|
|
||||||
# Clean the temporary files we created
|
# Clean the temporary files we created
|
||||||
COMMAND ${CMAKE_COMMAND} -E remove ${_outputname}.info ${_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."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Show info where to find the report
|
# Show info where to find the report
|
||||||
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
|
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
|
||||||
COMMAND ;
|
COMMAND ;
|
||||||
COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report."
|
COMMENT "Open ./${_outputname}/index.html in your browser to view the coverage report."
|
||||||
)
|
)
|
||||||
|
|
||||||
ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
|
ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
|
||||||
|
|
||||||
@@ -184,30 +184,30 @@ ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE
|
|||||||
# Pass them in list form, e.g.: "-j;2" for -j 2
|
# Pass them in list form, e.g.: "-j;2" for -j 2
|
||||||
FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname)
|
FUNCTION(SETUP_TARGET_FOR_COVERAGE_COBERTURA _targetname _testrunner _outputname)
|
||||||
|
|
||||||
IF(NOT PYTHON_EXECUTABLE)
|
IF(NOT PYTHON_EXECUTABLE)
|
||||||
MESSAGE(FATAL_ERROR "Python not found! Aborting...")
|
MESSAGE(FATAL_ERROR "Python not found! Aborting...")
|
||||||
ENDIF() # NOT PYTHON_EXECUTABLE
|
ENDIF() # NOT PYTHON_EXECUTABLE
|
||||||
|
|
||||||
IF(NOT GCOVR_PATH)
|
IF(NOT GCOVR_PATH)
|
||||||
MESSAGE(FATAL_ERROR "gcovr not found! Aborting...")
|
MESSAGE(FATAL_ERROR "gcovr not found! Aborting...")
|
||||||
ENDIF() # NOT GCOVR_PATH
|
ENDIF() # NOT GCOVR_PATH
|
||||||
MARK_AS_ADVANCED(GCOVR_PATH)
|
MARK_AS_ADVANCED(GCOVR_PATH)
|
||||||
|
|
||||||
ADD_CUSTOM_TARGET(${_targetname}
|
ADD_CUSTOM_TARGET(${_targetname}
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
${_testrunner} ${ARGV3}
|
${_testrunner} ${ARGV3}
|
||||||
|
|
||||||
# Running gcovr
|
# Running gcovr
|
||||||
COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml
|
COMMAND ${GCOVR_PATH} -x -r ${CMAKE_SOURCE_DIR} -e '${CMAKE_SOURCE_DIR}/tests/' -o ${_outputname}.xml
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
COMMENT "Running gcovr to produce Cobertura code coverage report."
|
COMMENT "Running gcovr to produce Cobertura code coverage report."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Show info where to find the report
|
# Show info where to find the report
|
||||||
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
|
ADD_CUSTOM_COMMAND(TARGET ${_targetname} POST_BUILD
|
||||||
COMMAND ;
|
COMMAND ;
|
||||||
COMMENT "Cobertura code coverage report saved in ${_outputname}.xml."
|
COMMENT "Cobertura code coverage report saved in ${_outputname}.xml."
|
||||||
)
|
)
|
||||||
|
|
||||||
ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA
|
ENDFUNCTION() # SETUP_TARGET_FOR_COVERAGE_COBERTURA
|
||||||
|
|||||||
Reference in New Issue
Block a user