diff --git a/.travis.yml b/.travis.yml index 87d362c7b..d11b4b866 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,7 +87,8 @@ env: # ======================================================= # TC. g++-4.8 | DEBUG | CDASH - CMAKE_CXX_COMPILER=g++-4.8 - CMAKE_BUILD_TYPE=TESTCOV + CMAKE_BUILD_TYPE=Debug + TESTCOV=ON PUSH_TO_CDASH=TRUE TCMALLOC=OFF @@ -154,7 +155,7 @@ script: else /usr/bin/cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DTCMALLOC=${TCMALLOC} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -G Ninja ../src; fi - - if [[ $CMAKE_BUILD_TYPE == DEBUG || $CMAKE_BUILD_TYPE == RELEASE || $CMAKE_BUILD_TYPE == TESTCOV ]]; then + - if [[ $CMAKE_BUILD_TYPE == DEBUG || $CMAKE_BUILD_TYPE == RELEASE || $TESTCOV == ON ]]; then SITE=Ubuntu12.04@Travis; GIT_COMMIT=`git log --oneline -n 1 | cut -d ' ' -f 1`; if [[ $CMAKE_BUILD_TYPE == RELEASE ]]; then @@ -180,7 +181,7 @@ script: after_script: - cd build -- if [[ $LEANREPO == BLESSED && $CMAKE_BUILD_TYPE == TESTCOV ]]; then +- if [[ $LEANREPO == BLESSED && $TESTCOV == ON ]]; then ctest -D ExperimentalCoverage; fi - if [[ $LEANREPO == BLESSED && $MEMCHECK == TRUE ]]; then diff --git a/script/run_tests.sh b/script/run_tests.sh new file mode 100755 index 000000000..c919e4d7b --- /dev/null +++ b/script/run_tests.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +ctest -D ExperimentalBuild +yes "C" | ctest -VV +exit 0 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc38f8450..91dda4bd0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,7 +32,12 @@ set(CMAKE_CXX_FLAGS_DEBUG "-g -DLEAN_DEBUG -DLEAN_TRACE") set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") -set(CMAKE_CXX_FLAGS_TESTCOV "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage") + +# Test coverage +if("${TESTCOV}" MATCHES "ON") + message(STATUS "Enable test-coverage") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -fprofile-arcs -ftest-coverage") +endif() # Compiler-specific C++11 activation. if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") @@ -151,3 +156,7 @@ file(GLOB_RECURSE LEAN_SOURCES add_style_check_target(style "${LEAN_SOURCES}") add_test(NAME style_check COMMAND ${LEAN_SOURCE_DIR}/cmake/Modules/cpplint.py ${LEAN_SOURCES}) + +# Include Code Coverage +include(CodeCoverage) +setup_target_for_coverage(cov ${LEAN_SOURCE_DIR}/../script/run_tests.sh coverage)