From 50501a41e2acb255e7f63a3d11d391c9f1c17d1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Tue, 21 Jun 2016 07:07:10 +0200 Subject: [PATCH] Fix test coverage by using gcov '-lp' options NOTE: it would be good to also be able to keep unused inline functions, but there is a problem between gcc 4.8 and -fkeep-inline-functions --- .travis.yml | 8 ++++---- CMakeLists.txt | 23 +++++++++++++++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 93e55d6..06c0c92 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,7 @@ addons: - cppcheck before_install: - - pip install --user cpp-coveralls + - if [[ "$CXX" == "g++" ]]; then pip install --user cpp-coveralls ; fi # scripts to run before build before_script: @@ -28,8 +28,8 @@ before_script: # build examples, and run tests (ie make & make test) script: - cmake --build . - - ctest --output-on-failure + - ctest --verbose --output-on-failure -# publish GCov coveralls results +# generate and publish GCov coveralls results after_success: - - if [[ "$CXX" == "g++" ]]; then coveralls --root .. -e examples -e googletest -e sqlite3 -e tests -E ".*feature_tests.*" -E ".*CompilerId.*" ; fi + - if [[ "$CXX" == "g++" ]]; then coveralls --root .. -e examples -e googletest -e sqlite3 -e tests -E ".*feature_tests.*" -E ".*CompilerId.*" --gcov-options '\-lp' ; fi diff --git a/CMakeLists.txt b/CMakeLists.txt index e4f05ad..67b2a83 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,8 +38,8 @@ else (MSVC) else () message (WARNING "GCov instrumentation works best in Debug mode") endif () - add_compile_options (-fprofile-arcs -ftest-coverage) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") + add_compile_options (-coverage) # NOTE would be usefull but not working with current google test and gcc 4.8 -fkeep-inline-functions + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -coverage") endif () endif (CMAKE_COMPILER_IS_GNUCXX) endif (MSVC) @@ -47,6 +47,25 @@ endif (MSVC) set(CPPLINT_ARG_VERBOSE "--verbose=3") set(CPPLINT_ARG_LINELENGTH "--linelength=120") +# Print CXX FLAGS +message (STATUS "CMAKE_CXX_FLAGS '${CMAKE_CXX_FLAGS}'") +if (MSVC) + message (STATUS "CMAKE_CXX_FLAGS_DEBUG '${CMAKE_CXX_FLAGS_DEBUG}'") + message (STATUS "CMAKE_CXX_FLAGS_RELEASE '${CMAKE_CXX_FLAGS_RELEASE}'") + message (STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO '${CMAKE_CXX_FLAGS_RELWITHDEBINFO}'") + message (STATUS "CMAKE_CXX_FLAGS_MINSIZEREL '${CMAKE_CXX_FLAGS_MINSIZEREL}'") +else (NOT MSVC) + if (CMAKE_BUILD_TYPE STREQUAL Debug) + message (STATUS "CMAKE_CXX_FLAGS_DEBUG '${CMAKE_CXX_FLAGS_DEBUG}'") + elseif (CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo) + message (STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO '${CMAKE_CXX_FLAGS_RELWITHDEBINFO}'") + elseif (CMAKE_BUILD_TYPE STREQUAL MinSizeRel) + message (STATUS "CMAKE_CXX_FLAGS_MINSIZEREL '${CMAKE_CXX_FLAGS_MINSIZEREL}'") + else () + message (STATUS "CMAKE_CXX_FLAGS_RELEASE '${CMAKE_CXX_FLAGS_RELEASE}'") + endif () +endif () + # Options relative to SQLite and SQLiteC++ functions