diff --git a/.travis.yml b/.travis.yml index 7174414..3bb7ec0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,14 @@ language: go -script: go test -race -v ./... +before_install: + - go get github.com/mattn/goveralls + - go get github.com/modocache/gover + +script: + - go test -race -v ./... + - ./coveralls.bash go: - - 1.7.x - - 1.8.x - - tip + - 1.7.x + - 1.8.x + - tip diff --git a/coverage.bash b/coverage.bash deleted file mode 100755 index f4b0524..0000000 --- a/coverage.bash +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -# This script runs the cover tool on all packages with test files. If you set a -# WEB environment variable, it will additionally open the web-based coverage -# visualizer for each package. - -set -e - -function go_files { find . -name '*_test.go' ; } -function filter { grep -v '/_' ; } -function remove_relative_prefix { sed -e 's/^\.\///g' ; } - -function directories { - go_files | filter | remove_relative_prefix | while read f - do - dirname $f - done -} - -function unique_directories { directories | sort | uniq ; } - -PATHS=${1:-$(unique_directories)} - -function report { - for path in $PATHS - do - go test -coverprofile=$path/cover.coverprofile ./$path - done -} - -function combine { - gover -} - -function clean { - find . -name cover.coverprofile | xargs rm -} - -report -combine -clean - -if [ -n "${WEB+x}" ] -then - go tool cover -html=gover.coverprofile -fi - diff --git a/coveralls.bash b/coveralls.bash new file mode 100755 index 0000000..cf8fee9 --- /dev/null +++ b/coveralls.bash @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +if ! type -P gover +then + echo gover missing: go get github.com/modocache/gover + exit 1 +fi + +if ! type -P goveralls +then + echo goveralls missing: go get github.com/mattn/goveralls + exit 1 +fi + +if [[ "$COVERALLS_TOKEN" == "" ]] +then + echo COVERALLS_TOKEN not set + exit 1 +fi + +go list ./... | grep -v '/examples/' | cut -d'/' -f 4- | while read d +do + cd $d + go test -covermode count -coverprofile coverage.coverprofile + cd - +done + +gover +goveralls -coverprofile gover.coverprofile -service travis-ci -repotoken $COVERALLS_TOKEN +find . -name '*.coverprofile' -delete +