Browse Source

build: Simplify make test and log output

pull/2968/head
Frank Schroeder 8 years ago committed by Frank Schröder
parent
commit
9c632e4eb7
  1. 1
      .gitignore
  2. 21
      GNUmakefile
  3. 24
      scripts/test.sh
  4. 13
      scripts/verify_no_uuid.sh

1
.gitignore vendored

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

21
GNUmakefile

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

24
scripts/test.sh

@ -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}

13
scripts/verify_no_uuid.sh

@ -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
Loading…
Cancel
Save