-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
58 additions
and
754 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
# go test and code quality report | ||
*.out | ||
|
||
# legacy | ||
go.mod | ||
go.sum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,59 @@ | ||
OPEN_BROWSER = | ||
SUPPORTED_VERSIONS = 1.5 1.6 1.7 1.8 1.9 1.10 latest | ||
PACKAGES := go list ./... | grep -v vendor | grep -v ^_ | ||
SHELL ?= /bin/bash -euo pipefail | ||
|
||
|
||
include makes/env.mk | ||
include makes/docker.mk | ||
include makes/local.mk | ||
include cmd/retry/Makefile | ||
.PHONY: test | ||
test: #| Runs tests with race. | ||
#| Accepts: ARGS. | ||
#| Uses: PACKAGES. | ||
$(PACKAGES) | xargs go test -race $(strip $(ARGS)) | ||
|
||
.PHONY: test-check | ||
test-check: #| Fast runs tests to check their compilation errors. | ||
#| Accepts: ARGS. | ||
#| Uses: PACKAGES. | ||
$(PACKAGES) | xargs go test -run=^hack $(strip $(ARGS)) | ||
|
||
.PHONY: code-quality-check | ||
code-quality-check: ARGS = \ | ||
--exclude=".*_test\.go:.*error return value not checked.*\(errcheck\)$$" \ | ||
--exclude="duplicate of.*_test.go.*\(dupl\)$$" \ | ||
--vendor --deadline=1m ./... | sort | ||
code-quality-check: docker-tool-gometalinter | ||
.PHONY: test-with-coverage | ||
test-with-coverage: #| Runs tests with coverage. | ||
#| Accepts: ARGS. | ||
#| Uses: PACKAGES. | ||
$(PACKAGES) | xargs go test -cover $(strip $(ARGS)) | ||
|
||
.PHONY: code-quality-report | ||
code-quality-report: | ||
time make code-quality-check | tail +7 | tee report.out | ||
.PHONY: test-with-coverage-formatted | ||
test-with-coverage-formatted: #| Runs tests with coverage and formats the result. | ||
#| Accepts: ARGS. | ||
#| Uses: PACKAGES. | ||
$(PACKAGES) | xargs go test -cover $(strip $(ARGS)) | column -t | sort -r | ||
|
||
.PHONY: test-with-coverage-profile | ||
test-with-coverage-profile: #| Runs tests with coverage and collects the result. | ||
#| Accepts: ARGS, OPEN_BROWSER. | ||
#| Uses: GO_TEST_COVERAGE_MODE, GO_TEST_COVERAGE_FILENAME, PACKAGES. | ||
echo 'mode: ${GO_TEST_COVERAGE_MODE}' > '${GO_TEST_COVERAGE_FILENAME}' | ||
for package in $$($(PACKAGES)); do \ | ||
go test -covermode '${GO_TEST_COVERAGE_MODE}' \ | ||
-coverprofile "coverage_$${package##*/}.out" \ | ||
$(strip $(ARGS)) "$${package}"; \ | ||
if [ -f "coverage_$${package##*/}.out" ]; then \ | ||
sed '1d' "coverage_$${package##*/}.out" >> '${GO_TEST_COVERAGE_FILENAME}'; \ | ||
rm "coverage_$${package##*/}.out"; \ | ||
fi \ | ||
done | ||
|
||
.PHONY: test-example | ||
test-example: GO_TEST_COVERAGE_FILENAME = coverage_example.out | ||
test-example: #| Runs example tests with coverage and collects the result. | ||
#| Accepts: ARGS, OPEN_BROWSER. | ||
#| Uses: GO_TEST_COVERAGE_MODE, GO_TEST_COVERAGE_FILENAME, PACKAGES. | ||
echo 'mode: ${GO_TEST_COVERAGE_MODE}' > '${GO_TEST_COVERAGE_FILENAME}' | ||
for package in $$($(PACKAGES)); do \ | ||
go test -v -run=Example \ | ||
-covermode '${GO_TEST_COVERAGE_MODE}' \ | ||
-coverprofile "coverage_example_$${package##*/}.out" \ | ||
$(strip $(ARGS)) "$${package}"; \ | ||
if [ -f "coverage_$${package##*/}.out" ]; then \ | ||
sed '1d' "coverage_example_$${package##*/}.out" >> '${GO_TEST_COVERAGE_FILENAME}'; \ | ||
rm "coverage_example_$${package##*/}.out"; \ | ||
fi \ | ||
done |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.