Better coverage support

This commit is contained in:
Derek Collison
2016-01-17 09:57:11 -08:00
parent 25732e087b
commit a28ce73281
5 changed files with 27 additions and 23 deletions

View File

@@ -7,14 +7,11 @@ install:
- go get golang.org/x/tools/cmd/vet - go get golang.org/x/tools/cmd/vet
- go get golang.org/x/tools/cmd/cover - go get golang.org/x/tools/cmd/cover
- go get github.com/mattn/goveralls - go get github.com/mattn/goveralls
- go get github.com/wadey/gocovmerge
script: script:
- go build - go build
- ./travis/gofmt.sh - go fmt ./...
- ./travis/govet.sh - go vet ./...
- go test -i -race ./... - go test -i -race ./...
- go test -v -race ./... - go test -v -race ./...
- ./travis/coveralls-script.sh - ./scripts/cov.sh TRAVIS
env:
global:
secure: fi/zxSp5eF6Mt8yrgJakBVinDpCDFy3zPZ4Jy7jsyoKWgF7CdSFmh0WBcN932KOLCRaVm7ZqD2RwO9SifIsBcDtZqML4RKg3Q+T+Uqt4LpskVobMYkPKDcA5i3c3ifhJu/wzl7Y/jnysvjxCwQrH/nGAc4+AwyH6x2TjKF7UFoY=

23
scripts/cov.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash -e
# Run from directory above via ./scripts/cov.sh
rm -rf ./cov
mkdir cov
go test -v -covermode=atomic -coverprofile=./cov/auth.out ./auth
go test -v -covermode=atomic -coverprofile=./cov/conf.out ./conf
go test -v -covermode=atomic -coverprofile=./cov/hash.out ./hash
go test -v -covermode=atomic -coverprofile=./cov/hashmap.out ./hashmap
go test -v -covermode=atomic -coverprofile=./cov/log.out ./logger
go test -v -covermode=atomic -coverprofile=./cov/server.out ./server
go test -v -covermode=atomic -coverprofile=./cov/sublist.out ./sublist
go test -v -covermode=atomic -coverprofile=./cov/test.out ./test
gocovmerge ./cov/*.out > acc.out
rm -rf ./cov
# If we have an arg, assume travis run and push to coveralls. Otherwise launch browser results
if [[ -n $1 ]]; then
$HOME/gopath/bin/goveralls -coverprofile=acc.out -service travis-ci
rm -rf ./acc.out
else
go tool cover -html=acc.out
fi

View File

@@ -1,16 +0,0 @@
#!/bin/bash -e
echo "mode: count" > acc.out
for Dir in $(find ./* -maxdepth 10 -type d | grep -v test | grep -v util);
do
if ls $Dir/*.go &> /dev/null;
then
GOMAXPROCS=1 go test -v -covermode=count -coverprofile=profile.out $Dir
if [ -f profile.out ]
then
cat profile.out | grep -v "mode: count" >> acc.out
fi
fi
done
$HOME/gopath/bin/goveralls -coverprofile=acc.out $COVERALLS
rm -rf ./profile.out
rm -rf ./acc.out