1#! /bin/bash 2# 3# Copyright 2017 - 2019 James E. King III 4# Distributed under the Boost Software License, Version 1.0. 5# (See accompanying file LICENSE_1_0.txt or copy at 6# http://www.boost.org/LICENSE_1_0.txt) 7# 8# Bash script to run in travis to perform codecov.io integration 9# 10 11# assumes cwd is the top level directory of the boost project 12# assumes an environment variable $SELF is the boost project name 13 14set -ex 15 16. ci/enforce.sh 17 18if [ -z "$GCOV" ]; then 19 if [ "${B2_TOOLSET%%-*}" == "gcc" ]; then 20 ver="${B2_TOOLSET#*-}" 21 GCOV=gcov-${ver} 22 else 23 GCOV=gcov-7 # default 24 fi 25fi 26 27# lcov after 1.14 needs this 28# sudo apt install --no-install-recommends -y libperlio-gzip-perl libjson-perl 29 30# install the latest lcov we know works 31# some older .travis.yml files install the tip which may be unstable 32rm -rf /tmp/lcov 33pushd /tmp 34git clone -b v1.14 https://github.com/linux-test-project/lcov.git 35export PATH=/tmp/lcov/bin:$PATH 36which lcov 37lcov --version 38popd 39 40B2_VARIANT=variant=debug 41ci/travis/build.sh cxxflags=--coverage linkflags=--coverage 42#cxxflags=-fprofile-arcs cxxflags=-ftest-coverage linkflags=-fprofile-arcs linkflags=-ftest-coverage 43 44# switch back to the original source code directory 45cd $TRAVIS_BUILD_DIR 46 47# coverage files are in ../../b2 from this location 48lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=0 --base-directory "$BOOST_ROOT/libs/$SELF" --directory "$BOOST_ROOT" --capture --output-file all.info 49 50# all.info contains all the coverage info for all projects - limit to ours 51# first we extract the interesting headers for our project then we use that list to extract the right things 52for f in `for f in include/boost/*; do echo $f; done | cut -f2- -d/`; do echo "*/$f*"; done > /tmp/interesting 53echo headers that matter: 54cat /tmp/interesting 55xargs -L 999999 -a /tmp/interesting lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=1 --extract all.info {} "*/libs/$SELF/src/*" --output-file coverage.info 56 57# dump a summary on the console - helps us identify problems in pathing 58lcov --gcov-tool=$GCOV --rc lcov_branch_coverage=1 --list coverage.info 59 60# 61# upload to codecov.io 62# 63curl -s https://codecov.io/bash > .codecov 64chmod +x .codecov 65./.codecov -f coverage.info -X gcov -x "$GCOV"