-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for whether Redis is running with Make, so the dev and CI environments run similarly and show the same warnings. Now the tests can be only "make test"!
- Loading branch information
Showing
2 changed files
with
39 additions
and
13 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
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,19 +1,55 @@ | ||
MAKEFLAGS += --warn-undefined-variables | ||
MAKEFLAGS += --no-builtin-rules | ||
MAKEFLAGS += --no-builtin-variables | ||
|
||
.PHONY: test | ||
#: run all tests | ||
test: test_with_race test_all | ||
|
||
.PHONY: test_with_race | ||
#: run only tests tagged with potential race conditions | ||
test_with_race: | ||
test_with_race: wait_for_redis | ||
@echo | ||
@echo "+++ testing - race conditions?" | ||
@echo | ||
go test -tags race --race --timeout 60s -v ./... | ||
|
||
.PHONY: test_all | ||
#: run all tests, but with no race condition detection | ||
test_all: | ||
test_all: wait_for_redis | ||
@echo | ||
@echo "+++ testing - all the tests" | ||
@echo | ||
go test -tags all --timeout 60s -v ./... | ||
|
||
.PHONY: wait_for_redis | ||
# wait for Redis to become available for test suite | ||
wait_for_redis: dockerize | ||
@echo | ||
@echo "+++ We need a Redis running to run the tests." | ||
@echo | ||
@echo "Checking with dockerize $(shell ./dockerize --version)" | ||
@./dockerize -wait tcp://localhost:6379 -timeout 30s | ||
|
||
# ensure the dockerize command is available | ||
dockerize: dockerize.tar.gz | ||
tar xzvmf dockerize.tar.gz | ||
|
||
HOST_OS := $(shell uname -s | tr A-Z a-z) | ||
# You can override this version from an environment variable. | ||
DOCKERIZE_VERSION ?= v0.6.1 | ||
DOCKERIZE_RELEASE_ASSET := dockerize-${HOST_OS}-amd64-${DOCKERIZE_VERSION}.tar.gz | ||
|
||
dockerize.tar.gz: | ||
@echo | ||
@echo "+++ Retrieving dockerize tool for Redis readiness check." | ||
@echo | ||
curl --location --silent --show-error \ | ||
--output dockerize.tar.gz \ | ||
https://github.com/jwilder/dockerize/releases/download/${DOCKERIZE_VERSION}/${DOCKERIZE_RELEASE_ASSET} \ | ||
&& file dockerize.tar.gz | grep --silent gzip | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f dockerize.tar.gz | ||
rm -f dockerize |