chore(testcov): add compile target "cov" to run code-coverage locally

- need to run cmake with "-DTESTCOV=ON" and "-DCMAKE_BUILD_TYPE=Debug"
 - type "make/ninja cov"
 - open "coverage/index.html" to check the code coverage
This commit is contained in:
Soonho Kong 2013-09-26 20:22:40 -07:00
parent 9d8ff0eadb
commit 5e5087b0a3
3 changed files with 18 additions and 4 deletions

View file

@ -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

4
script/run_tests.sh Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env bash
ctest -D ExperimentalBuild
yes "C" | ctest -VV
exit 0

View file

@ -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)