Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix code coverage reporting to CodeCov #293

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fi
mkdir build
cd build

if [ $BUILD_NAME = TRUSTY_GCC_DEBUG ]; then
if [ $BUILD_NAME = BIONIC_GCC_DEBUG_CODECOV ]; then
cmake "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" "-DLLVM_DIR=${LLVM_DIR}" "-DCODECOV=ON" ..
else
cmake "-DCMAKE_BUILD_TYPE=${BUILD_TYPE}" "-DLLVM_DIR=${LLVM_DIR}" "-DCODECOV=OFF" ..
Expand All @@ -36,7 +36,7 @@ if [ "${OS_NAME}" = "linux" ]; then
# - https://travis-ci.org/github/personalrobotics/chimera/jobs/671301082#L2523-L2573
make tests binding_tests

if [ $BUILD_NAME = TRUSTY_GCC_DEBUG ]; then
if [ $BUILD_NAME = BIONIC_GCC_DEBUG_CODECOV ]; then
make chimera_coverage
else
ctest --output-on-failure
Expand Down
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ env:

matrix:
include:
# TODO: Fix CODECOV reporting
- os: linux
compiler: gcc
env:
- BUILD_NAME=BIONIC_GCC_DEBUG_CODECOV
- BUILD_TYPE=Debug
- COMPILER=GCC
- LLVM_VERSION=6.0
- PYTHON_VERSION=3.6
- SUDO=sudo
- os: linux
compiler: gcc
env:
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ option(CODECOV "Enable CodeCov support" OFF)
if(CODECOV)
include(CodeCoverage)
setup_target_for_coverage(${PROJECT_NAME}_coverage ctest coverage)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage"
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 --coverage")
endif()

###########
Expand Down
11 changes: 11 additions & 0 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
# - Added support for Clang.
# - Some additional usage instructions.
#
# 2019-01-24, Brian Hou
# - Added support for Codecov uploads.
#
# USAGE:

# 0. (Mac only) If you use Xcode 5.1 make sure to patch geninfo as described here:
Expand Down Expand Up @@ -132,6 +135,7 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)

SET(coverage_info "${CMAKE_BINARY_DIR}/${_outputname}.info")
SET(coverage_cleaned "${coverage_info}.cleaned")
SET(codecov_script "${CMAKE_BINARY_DIR}/codecov.sh")

SEPARATE_ARGUMENTS(test_command UNIX_COMMAND "${_testrunner}")

Expand All @@ -148,6 +152,13 @@ FUNCTION(SETUP_TARGET_FOR_COVERAGE _targetname _testrunner _outputname)
COMMAND ${LCOV_PATH} --directory . --capture --output-file ${coverage_info}
COMMAND ${LCOV_PATH} --remove ${coverage_info} 'tests/*' '/usr/*' --output-file ${coverage_cleaned}
COMMAND ${GENHTML_PATH} -o ${_outputname} ${coverage_cleaned}

# Upload to Codecov (added by @brianhou)
COMMAND curl -s "https://codecov.io/bash" > ${codecov_script}
COMMAND chmod +x ${codecov_script}
COMMAND ${codecov_script} -R ${CMAKE_SOURCE_DIR} -X gcov -f ${coverage_cleaned}

# Clean up reports
COMMAND ${CMAKE_COMMAND} -E remove ${coverage_info} ${coverage_cleaned}

WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
Expand Down
2 changes: 1 addition & 1 deletion cmake/chimeraFindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ endif()
#
# Note that LLVM >= 7 causes memory leaks in chimera::util::resolveDeclaration()
# See https://github.com/personalrobotics/chimera/issues/222
set(COMPATIBLE_LLVM_VERSIONS 3.6 3.9 6.0 8.0 9.0 10.0)
set(COMPATIBLE_LLVM_VERSIONS 3.6 3.9 6.0 7.0 8.0 9.0 10.0)
set(LLVM_VERSION_MAJOR_MINOR ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR})
set(FOUND_COMPATIBLE_LLVM FALSE)
foreach(version ${COMPATIBLE_LLVM_VERSIONS})
Expand Down