From b81b50be55658b0b8570b3d1cf42541f2e2a8fed Mon Sep 17 00:00:00 2001 From: silverwind Date: Thu, 5 Nov 2026 23:44:33 +0000 Subject: [PATCH] fix(build): pass `#` test patterns to `go test -run` unchanged (#39977) The `test-backend#` and `test-integration#` targets rewrote every `.` into `/`, because GNU make pattern rules never match goals containing `/`. That broke regexes like `make 'test-backend#TestA.*'`, which silently selected subtests instead. Static pattern rules built from the goals accept `/` directly, so the pattern reaches `go test -run` unchanged. Subtests are now selected like `make 'test-backend#TestA/sub'`, on GNU make 3.81 and 4.x. --- Makefile | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index a13950018f6..173c6683f68 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ DIST := dist DIST_DIRS := $(DIST)/binaries $(DIST)/release - +HASH := \# GO ?= go SHASUM ?= shasum -a 256 @@ -385,10 +385,11 @@ test-check: exit 1; \ fi -.PHONY: test-backend\#% -test-backend\#%: +TEST_BACKEND_GOALS := $(filter test-backend$(HASH)%,$(MAKECMDGOALS)) +.PHONY: $(TEST_BACKEND_GOALS) +$(TEST_BACKEND_GOALS): test-backend$(HASH)%: @echo "Running go test with -tags '$(TAGS)'..." - @$(GO) test $(GOTEST_FLAGS) -tags='$(TAGS)' -run '$(subst .,/,$*)' $(GO_TEST_PACKAGES) + @$(GO) test $(GOTEST_FLAGS) -tags='$(TAGS)' -run '$*' $(GO_TEST_PACKAGES) .PHONY: coverage coverage: @@ -443,9 +444,10 @@ test-integration: $(EXECUTABLE) test-integration-compile: $(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -c -o /dev/null gitea.dev/tests/integration -.PHONY: test-integration\#% -test-integration\#%: $(EXECUTABLE) - $(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -run '$(subst .,/,$*)' gitea.dev/tests/integration +TEST_INTEGRATION_GOALS := $(filter test-integration$(HASH)%,$(MAKECMDGOALS)) +.PHONY: $(TEST_INTEGRATION_GOALS) +$(TEST_INTEGRATION_GOALS): test-integration$(HASH)%: $(EXECUTABLE) + $(GO) test $(GOTEST_FLAGS) -tags '$(TAGS)' -run '$*' gitea.dev/tests/integration .PHONY: test-migration test-migration: migrations.integration.test migrations.individual.test