Skip to content

Commit

Permalink
Merge branch 'setup-coverall-and-travis' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbertKoelman committed Jun 8, 2019
2 parents b0abc83 + 7e8e7c0 commit 9c26b02
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ dist: xenial
language: cpp
compiler: gcc

# install things for coverall.io
before_install:
- pip install --user cpp-coveralls

# Run travis on these branches only...
branches:
only:
Expand All @@ -22,5 +26,11 @@ addons:

script:
- mkdir cmake-build
- cd cmake-build && cmake ..
- cd cmake-build && cmake -DGCOV=yes ..
- make all test

# create coveralls.io report
after_success:
- coveralls --root CMakeFiles/cpp-logger-static.dir/


10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ project(
VERSION 2.2.2
DESCRIPTION "Simple C++ logger (${GIT_LOG})")

option(GCOV "Activate GCOV options")
if (GCOV )
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
message(STATUS "Setting GCOV compiler options")
add_compile_options(--coverage)
else()
message(SEND_ERROR "The GCOV option is only supported when using GNU...")
endif()
endif()

#find_package(Git CONFIG)
#find_package(Conan)

Expand Down
16 changes: 10 additions & 6 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# Load and compile GTest
# Aliases: GTest::GTest, GTest::gtest_main, GMock::GMock

if (GCOV AND ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
set(GCOV_LIB gcov)
endif()

add_executable(logger_tests logger_tests.cpp)
target_link_libraries(logger_tests GTest::GTest cpp-logger-static GTest::gtest_main)
target_link_libraries(logger_tests GTest::GTest cpp-logger-static GTest::gtest_main ${GCOV_LIB})

add_executable(facility_tests facility_tests.cpp)
target_link_libraries(facility_tests GTest::GTest GMock::GMock cpp-logger-static GTest::gtest_main)
target_link_libraries(facility_tests GTest::GTest GMock::GMock cpp-logger-static GTest::gtest_main ${GCOV_LIB})

add_executable(exception_tests exception_tests.cpp)
target_link_libraries(exception_tests GTest::GTest GMock::GMock cpp-logger-static GTest::gtest_main)
target_link_libraries(exception_tests GTest::GTest GMock::GMock cpp-logger-static GTest::gtest_main ${GCOV_LIB})

add_executable(sink_tests sink_tests.cpp)
target_link_libraries(sink_tests GTest::GTest GMock::GMock cpp-logger-static GTest::gtest_main)
target_link_libraries(sink_tests GTest::GTest GMock::GMock cpp-logger-static GTest::gtest_main ${GCOV_LIB})

add_executable(logger_performance_tests logger_performance_tests.cpp)
target_link_libraries(logger_performance_tests GTest::GTest cpp-logger-static GTest::gtest_main)
target_link_libraries(logger_performance_tests GTest::GTest cpp-logger-static GTest::gtest_main ${GCOV_LIB})

add_test(NAME logger_tests COMMAND logger_tests)
add_test(NAME facility_tests COMMAND facility_tests)
add_test(NAME exception_tests COMMAND facility_tests)
add_test(NAME sink_tests COMMAND sink_tests)
add_test(NAME sink_tests COMMAND sink_tests)

0 comments on commit 9c26b02

Please sign in to comment.