From 4860201d8c1429073e009945f42745269daa31a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?louiz=E2=80=99?= Date: Sat, 10 Dec 2016 19:03:11 +0100 Subject: [PATCH] Add a make coverage target to merge all other coverages, and upload to codecov --- .gitlab-ci.yml | 12 +++++------- CMakeLists.txt | 17 +++++++++++++---- cmake/Modules/CodeCoverage.cmake | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f270477..7ac6f27 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -89,21 +89,19 @@ build:rpm: script: - cmake .. -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${BOTAN} ${CARES} ${SYSTEMD} ${LIBIDN} ${LITESQL} - make biboumi -j$(nproc || echo 1) - - make check + - make coverage_check -j$(nproc || echo 1) + - make coverage_e2e -j$(nproc || echo 1) - make coverage - - mkdir tests_outputs && pushd tests_outputs && make coverage_e2e -j$(nproc || echo 1) -C .. && popd - - if [ ! -z $COVERALLS_TOKEN -a ! -z $UPLOAD_TO_COVERALLS ]; then coveralls-lcov --repo-token $COVERALLS_TOKEN coverage_e2e.info.cleaned; fi + - bash <(curl -s https://codecov.io/bash) artifacts: paths: - - build/coverage/ + - build/coverage_test_suite/ - build/coverage_e2e/ - - build/tests_outputs/ + - build/coverage_total/ when: always name: $CI_PROJECT_NAME-test-$CI_BUILD_ID test:debian: - variables: - UPLOAD_TO_COVERALLS: "true" image: biboumi-test-debian:latest <<: *basic_test diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a3c3e6..f25a6ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -241,14 +241,23 @@ add_custom_target(e2e_valgrind COMMAND "E2E_BIBOUMI_SUPP_DIR=${CMAKE_CURRENT_SOU # if(CMAKE_BUILD_TYPE MATCHES Debug) include(CodeCoverage) - SETUP_TARGET_FOR_COVERAGE(coverage - test_suite - coverage - ) + SETUP_TARGET_FOR_COVERAGE(coverage_check + make + coverage_test_suite + check) SETUP_TARGET_FOR_COVERAGE(coverage_e2e make coverage_e2e e2e) + + ADD_CUSTOM_TARGET(coverage + COMMAND ${LCOV_PATH} -a coverage_e2e.info -a coverage_test_suite.info -o coverage_total.info + + COMMAND ${GENHTML_PATH} -o coverage_total coverage_total.info + + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + endif() # diff --git a/cmake/Modules/CodeCoverage.cmake b/cmake/Modules/CodeCoverage.cmake index 20f2110..77586ab 100644 --- a/cmake/Modules/CodeCoverage.cmake +++ b/cmake/Modules/CodeCoverage.cmake @@ -157,10 +157,10 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname) # Remove information about source files that are not part of # 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 -q # Generate the report - COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info.cleaned + COMMAND ${GENHTML_PATH} -o ${_outputname} ${_outputname}.info WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." -- 2.45.2