Skip to content

Commit 0cf141e

Browse files
Cleanup: Run unit tests with ginkgo
As well as being a test framework, ginkgo can be used as an application to run the test. It will run the same tests as `go test`, but ginkgo allows tests within a suite to be run in concurrently (`go test` can run suites in parallel, but each test in a suite sequentially). Since the majority of our tests are in the same suite (controllers/) it can save time running with ginkgo directly
1 parent 7310705 commit 0cf141e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Makefile

+8-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ vet: ## Run go vet against code.
111111
go vet ./...
112112

113113
.PHONY: test
114-
test: manifests generate fmt vet envtest ## Run tests.
115-
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
114+
test: manifests generate fmt vet envtest ginkgo ## Run tests.
115+
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" $(GINKGO) run --succinct -p ./... -coverprofile cover.out
116116

117117
##@ Build
118118

@@ -202,6 +202,7 @@ $(LOCALBIN):
202202
KUSTOMIZE ?= $(LOCALBIN)/kustomize
203203
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
204204
ENVTEST ?= $(LOCALBIN)/setup-envtest
205+
GINKGO ?= $(LOCALBIN)/ginkgo
205206

206207
## Tool Versions
207208
KUSTOMIZE_VERSION ?= v3.8.7
@@ -228,6 +229,11 @@ envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
228229
$(ENVTEST): $(LOCALBIN)
229230
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
230231

232+
.PHONY: ginkgo
233+
ginkgo: $(GINKGO) ## Download envtest-setup locally if necessary.
234+
$(GINKGO): $(LOCALBIN)
235+
test -s $(LOCALBIN)/ginkgo || GOBIN=$(LOCALBIN) go install github.com/onsi/ginkgo/v2/ginkgo
236+
231237
.PHONY: operator-sdk
232238
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
233239
operator-sdk: ## Download operator-sdk locally if necessary.

0 commit comments

Comments
 (0)