build: build all packages together

Build all packages together with a global timeout. Locally,
the tests pass within 40 sec. On travis, we complete within
3-4 min.

travis truncates the logs after 4MB which we are hitting so
show the relevant information first and then whatever is left.
This commit is contained in:
Frank Schroeder 2017-06-29 14:50:47 +02:00 committed by Frank Schröder
parent 33588d8fdd
commit 4ed443cfc4
2 changed files with 16 additions and 11 deletions

3
.gitignore vendored
View File

@ -5,10 +5,11 @@
*.swp *.swp
*.test *.test
.DS_Store .DS_Store
Thumbs.db
.vagrant/ .vagrant/
/pkg /pkg
Thumbs.db
bin/ bin/
exit-code
ui/.bundle ui/.bundle
ui/.sass-cache ui/.sass-cache
ui/dist/ ui/dist/

View File

@ -7,7 +7,7 @@ GOTOOLS = \
golang.org/x/tools/cmd/stringer \ golang.org/x/tools/cmd/stringer \
github.com/axw/gocov/gocov \ github.com/axw/gocov/gocov \
gopkg.in/matm/v1/gocov-html gopkg.in/matm/v1/gocov-html
GOTAGS ?= consul GOTAGS ?= consul
GOFILES ?= $(shell go list ./... | grep -v /vendor/) GOFILES ?= $(shell go list ./... | grep -v /vendor/)
GOOS=$(shell go env GOOS) GOOS=$(shell go env GOOS)
@ -50,16 +50,20 @@ cov:
open /tmp/coverage.html open /tmp/coverage.html
test: dev test: dev
go test -tags "$(GOTAGS)" -i ./... go test -tags '$(GOTAGS)' -i ./...
go test -tags "$(GOTAGS)" -run '^$$' ./... > /dev/null go test $(GOTEST_FLAGS) -tags '$(GOTAGS)' -timeout 7m -v ./... 2>&1 >test$(GOTEST_FLAGS).log ; echo $$? > exit-code
go test -tags "$(GOTAGS)" -v $$(go list ./... | egrep -v '(agent/consul|vendor)') > test.log 2>&1 || echo 'FAIL_TOKEN' >> test.log @echo "Exit code: `cat exit-code`" >> test$(GOTEST_FLAGS).log
go test -tags "$(GOTAGS)" -v $$(go list ./... | egrep '(agent/consul)') >> test.log 2>&1 || echo 'FAIL_TOKEN' >> test.log @echo "----"
@if [ "$$TRAVIS" == "true" ] ; then cat test.log ; fi @grep -A5 'DATA RACE' test.log || true
@if grep -q 'FAIL_TOKEN' test.log ; then grep 'FAIL:' test.log ; exit 1 ; else echo 'PASS' ; fi @grep -A10 'panic: test timed out' test.log || true
@grep '^PASS' test.log | uniq || true
@grep -A1 -- '--- FAIL:' test.log || true
@grep '^FAIL' test.log || true
@test "$$TRAVIS" == "true" && cat test.log || true
@exit $$(cat exit-code)
test-race: dev test-race:
go test -tags "$(GOTAGS)" -i -run '^$$' ./... $(MAKE) GOTEST_FLAGS=-race
( set -o pipefail ; go test -race -tags "$(GOTAGS)" -v ./... 2>&1 | tee test-race.log )
cover: cover:
go test $(GOFILES) --cover go test $(GOFILES) --cover