Skip to content

Commit 9c6a6d9

Browse files
Max Jonas Wernermakkes
authored andcommitted
build: let users pass test flags to make test
This comes in handy e.g. to only run a single test during development. Signed-off-by: Max Jonas Werner <[email protected]>
1 parent 745d6ee commit 9c6a6d9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

DEVELOPMENT.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ You can run the test suite by simply doing
5353
make test
5454
```
5555

56+
### Additional test configuration
57+
58+
By setting the `GO_TEST_ARGS` environment variable you can pass additional flags to [`go test`](https://pkg.go.dev/cmd/go#hdr-Test_packages):
59+
60+
```sh
61+
make test GO_TEST_ARGS="-v -run=TestReadIgnoreFile/with_domain"
62+
```
63+
5664
## How to run the controller locally
5765

5866
Install the controller's CRDs on your test cluster:

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ TAG ?= latest
66
LIBGIT2_IMG ?= ghcr.io/fluxcd/golang-with-libgit2
77
LIBGIT2_TAG ?= libgit2-1.3.1
88

9+
# Allows for defining additional Go test args, e.g. '-tags integration'.
10+
GO_TEST_ARGS ?=
11+
912
# Allows for defining additional Docker buildx arguments,
1013
# e.g. '--push'.
1114
BUILD_ARGS ?=
@@ -97,7 +100,10 @@ KUBEBUILDER_ASSETS?="$(shell $(ENVTEST) --arch=$(ENVTEST_ARCH) use -i $(ENVTEST_
97100
test: $(LIBGIT2) install-envtest test-api check-deps ## Run tests
98101
KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) \
99102
GIT_CONFIG_GLOBAL=/dev/null \
100-
go test $(GO_STATIC_FLAGS) ./... -coverprofile cover.out
103+
go test $(GO_STATIC_FLAGS) \
104+
./... \
105+
$(GO_TEST_ARGS) \
106+
-coverprofile cover.out
101107

102108
check-deps:
103109
ifeq ($(shell uname -s),Darwin)

0 commit comments

Comments
 (0)