summaryrefslogtreecommitdiff
path: root/build-aux/travis-after-success
blob: efb0ab3068c18f7d550312cfb3f2980fab042280 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#! /bin/sh
set -e

if [ "$PERFORM_COVERITY_SCAN" = 1 ] || [ "$DISTCHECK" = 1 ]; then
  exit 0
fi

# All travis-* scripts must begin by initializing perlbrew if
# possible; travis does not do this for us.  Unfortunately, the
# code in $PERLBREW_ROOT/etc/bashrc is crawling with bashisms,
# and the only alternatives offered are for fish and csh, not
# portable sh.  Fortunately, what we need to do is simple
# enough to open-code.
if [ -f "$PERLBREW_HOME/init" ]; then
    . "$PERLBREW_HOME/init"
    PATH="$(echo $PATH | sed "s%:$PERLBREW_ROOT/bin:%:$PERLBREW_PATH:%")"
fi

GCOV=gcov

if [ "$TRAVIS_OS_NAME" = osx ]; then
  case "$CC" in
    gcc*)
      GCC_VER="$( (brew list --versions gcc || echo gcc 0) |
                  sed 's/^gcc \([0-9]*\)\..*$/\1/' )"
      if command -V "gcov-$GCC_VER"; then
        GCOV="gcov-$GCC_VER"
      fi
    ;;
  esac

elif [ "$TRAVIS_OS_NAME" = linux ]; then
  if [ "$CC" = clang ]; then
    GCOV="$PWD/build-aux/clang-gcov-wrapper"
  fi

fi
export GCOV

# Log the identities and versions of the coverage tools.
for tool in "$GCOV" lcov
do
    # $tool might include mandatory command-line arguments.
    # Interpret it the same way Make would.
    set fnord $tool
    shift
    if command -V $1; then
        echo + "$@" --version
        "$@" --version
    fi
    echo
done
set fnord; shift  # clear $@

set -x
# Merge all of the gcov output into one overview file using lcov,
# then prune data for the tests themselves, and for system libraries.

lcov --gcov-tool $GCOV --rc lcov_branch_coverage=1 \
     --directory . --output-file all_coverage.info \
     --capture

lcov --gcov-tool $GCOV --rc lcov_branch_coverage=1 \
     --directory . --output-file coverage.info \
     --remove all_coverage.info '/usr/*' '*test*'

# Upload the pruned .info file only.
curl -sS -o codecov.bash https://codecov.io/bash
bash codecov.bash -f coverage.info