build: Simplify make test and log output

This commit is contained in:
Frank Schroeder 2017-04-26 15:47:57 -07:00 committed by Frank Schröder
parent 63842b1e09
commit 7227ee21c3
4 changed files with 9 additions and 50 deletions

1
.gitignore vendored
View File

@ -30,6 +30,7 @@ website/build/
website/npm-debug.log website/npm-debug.log
*.old *.old
*.attr *.attr
*.log
ui/.sass-cache ui/.sass-cache
ui/static/base.css ui/static/base.css

View File

@ -4,9 +4,8 @@ GOTOOLS = \
github.com/mitchellh/gox \ github.com/mitchellh/gox \
golang.org/x/tools/cmd/cover \ golang.org/x/tools/cmd/cover \
golang.org/x/tools/cmd/stringer golang.org/x/tools/cmd/stringer
TEST ?= ./...
GOTAGS ?= consul GOTAGS ?= consul
GOFILES ?= $(shell go list $(TEST) | grep -v /vendor/) GOFILES ?= $(shell go list ./... | grep -v /vendor/)
GOOS=$(shell go env GOOS) GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH) GOARCH=$(shell go env GOARCH)
@ -38,27 +37,23 @@ dist:
@GOTAGS='$(GOTAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'" @GOTAGS='$(GOTAGS)' sh -c "'$(CURDIR)/scripts/dist.sh'"
cov: cov:
gocov test ${GOFILES} | gocov-html > /tmp/coverage.html gocov test $(GOFILES) | gocov-html > /tmp/coverage.html
open /tmp/coverage.html open /tmp/coverage.html
test: test: dev
@./scripts/verify_no_uuid.sh go test -tags "$(GOTAGS)" -i -run '^$$' ./...
@env \ go test -tags "$(GOTAGS)" -v $(GOFILES) | tee test.log 2>&1
GOTAGS="${GOTAGS}" \
GOFILES="${GOFILES}" \
TESTARGS="${TESTARGS}" \
sh -c "'$(CURDIR)/scripts/test.sh'"
cover: cover:
go test ${GOFILES} --cover go test $(GOFILES) --cover
format: format:
@echo "--> Running go fmt" @echo "--> Running go fmt"
@go fmt ${GOFILES} @go fmt $(GOFILES)
vet: vet:
@echo "--> Running go vet" @echo "--> Running go vet"
@go vet ${GOFILES}; if [ $$? -eq 1 ]; then \ @go vet $(GOFILES); if [ $$? -eq 1 ]; then \
echo ""; \ echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \ echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \ echo "and fix them if necessary before submitting the code for review."; \

View File

@ -1,24 +0,0 @@
#!/usr/bin/env bash
set -e
if [ -n "$TRAVIS" ]; then
# Install all packages - this will make running the suite faster
echo "--> Installing packages for faster tests"
go install -tags="${GOTAGS}" -a ./...
fi
# If we are testing the API, build and install consul
if grep -q "/consul/api" <<< "${GOFILES}"; then
# Create a temp dir and clean it up on exit
TEMPDIR=`mktemp -d -t consul-test.XXX`
trap "rm -rf ${TEMPDIR}" EXIT HUP INT QUIT TERM
# Build the Consul binary for the API tests
echo "--> Building consul"
go build -tags="${GOTAGS}" -o $TEMPDIR/consul
PATH="${TEMPDIR}:${PATH}"
fi
# Run the tests
echo "--> Running tests"
go test -timeout=360s -tags="${GOTAGS}" ${GOFILES} ${TESTARGS}

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
grep GenerateUUID consul/state/state_store.go
RESULT=$?
if [ $RESULT -eq 0 ]; then
exit 1
fi
grep GenerateUUID consul/fsm.go
RESULT=$?
if [ $RESULT -eq 0 ]; then
exit 1
fi