~singpolyma/biboumi

4860201d8c1429073e009945f42745269daa31a3 — louiz’ 6 years ago 3961df3
Add a make coverage target to merge all other coverages, and upload to codecov
3 files changed, 20 insertions(+), 13 deletions(-)

M .gitlab-ci.yml
M CMakeLists.txt
M cmake/Modules/CodeCoverage.cmake
M .gitlab-ci.yml => .gitlab-ci.yml +5 -7
@@ 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


M CMakeLists.txt => CMakeLists.txt +13 -4
@@ 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()

#

M cmake/Modules/CodeCoverage.cmake => cmake/Modules/CodeCoverage.cmake +2 -2
@@ 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."