Skip to content

Commit

Permalink
chore: rerun test fails (#280)
Browse files Browse the repository at this point in the history
# Description

redshift tests are sensitive to other concurrent tests deleting schemas
and they can fail, thus retrying test fails in gotestsum.

## Security

- [x] The code changed/added as part of this pull request won't create
any security issues with how the software is being used.
  • Loading branch information
atzoum authored Feb 13, 2025
1 parent ecb6b91 commit c9ee171
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ coverage.html
*.orig
**/gomock_reflect_*/*
ginkgo.report
vendor/
vendor/
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

GO=go
LDFLAGS?=-s -w
TESTFILE=_testok

default: lint

Expand All @@ -12,26 +11,28 @@ generate: install-tools
test: install-tools test-run

test-run: ## Run all unit tests
ifeq ($(filter 1,$(debug) $(RUNNER_DEBUG)),)
$(eval TEST_CMD = gotestsum --format pkgname-and-test-fails --)
$(eval TEST_OPTIONS = -p=1 -v -failfast -shuffle=on -coverprofile=profile.out -covermode=atomic -coverpkg=./... -vet=all --timeout=30m)
else
$(eval TEST_CMD = SLOW=0 go test)
$(eval TEST_OPTIONS = -p=1 -v -failfast -shuffle=on -coverprofile=profile.out -covermode=atomic -coverpkg=./... -vet=all --timeout=30m)
endif
ifdef package
ifdef exclude
$(eval FILES = `go list ./$(package)/... | egrep -iv '$(exclude)'`)
$(TEST_CMD) -count=1 $(TEST_OPTIONS) $(FILES) && touch $(TESTFILE)
$(eval PACKAGES = `go list ./$(package)/... | egrep -iv '$(exclude)' | xargs`)
else
$(TEST_CMD) $(TEST_OPTIONS) ./$(package)/... && touch $(TESTFILE)
$(eval PACKAGES = "./$(package)/...")
endif
else ifdef exclude
$(eval FILES = `go list ./... | egrep -iv '$(exclude)'`)
$(TEST_CMD) -count=1 $(TEST_OPTIONS) $(FILES) && touch $(TESTFILE)
$(eval PACKAGES = `go list ./... | egrep -iv '$(exclude)' | xargs`)
else
$(eval PACKAGES = "./...")
endif

ifeq ($(filter 1,$(debug) $(RUNNER_DEBUG)),)
$(eval TEST_CMD = gotestsum --rerun-fails --format pkgname-and-test-fails --packages="${PACKAGES}" --)
$(eval TEST_OPTIONS = -p=1 -v -failfast -shuffle=on -coverprofile=profile.out -coverpkg=./... -covermode=atomic -vet=all --timeout=60m)
$(eval CMD = $(TEST_CMD) -count=1 $(TEST_OPTIONS) ${PACKAGES})
else
$(TEST_CMD) -count=1 $(TEST_OPTIONS) ./... && touch $(TESTFILE)
$(eval TEST_CMD = go test)
$(eval TEST_OPTIONS = -p=1 -v -failfast -shuffle=on -coverprofile=profile.out -coverpkg=./... -covermode=atomic -vet=all --timeout=60m)
$(eval CMD = $(TEST_CMD) -count=1 $(TEST_OPTIONS) ${PACKAGES})
endif
$(CMD)

help: ## Show the available commands
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' ./Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Expand Down

0 comments on commit c9ee171

Please sign in to comment.