...
1#!/bin/bash
2set -e -o pipefail
3
4# Run test coverage on each subdirectories and merge the coverage profile.
5echo "mode: ${GOCOVMODE-atomic}" > coverage.txt
6
7# Standard go tooling behavior is to ignore dirs with leading underscores
8# skip generator for race detection and coverage
9for dir in $(go list ./...)
10do
11 pth="$GOPATH/src/$dir"
12 go test -race -timeout 20m -covermode=${GOCOVMODE-atomic} -coverprofile=${pth}/profile.out $dir
13 if [ -f $pth/profile.out ]
14 then
15 cat $pth/profile.out | tail -n +2 >> coverage.txt
16 rm $pth/profile.out
17 fi
18done
19
20go tool cover -func coverage.txt
View as plain text