Created
November 26, 2015 07:15
-
-
Save axw/457a402b4dfb4e4267f9 to your computer and use it in GitHub Desktop.
Recursively run tests with coverage profiling of all juju packages, then output a gocov profile
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 | |
set -e | |
tmp=$(mktemp -d -p "" gocov.XXXXXXXXXX) | |
function cleanup { | |
rm -rf "$tmp" | |
} | |
trap cleanup EXIT | |
pattern=$1 | |
shift | |
for pkg in $(go list $pattern); do | |
mkdir -p $tmp/$pkg | |
coverpkg="$pkg" | |
juju_deps=$(go list -f '{{.Deps}}' $pkg | \ | |
tr -d '\[\]' | tr ' ' '\n' | \ | |
awk '/github\.com\/juju\//{print $1}' | \ | |
tr '\n' ',') | |
if test -n "$juju_deps"; then | |
coverpkg="$juju_deps$coverpkg" # juju_deps has a trailing ',' | |
fi | |
# redirect stdout to stderr so it doesn't get mixed into the gocov output | |
go test -outputdir "$tmp/$pkg" -coverprofile cover.out -coverpkg "$coverpkg" "$pkg" "$*" 1>&2 | |
done | |
find $tmp -name cover.out | xargs gocov convert |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment