Skip to content

Commit

Permalink
Merge code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotchance committed May 30, 2017
1 parent 29c9c94 commit 3922404
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,34 @@ before_install:
rvm get head
fi
# gocovmerge is used to merge all the separate unit/integration test coverage
# profiles.
- go get -u wadey/gocovmerge

script:
- . ./.travis.gofmt.sh

# Run the unit tests first
# Run the unit/integration tests first
- |
set -e
echo "" > coverage.txt
go test -tags=integration -race -coverprofile=profile.out -coverpkg ./...
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
# The code below was used from:
# https://github.com/golang/go/issues/6909#issuecomment-232878416
# as in @rodrigocorsi2 comment above (using full path to grep due to
# 'grep -n' alias)
export PKGS=$(go list ./... | /usr/bin/grep -v /vendor/)
# make comma-separated
export PKGS_DELIM=$(echo "$PKGS" | paste -sd "," -)
# should work as before replacing './...' with vars
go list -f '{{if or (len .TestGoFiles) (len .XTestGoFiles)}}go test -tags=integration -race -coverprofile {{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile -coverpkg $PKGS_DELIM {{.ImportPath}}{{end}}' $PKGS | xargs -I {} bash -c {}
# Merge coverage profiles.
gocovmerge `ls *.coverprofile` > coverage.txt
rm *.coverprofile
# These steps are from the README to verify it can be installed and run as
# documented.
Expand Down

0 comments on commit 3922404

Please sign in to comment.