diff --git a/.travis.yml b/.travis.yml index d5fbc33..b9f7c27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,6 +23,21 @@ matrix: # 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 - os: linux env: ZMQ_VERSION=4.2.0 BUILD_TYPE=pkgconfig @@ -51,6 +66,7 @@ matrix: - g++-7 env: - 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 # os: linux # addons: @@ -60,14 +76,9 @@ matrix: # packages: # - clang-5.0 -before_install: - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then pip install --user cpp-coveralls; fi - # Build and check this project script: - eval "${MATRIX_EVAL}" - cmake --version - ./ci_build.sh -after_success: - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then coveralls --root . -E ".*external.*" -E ".*CMakeFiles.*" -E ".*tests/" -E ".*demo/" -E ".*libzmq/"; fi diff --git a/ci_build.sh b/ci_build.sh index aac0332..c900f57 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -6,6 +6,7 @@ set -e BUILD_TYPE=${BUILD_TYPE:-cmake} ZMQ_VERSION=${ZMQ_VERSION:-4.2.5} ENABLE_DRAFTS=${ENABLE_DRAFTS:-OFF} +COVERAGE=${COVERAGE:-OFF} LIBZMQ=${PWD}/libzmq-build CPPZMQ=${PWD}/cppzmq-build # Travis machines have 2 cores @@ -37,7 +38,8 @@ libzmq_install() { cppzmq_build() { pushd . 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} popd } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f75f2e8..57da555 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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_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) fetch_googletest( ${PROJECT_SOURCE_DIR}/cmake @@ -32,10 +27,17 @@ add_executable( target_link_libraries( unit_tests - gtest_main - cppzmq + PRIVATE gtest_main + 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( NAME unit