Last active
January 25, 2021 00:00
-
-
Save paddycarver/6f0d85d2763accaf2668 to your computer and use it in GitHub Desktop.
Testing a Go package with subpackages and getting good coverage reports.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
go get -u github.com/golang/lint/golint | |
go get -u github.com/paddyforan/combinedcoverage | |
go get -u github.com/wadey/gocovmerge | |
cd $GOPATH/src/path/to/your/package | |
go vet $(go list ./... | grep -v '/vendor/') | |
go list ./... | grep -v /vendor/ | xargs -L1 golint | |
mkdir -p coverage | |
rm -rf coverage/* | |
for pkg in $(go list ./... | grep -v '/vendor/'); do \ | |
echo "################### testing ${pkg} ###################"; \ | |
go test $pkg -v -race -covermode=count -coverprofile=coverage/${pkg//\//.}.out; \ | |
done | |
combinedcoverage $(find coverage/*.out | grep -v '/vendor/') | |
gocovmerge $(find coverage/*.out | grep -v '/vendor/') > coverage/total.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment