1#!/bin/sh 2# must be executed in project root folder 3 4# Copyright Hans Dembinski 2018-2019 5# Distributed under the Boost Software License, Version 1.0. 6# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt 7 8if [ -z $GCOV ]; then 9 # gcov-9, gcov-7, gcov-6 do not work 10 for i in 8 5; do 11 if test $(which gcov-$i); then 12 GCOV=gcov-$i 13 break; 14 fi; 15 done 16fi 17 18LCOV_VERSION="1.14" 19LCOV_DIR="tools/lcov-${LCOV_VERSION}" 20 21if [ ! -e $LCOV_DIR ]; then 22 cd tools 23 curl -L https://github.com/linux-test-project/lcov/releases/download/v${LCOV_VERSION}/lcov-${LCOV_VERSION}.tar.gz | tar zxf - 24 cd .. 25fi 26 27# --rc lcov_branch_coverage=1 doesn't work on travis 28# LCOV="${LCOV_DIR}/bin/lcov --gcov-tool=${GCOV} --rc lcov_branch_coverage=1" 29LCOV="${LCOV_DIR}/bin/lcov --gcov-tool=${GCOV}" 30 31# collect raw data 32$LCOV --base-directory `pwd` \ 33 --directory `pwd`/../../bin.v2/libs/histogram/test \ 34 --capture --output-file coverage.info 35 36# remove uninteresting entries 37$LCOV --extract coverage.info "*/boost/histogram/*" --output-file coverage.info 38 39if [ $CI ] || [ $1 ]; then 40 # upload if on CI or when token is passed as argument 41 which cpp-coveralls || echo "Error: you need to install cpp-coveralls" 42 if [ $1 ]; then 43 cpp-coveralls -l coverage.info -r ../.. -n -t $1 44 else 45 cpp-coveralls -l coverage.info -r ../.. -n 46 fi 47else 48 # otherwise generate html report 49 $LCOV_DIR/bin/genhtml coverage.info --demangle-cpp -o coverage-report 50fi 51