aboutsummaryrefslogtreecommitdiffstats
path: root/build/test-global-coverage.sh
blob: 5bb233a31dc8378d55f01001b6e81e88ab9588d8 (plain) (blame)
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
#!/bin/bash

# This script runs all package tests and merges the resulting coverage
# profiles. Coverage is accounted per package under test.

set -e

if [ ! -f "build/env.sh" ]; then
    echo "$0 must be run from the root of the repository."
    exit 2
fi

echo "mode: count" > profile.cov

for pkg in $(go list ./...); do
    # drop the namespace prefix.
    dir=${pkg##github.com/ethereum/go-ethereum/}
    
    if [[ $dir != "tests" ]]; then
        go test -covermode=count -coverprofile=$dir/profile.tmp $pkg
    fi
    if [[ -f $dir/profile.tmp ]]; then
        tail -n +2 $dir/profile.tmp >> profile.cov
        rm $dir/profile.tmp
    fi
done