Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
Update .travis-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Pabón committed May 4, 2016
1 parent b39ee43 commit e3bbfc4
Showing 1 changed file with 4 additions and 28 deletions.
32 changes: 4 additions & 28 deletions .travis-coverage
Expand Up @@ -4,37 +4,13 @@
# the tool requires that it be used only on one package when
# capturing the coverage
# This is why we need this little script here.
packages="./apps/glusterfs"
packages="${packages} ./executors/sshexec"
packages="${packages} ./executors/mockexec"
packages="${packages} ./executors ./apps"
packages="${packages} ./client/cli/go/cmds"
packages="${packages} ./client/api/go-client"
packages="${packages} ./middleware"
COVERFILE=packagecover.out

coverage()
{
# For each package with test files, run with full coverage (including other packages)
go list -f '{{if gt (len .TestGoFiles) 0}}"go test -covermode count -coverprofile {{.Name}}_{{len .Imports}}_{{len .Deps}}.coverprofile -coverpkg ./... {{.ImportPath}}"{{end}}' ./... | xargs -I {} bash -c {}

echo "mode: count" > $COVERFILE
for pkg in $packages ; do
echo "-- Testing $pkg --"

# Collect coverage
go test -covermode=count -coverprofile=cover.out $pkg || exit 1

# Show in the command line
go tool cover -func=cover.out

# Append to coverfile
grep -v "^mode: count" cover.out >> $COVERFILE

# Cleanup
rm -f cover.out
done
}

coverage
# Merge the generated cover profiles into a single file
gocovmerge `ls *.coverprofile` > $COVERFILE

if [ -n "$COVERALLS_TOKEN" ] ; then
# Send to coveralls.io
Expand Down

0 comments on commit e3bbfc4

Please sign in to comment.