Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 261e443

Browse files
committed
WIP related to coverage
1 parent e05ad94 commit 261e443

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

.travis.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ os:
1111
compiler:
1212
- gcc
1313

14+
15+
addons:
16+
apt:
17+
sources:
18+
- ubuntu-toolchain-r-test
19+
packages:
20+
- lcov
21+
1422
matrix:
1523
include:
1624
- bare_linux:
@@ -42,7 +50,27 @@ before_script:
4250
- mkdir -p build
4351

4452
script:
45-
- if [ "$ROS_DISTRO" = "none" ]; then (cd build; cmake .. ; sudo cmake --build . --target install; ./bin/behaviortree_cpp_test); fi
53+
- if [ "$ROS_DISTRO" = "none" ]; then (cd build; cmake .. ; sudo cmake -DCMAKE_BUILD_TYPE=Debug -DADD_COVERAGE=ON --build . --target install; ./bin/behaviortree_cpp_test); fi
4654
- if [ "$ROS_DISTRO" != "none" ]; then (.ci_config/travis.sh); fi
4755

4856

57+
58+
after_success:
59+
# Creating report
60+
- cd ${TRAVIS_BUILD_DIR}
61+
- lcov --directory . --capture --output-file coverage.info # capture coverage info
62+
- lcov --remove coverage.info '/usr/*' --output-file coverage.info # filter out system
63+
- lcov --list coverage.info #debug info
64+
# Uploading report to CodeCov
65+
- bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
66+
67+
env:
68+
global:
69+
- LANG="en_US.UTF-8"
70+
71+
notifications:
72+
email:
73+
recipients:
74+
75+
on_success: change
76+
on_failure: always

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,18 @@ endif()
1010

1111
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
1212

13-
1413
set(CMAKE_CONFIG_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")
1514
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CONFIG_PATH}")
1615

1716
option(BUILD_EXAMPLES "Build tutorials and examples" ON)
1817
option(BUILD_UNIT_TESTS "Build the unit tests" ON)
18+
option(ADD_COVERAGE "Include code coverage" OFF)
19+
20+
if(CMAKE_COMPILER_IS_GNUCXX)
21+
include(CodeCoverage)
22+
setup_target_for_coverage(${PROJECT_NAME}_coverage tests coverage)
23+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
24+
endif()
1925

2026
#############################################################
2127
# Find packages

0 commit comments

Comments
 (0)