2016-02-13 00:50:37 +00:00
|
|
|
DEPS = $(go list -f '{{range .TestImports}}{{.}} {{end}}' ./...)
|
2020-01-20 12:58:02 +00:00
|
|
|
ENV = $(shell go env GOPATH)
|
|
|
|
GO_VERSION = $(shell go version)
|
|
|
|
GOLANG_CI_VERSION = v1.19.0
|
|
|
|
|
|
|
|
# Look for versions prior to 1.10 which have a different fmt output
|
|
|
|
# and don't lint with gofmt against them.
|
|
|
|
ifneq (,$(findstring go version go1.8, $(GO_VERSION)))
|
|
|
|
FMT=
|
|
|
|
else ifneq (,$(findstring go version go1.9, $(GO_VERSION)))
|
|
|
|
FMT=
|
|
|
|
else
|
|
|
|
FMT=--enable gofmt
|
|
|
|
endif
|
|
|
|
|
2019-07-24 21:06:39 +00:00
|
|
|
TEST_RESULTS_DIR?=/tmp/test-results
|
2016-02-13 00:50:37 +00:00
|
|
|
|
|
|
|
test:
|
2020-01-20 12:58:02 +00:00
|
|
|
go test $(TESTARGS) -timeout=60s -race .
|
|
|
|
go test $(TESTARGS) -timeout=60s -tags batchtest -race .
|
2016-02-13 00:50:37 +00:00
|
|
|
|
|
|
|
integ: test
|
2020-01-20 12:58:02 +00:00
|
|
|
INTEG_TESTS=yes go test $(TESTARGS) -timeout=25s -run=Integ .
|
|
|
|
INTEG_TESTS=yes go test $(TESTARGS) -timeout=25s -tags batchtest -run=Integ .
|
2016-02-13 00:50:37 +00:00
|
|
|
|
2019-07-24 21:06:39 +00:00
|
|
|
ci.test-norace:
|
|
|
|
gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-test.xml -- -timeout=60s
|
2020-01-20 12:58:02 +00:00
|
|
|
gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-test.xml -- -timeout=60s -tags batchtest
|
2019-07-24 21:06:39 +00:00
|
|
|
|
|
|
|
ci.test:
|
|
|
|
gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-test.xml -- -timeout=60s -race .
|
2020-01-20 12:58:02 +00:00
|
|
|
gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-test.xml -- -timeout=60s -race -tags batchtest .
|
2019-07-24 21:06:39 +00:00
|
|
|
|
|
|
|
ci.integ: ci.test
|
|
|
|
INTEG_TESTS=yes gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-integ.xml -- -timeout=25s -run=Integ .
|
2020-01-20 12:58:02 +00:00
|
|
|
INTEG_TESTS=yes gotestsum --format=short-verbose --junitfile $(TEST_RESULTS_DIR)/gotestsum-report-integ.xml -- -timeout=25s -run=Integ -tags batchtest .
|
2019-07-24 21:06:39 +00:00
|
|
|
|
2017-08-24 21:44:05 +00:00
|
|
|
fuzz:
|
2020-01-20 12:58:02 +00:00
|
|
|
go test $(TESTARGS) -timeout=20m ./fuzzy
|
|
|
|
go test $(TESTARGS) -timeout=20m -tags batchtest ./fuzzy
|
2019-07-24 21:06:39 +00:00
|
|
|
|
2016-02-13 00:50:37 +00:00
|
|
|
deps:
|
2019-04-09 22:09:22 +00:00
|
|
|
go get -t -d -v ./...
|
2016-02-13 00:50:37 +00:00
|
|
|
echo $(DEPS) | xargs -n1 go get -d
|
|
|
|
|
2020-01-20 12:58:02 +00:00
|
|
|
lint:
|
|
|
|
gofmt -s -w .
|
|
|
|
golangci-lint run -c .golangci-lint.yml $(FMT) .
|
|
|
|
|
|
|
|
dep-linter:
|
|
|
|
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(ENV)/bin $(GOLANG_CI_VERSION)
|
|
|
|
|
2016-02-13 00:50:37 +00:00
|
|
|
cov:
|
|
|
|
INTEG_TESTS=yes gocov test github.com/hashicorp/raft | gocov-html > /tmp/coverage.html
|
|
|
|
open /tmp/coverage.html
|
|
|
|
|
2020-01-20 12:58:02 +00:00
|
|
|
.PHONY: test cov integ deps dep-linter lint
|