From 61ca9b02d4563c245b79795f628515e4b7a5c9ed Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Thu, 29 Jun 2017 14:50:47 +0200 Subject: [PATCH] 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. --- .gitignore | 3 ++- GNUmakefile | 24 ++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 41e9026dee..b19858143c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,11 @@ *.swp *.test .DS_Store -Thumbs.db .vagrant/ /pkg +Thumbs.db bin/ +exit-code ui/.bundle ui/.sass-cache ui/dist/ diff --git a/GNUmakefile b/GNUmakefile index ff7f810f7c..0580c649d7 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -7,7 +7,7 @@ GOTOOLS = \ golang.org/x/tools/cmd/stringer \ github.com/axw/gocov/gocov \ gopkg.in/matm/v1/gocov-html - + GOTAGS ?= consul GOFILES ?= $(shell go list ./... | grep -v /vendor/) GOOS=$(shell go env GOOS) @@ -50,16 +50,20 @@ cov: open /tmp/coverage.html test: dev - go test -tags "$(GOTAGS)" -i ./... - go test -tags "$(GOTAGS)" -run '^$$' ./... > /dev/null - go test -tags "$(GOTAGS)" -v $$(go list ./... | egrep -v '(agent/consul|vendor)') > test.log 2>&1 || echo 'FAIL_TOKEN' >> test.log - go test -tags "$(GOTAGS)" -v $$(go list ./... | egrep '(agent/consul)') >> test.log 2>&1 || echo 'FAIL_TOKEN' >> test.log - @if [ "$$TRAVIS" == "true" ] ; then cat test.log ; fi - @if grep -q 'FAIL_TOKEN' test.log ; then grep 'FAIL:' test.log ; exit 1 ; else echo 'PASS' ; fi + go test -tags '$(GOTAGS)' -i ./... + go test $(GOTEST_FLAGS) -tags '$(GOTAGS)' -timeout 7m -v ./... 2>&1 >test$(GOTEST_FLAGS).log ; echo $$? > exit-code + @echo "Exit code: `cat exit-code`" >> test$(GOTEST_FLAGS).log + @echo "----" + @grep -A5 'DATA RACE' test.log || true + @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 - go test -tags "$(GOTAGS)" -i -run '^$$' ./... - ( set -o pipefail ; go test -race -tags "$(GOTAGS)" -v ./... 2>&1 | tee test-race.log ) +test-race: + $(MAKE) GOTEST_FLAGS=-race cover: go test $(GOFILES) --cover