Skip to content

Commit 799d7df

Browse files
committed
Add filter option when running tests
Allow running specific controller tests by specifying a prefix e.g. GO_TEST_PREFIX=TestOCI make test-ctrl Signed-off-by: Stefan Prodan <[email protected]>
1 parent 25b8825 commit 799d7df

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ LIBGIT2_TAG ?= v0.2.0
99
# Allows for defining additional Go test args, e.g. '-tags integration'.
1010
GO_TEST_ARGS ?= -race
1111

12+
# Allows for filtering tests based on the specified prefix
13+
GO_TEST_PREFIX ?=
14+
1215
# Allows for defining additional Docker buildx arguments,
1316
# e.g. '--push'.
1417
BUILD_ARGS ?=
@@ -69,7 +72,7 @@ build: check-deps $(LIBGIT2) ## Build manager binary
6972
go build $(GO_STATIC_FLAGS) -o $(BUILD_DIR)/bin/manager main.go
7073

7174
KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) --arch=$(ENVTEST_ARCH) use -i $(ENVTEST_KUBERNETES_VERSION) --bin-dir=$(ENVTEST_ASSETS_DIR) -p path)"
72-
test: $(LIBGIT2) install-envtest test-api check-deps ## Run tests
75+
test: $(LIBGIT2) install-envtest test-api check-deps ## Run all tests
7376
HTTPS_PROXY="" HTTP_PROXY="" \
7477
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) \
7578
GIT_CONFIG_GLOBAL=/dev/null \
@@ -78,6 +81,15 @@ test: $(LIBGIT2) install-envtest test-api check-deps ## Run tests
7881
$(GO_TEST_ARGS) \
7982
-coverprofile cover.out
8083

84+
test-ctrl: $(LIBGIT2) install-envtest test-api check-deps ## Run controller tests
85+
HTTPS_PROXY="" HTTP_PROXY="" \
86+
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) \
87+
GIT_CONFIG_GLOBAL=/dev/null \
88+
go test $(GO_STATIC_FLAGS) \
89+
-run "^$(GO_TEST_PREFIX).*" \
90+
-v ./controllers \
91+
-coverprofile cover.out
92+
8193
check-deps:
8294
ifeq ($(shell uname -s),Darwin)
8395
if ! command -v pkg-config &> /dev/null; then echo "pkg-config is required"; exit 1; fi

0 commit comments

Comments
 (0)