Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Re-run failed unit tests automatically #31253

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[chore] Re-run failed unit tests automatically
mx-psi committed Feb 14, 2024

Verified

This commit was signed with the committer’s verified signature.
mx-psi Pablo Baeyens
commit f32561a2609a05dd945c881d9ab6f751c22f8433
14 changes: 8 additions & 6 deletions Makefile.Common
Original file line number Diff line number Diff line change
@@ -73,6 +73,8 @@ GOVULNCHECK := $(TOOLS_BIN_DIR)/govulncheck
GCI := $(TOOLS_BIN_DIR)/gci
GOTESTSUM := $(TOOLS_BIN_DIR)/gotestsum

GOTESTSUM_OPT?= --rerun-fails

# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release

@@ -121,38 +123,38 @@ common: lint test

.PHONY: test
test: $(GOTESTSUM)
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT)
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT)

.PHONY: test-with-cover
test-with-cover: $(GOTESTSUM)
mkdir -p $(PWD)/coverage/unit
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT) -cover -covermode=atomic -args -test.gocoverdir="$(PWD)/coverage/unit"
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT) -cover -covermode=atomic -args -test.gocoverdir="$(PWD)/coverage/unit"

.PHONY: do-unit-tests-with-cover
do-unit-tests-with-cover: $(GOTESTSUM)
@echo "running $(GOCMD) unit test ./... + coverage in `pwd`"
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT_WITH_COVERAGE)
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT_WITH_COVERAGE)
$(GOCMD) tool cover -html=coverage.txt -o coverage.html

.PHONY: mod-integration-test
mod-integration-test: $(GOTESTSUM)
@echo "running $(GOCMD) integration test ./... in `pwd`"
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION)
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION)
@if [ -e integration-coverage.txt ]; then \
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
fi

.PHONY: do-integration-tests-with-cover
do-integration-tests-with-cover: $(GOTESTSUM)
@echo "running $(GOCMD) integration test ./... + coverage in `pwd`"
$(GOTESTSUM) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION_COVERAGE)
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="./..." -- $(GOTEST_OPT_WITH_INTEGRATION_COVERAGE)
@if [ -e integration-coverage.txt ]; then \
$(GOCMD) tool cover -html=integration-coverage.txt -o integration-coverage.html; \
fi

.PHONY: benchmark
benchmark: $(GOTESTSUM)
$(GOTESTSUM) --packages="$(ALL_PKGS)" -- -bench=. -run=notests --tags=$(GO_BUILD_TAGS)
$(GOTESTSUM) $(GOTESTSUM_OPT) --packages="$(ALL_PKGS)" -- -bench=. -run=notests --tags=$(GO_BUILD_TAGS)

.PHONY: addlicense
addlicense: $(ADDLICENSE)