From b6d768d36f57704546a3da4dfac0f993b2be2436 Mon Sep 17 00:00:00 2001 From: miagilepner Date: Tue, 2 May 2023 14:46:13 +0200 Subject: [PATCH] Fix testonly flag in Makefile (#20457) --- Makefile | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 6dc764f62..d33f0e89d 100644 --- a/Makefile +++ b/Makefile @@ -30,16 +30,16 @@ default: dev bin: prep @CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS) ui' sh -c "'$(CURDIR)/scripts/build.sh'" -testonly: - $(eval BUILD_TAGS += testonly) - # dev creates binaries for testing Vault locally. These are put # into ./bin/ as well as $GOPATH/bin -dev: prep testonly +dev: BUILD_TAGS+=testonly +dev: prep @CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS)' VAULT_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'" -dev-ui: assetcheck prep testonly +dev-ui: BUILD_TAGS+=testonly +dev-ui: assetcheck prep @CGO_ENABLED=$(CGO_ENABLED) BUILD_TAGS='$(BUILD_TAGS) ui' VAULT_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'" -dev-dynamic: prep testonly +dev-dynamic: BUILD_TAGS+=testonly +dev-dynamic: prep @CGO_ENABLED=1 BUILD_TAGS='$(BUILD_TAGS)' VAULT_DEV_BUILD=1 sh -c "'$(CURDIR)/scripts/build.sh'" # *-mem variants will enable memory profiling which will write snapshots of heap usage @@ -54,14 +54,17 @@ dev-dynamic-mem: dev-dynamic # Creates a Docker image by adding the compiled linux/amd64 binary found in ./bin. # The resulting image is tagged "vault:dev". -docker-dev: prep testonly +docker-dev: BUILD_TAGS+=testonly +docker-dev: prep docker build --build-arg VERSION=$(GO_VERSION_MIN) --build-arg BUILD_TAGS="$(BUILD_TAGS)" -f scripts/docker/Dockerfile -t vault:dev . -docker-dev-ui: prep testonly +docker-dev-ui: BUILD_TAGS+=testonly +docker-dev-ui: prep docker build --build-arg VERSION=$(GO_VERSION_MIN) --build-arg BUILD_TAGS="$(BUILD_TAGS)" -f scripts/docker/Dockerfile.ui -t vault:dev-ui . # test runs the unit tests and vets the code -test: prep testonly +test: BUILD_TAGS+=testonly +test: prep @CGO_ENABLED=$(CGO_ENABLED) \ VAULT_ADDR= \ VAULT_TOKEN= \ @@ -69,13 +72,15 @@ test: prep testonly VAULT_ACC= \ $(GO_CMD) test -tags='$(BUILD_TAGS)' $(TEST) $(TESTARGS) -timeout=$(TEST_TIMEOUT) -parallel=20 -testcompile: prep testonly +testcompile: BUILD_TAGS+=testonly +testcompile: prep @for pkg in $(TEST) ; do \ $(GO_CMD) test -v -c -tags='$(BUILD_TAGS)' $$pkg -parallel=4 ; \ done # testacc runs acceptance tests -testacc: prep testonly +testacc: BUILD_TAGS+=testonly +testacc: prep @if [ "$(TEST)" = "./..." ]; then \ echo "ERROR: Set TEST to a specific package"; \ exit 1; \ @@ -83,7 +88,8 @@ testacc: prep testonly VAULT_ACC=1 $(GO_CMD) test -tags='$(BUILD_TAGS)' $(TEST) -v $(TESTARGS) -timeout=$(EXTENDED_TEST_TIMEOUT) # testrace runs the race checker -testrace: prep testonly +testrace: BUILD_TAGS+=testonly +testrace: prep @CGO_ENABLED=1 \ VAULT_ADDR= \ VAULT_TOKEN= \