1TEST?=./... 2VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr 3 4default: test 5 6# test runs the unit tests and vets the code 7test: 8 ACD_ACC= go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4 9 @$(MAKE) fmt 10 @$(MAKE) vet 11 12# testacc runs acceptance tests 13testacc: 14 @if [ "$(TEST)" = "./..." ]; then \ 15 echo "ERROR: Set TEST to a specific package"; \ 16 exit 1; \ 17 fi 18 ACD_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 45m 19 20# testrace runs the race checker 21testrace: 22 ACD_ACC= go test -race $(TEST) $(TESTARGS) 23 24# updatedeps installs all the dependencies needed to run 25# and build 26updatedeps: 27 @gpm 28 29cover: 30 @go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \ 31 go get -u golang.org/x/tools/cmd/cover; \ 32 fi 33 go test $(TEST) -coverprofile=coverage.out 34 go tool cover -html=coverage.out 35 rm coverage.out 36 37# fmt formats the Go source code 38fmt: 39 @go list ./... \ 40 | xargs go fmt 41 42# vet runs the Go source code static analysis tool `vet` to find 43# any common errors. 44vet: 45 @go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \ 46 go get golang.org/x/tools/cmd/vet; \ 47 fi 48 @go list -f '{{.Dir}}' ./... \ 49 | xargs go tool vet ; if [ $$? -eq 1 ]; then \ 50 echo ""; \ 51 echo "Vet found suspicious constructs. Please check the reported constructs"; \ 52 echo "and fix them if necessary before submitting the code for reviewal."; \ 53 fi 54 55.PHONY: default test vet 56