Problem: Coverage with coveralls not working

Solution: Enable coveralls for one linux build target and fix coveralls
configuration.
This commit is contained in:
Pawel Kurdybacha 2018-06-02 17:25:37 +01:00
parent 3c14d37d8b
commit 9a7a85703c
3 changed files with 28 additions and 13 deletions

View File

@ -23,6 +23,21 @@ matrix:
# GCC on Linux # GCC on Linux
########################################################## ##########################################################
# Coverage, GCC 7, draft enabled, latest libzmq (default)
- os: linux
before_install:
- pip install --user cpp-coveralls
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" ENABLE_DRAFTS=ON COVERAGE=ON
after_success:
- coveralls -r . -E ".*external.*" -E ".*CMakeFiles.*" -E ".*tests/" -E ".*demo/" -E ".*libzmq.*/" -b cppzmq-build --gcov-options '\-lp'
# GCC default, draft disabled, older libzmq with pkg-config # GCC default, draft disabled, older libzmq with pkg-config
- os: linux - os: linux
env: ZMQ_VERSION=4.2.0 BUILD_TYPE=pkgconfig env: ZMQ_VERSION=4.2.0 BUILD_TYPE=pkgconfig
@ -51,6 +66,7 @@ matrix:
- g++-7 - g++-7
env: env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" ENABLE_DRAFTS=ON - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7" ENABLE_DRAFTS=ON
# - env: BUILD_TYPE=cmake DO_CLANG_FORMAT_CHECK=1 CLANG_FORMAT=/usr/local/clang-5.0.0/bin/clang-format # - env: BUILD_TYPE=cmake DO_CLANG_FORMAT_CHECK=1 CLANG_FORMAT=/usr/local/clang-5.0.0/bin/clang-format
# os: linux # os: linux
# addons: # addons:
@ -60,14 +76,9 @@ matrix:
# packages: # packages:
# - clang-5.0 # - clang-5.0
before_install:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then pip install --user cpp-coveralls; fi
# Build and check this project # Build and check this project
script: script:
- eval "${MATRIX_EVAL}" - eval "${MATRIX_EVAL}"
- cmake --version - cmake --version
- ./ci_build.sh - ./ci_build.sh
after_success:
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then coveralls --root . -E ".*external.*" -E ".*CMakeFiles.*" -E ".*tests/" -E ".*demo/" -E ".*libzmq/"; fi

View File

@ -6,6 +6,7 @@ set -e
BUILD_TYPE=${BUILD_TYPE:-cmake} BUILD_TYPE=${BUILD_TYPE:-cmake}
ZMQ_VERSION=${ZMQ_VERSION:-4.2.5} ZMQ_VERSION=${ZMQ_VERSION:-4.2.5}
ENABLE_DRAFTS=${ENABLE_DRAFTS:-OFF} ENABLE_DRAFTS=${ENABLE_DRAFTS:-OFF}
COVERAGE=${COVERAGE:-OFF}
LIBZMQ=${PWD}/libzmq-build LIBZMQ=${PWD}/libzmq-build
CPPZMQ=${PWD}/cppzmq-build CPPZMQ=${PWD}/cppzmq-build
# Travis machines have 2 cores # Travis machines have 2 cores
@ -37,7 +38,8 @@ libzmq_install() {
cppzmq_build() { cppzmq_build() {
pushd . pushd .
CMAKE_PREFIX_PATH=${LIBZMQ} \ CMAKE_PREFIX_PATH=${LIBZMQ} \
cmake -H. -B${CPPZMQ} -DENABLE_DRAFTS=${ENABLE_DRAFTS} cmake -H. -B${CPPZMQ} -DENABLE_DRAFTS=${ENABLE_DRAFTS} \
-DCOVERAGE=${COVERAGE}
cmake --build ${CPPZMQ} -- -j${JOBS} cmake --build ${CPPZMQ} -- -j${JOBS}
popd popd
} }

View File

@ -9,11 +9,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
# we use this to get code coverage
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
include(cmake/googletest.cmake) include(cmake/googletest.cmake)
fetch_googletest( fetch_googletest(
${PROJECT_SOURCE_DIR}/cmake ${PROJECT_SOURCE_DIR}/cmake
@ -32,10 +27,17 @@ add_executable(
target_link_libraries( target_link_libraries(
unit_tests unit_tests
gtest_main PRIVATE gtest_main
cppzmq PRIVATE cppzmq
) )
OPTION (COVERAGE "Enable gcda file generation needed by lcov" OFF)
if (COVERAGE)
target_compile_options(unit_tests PRIVATE --coverage)
target_link_libraries(unit_tests PRIVATE --coverage)
endif()
add_test( add_test(
NAME NAME
unit unit