From aaab336edc02bc170f1e9edb11f5701cad1b0e99 Mon Sep 17 00:00:00 2001 From: Brian Bland Date: Mon, 21 Dec 2015 12:35:33 -0800 Subject: [PATCH] Enables cross-package code coverage reporting Signed-off-by: Brian Bland --- circle.yml | 15 ++------------- coverpkg.sh | 7 +++++++ 2 files changed, 9 insertions(+), 13 deletions(-) create mode 100755 coverpkg.sh diff --git a/circle.yml b/circle.yml index f5dc4d7a..e275b2e1 100644 --- a/circle.yml +++ b/circle.yml @@ -48,9 +48,6 @@ dependencies: gvm use stable && go get github.com/axw/gocov/gocov github.com/golang/lint/golint - # Disabling goveralls for now - # go get github.com/axw/gocov/gocov github.com/mattn/goveralls github.com/golang/lint/golint - test: pre: # Output the go versions we are going to test @@ -75,25 +72,17 @@ test: pwd: $BASE_STABLE override: - # Test stable, and report - # Preset the goverall report file - # - echo "$CIRCLE_PAIN" > ~/goverage.report - - - gvm use stable; go list ./... | xargs -L 1 -I{} rm -f $GOPATH/src/{}/coverage.out: - pwd: $BASE_STABLE - - - gvm use stable; go list -tags "$DOCKER_BUILDTAGS" ./... | xargs -L 1 -I{} godep go test -tags "$DOCKER_BUILDTAGS" -test.short -coverprofile=$GOPATH/src/{}/coverage.out -covermode=count {}: + - gvm use stable; export ROOT_PACKAGE=$(go list .); go list -tags "$DOCKER_BUILDTAGS" ./... | xargs -L 1 -I{} bash -c 'export PACKAGE={}; godep go test -tags "$DOCKER_BUILDTAGS" -test.short -coverprofile=$GOPATH/src/$PACKAGE/coverage.out -coverpkg=$(./coverpkg.sh $PACKAGE $ROOT_PACKAGE) $PACKAGE': timeout: 600 pwd: $BASE_STABLE post: - # Aggregate and report to coveralls + # Report to codecov - bash <(curl -s https://codecov.io/bash): pwd: $BASE_STABLE ## Notes - # Disabled coveralls reporting: build breaking sending coverage data to coveralls # Disabled the -race detector due to massive memory usage. # Do we want these as well? # - go get code.google.com/p/go.tools/cmd/goimports diff --git a/coverpkg.sh b/coverpkg.sh new file mode 100755 index 00000000..7ee751ab --- /dev/null +++ b/coverpkg.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# Given a subpackage and the containing package, figures out which packages +# need to be passed to `go test -coverpkg`: this includes all of the +# subpackage's dependencies within the containing package, as well as the +# subpackage itself. +DEPENDENCIES="$(go list -f $'{{range $f := .Deps}}{{$f}}\n{{end}}' ${1} | grep ${2})" +echo "${1} ${DEPENDENCIES}" | xargs echo -n | tr ' ' ','