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.
This commit is contained in:
silverwind
2026-11-05 23:44:33 +00:00
committed by GitHub
parent c62db5b2a3
commit b81b50be55

View File

@@ -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