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

Optional arguments for make test #511

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
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
24 changes: 23 additions & 1 deletion build/test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,30 @@ GOTEST_OPTS ?=
GOTEST_TOOL ?= gotestsum $(GOTESTSUM_OPTS) --
endif

# Optionally test an individual package
INTERNAL_PKG ?= ...
PKG ?= ...

# If either type of package is specified, test only that directory (but do both if both are specified)
# Otherwise, test all
ifneq ($(PKG),...)
GOTEST_PKG = ./pkg/$(PKG)
ifneq ($(INTERNAL_PKG),...)
GOTEST_INTERNAL_PKGS = ./internal/$(INTERNAL_PKG)
else
GOTEST_INTERNAL_PKGS =
endif
else
GOTEST_INTERNAL_PKGS = ./internal/$(INTERNAL_PKG)
ifneq ($(INTERNAL_PKG),...)
GOTEST_PKG =
else
GOTEST_PKG = ./pkg/$(PKG)
endif
endif

# Overriden when running integration tests in CI/CD pipeline
GOTEST_CMD = CGO_ENABLED=1 $(GOTEST_TOOL) -v ./internal/... ./pkg/... $(GOTEST_OPTS)
GOTEST_CMD = CGO_ENABLED=1 $(GOTEST_TOOL) -v $(GOTEST_INTERNAL_PKGS) $(GOTEST_PKG) $(GOTEST_OPTS)

.PHONY: test
test: ## Runs unit tests in the internal and pkg folders
Expand Down
Loading