diff --git a/.travis.yml b/.travis.yml index 2383278f..b18ca58e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,14 +7,11 @@ install: - go get golang.org/x/tools/cmd/vet - go get golang.org/x/tools/cmd/cover - go get github.com/mattn/goveralls - +- go get github.com/wadey/gocovmerge script: - go build -- ./travis/gofmt.sh -- ./travis/govet.sh +- go fmt ./... +- go vet ./... - go test -i -race ./... - go test -v -race ./... -- ./travis/coveralls-script.sh -env: - global: - secure: fi/zxSp5eF6Mt8yrgJakBVinDpCDFy3zPZ4Jy7jsyoKWgF7CdSFmh0WBcN932KOLCRaVm7ZqD2RwO9SifIsBcDtZqML4RKg3Q+T+Uqt4LpskVobMYkPKDcA5i3c3ifhJu/wzl7Y/jnysvjxCwQrH/nGAc4+AwyH6x2TjKF7UFoY= +- ./scripts/cov.sh TRAVIS diff --git a/scripts/cov.sh b/scripts/cov.sh new file mode 100755 index 00000000..82615dcf --- /dev/null +++ b/scripts/cov.sh @@ -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 diff --git a/travis/gofmt.sh b/scripts/gofmt.sh similarity index 100% rename from travis/gofmt.sh rename to scripts/gofmt.sh diff --git a/travis/govet.sh b/scripts/govet.sh similarity index 100% rename from travis/govet.sh rename to scripts/govet.sh diff --git a/travis/coveralls-script.sh b/travis/coveralls-script.sh deleted file mode 100755 index a4d4332a..00000000 --- a/travis/coveralls-script.sh +++ /dev/null @@ -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