From 25440792f32fd5d8b0762490035dc077e7fd2094 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 26 Dec 2025 00:29:01 +0200 Subject: [PATCH 1/8] chore: Update GNUmakefile to enhance test command functionality - Renamed TESTARGS to COVERAGEARGS for clarity. - Added variable references and examples for test-specific variables. - Improved test and acceptance test commands to include branch information and coverage options. Signed-off-by: Timo Sand --- GNUmakefile | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index b4e651ed50..f1b27fab5e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,27 @@ SWEEP?=repositories,teams WEBSITE_REPO=github.com/hashicorp/terraform-website PKG_NAME=github -export TESTARGS=-race -coverprofile=coverage.txt -covermode=atomic +COVERAGEARGS?=-race -coverprofile=coverage.txt -covermode=atomic + +# VARIABLE REFERENCE: +# +# Test-specific variables: +# T= - Test name pattern (e.g., TestAccGithubRepository) +# COV=true - Enable coverage +# +# +# Examples: +# make test T=TestMigrate # Run only schema migration unit tests +# make test COV=true # Run all unit tests with coverage +# make testacc T=TestAccGithubRepositories\$$ COV=true # Run only acceptance tests for a specific Test name with coverage + +ifneq ($(origin T), undefined) + RUNARGS = -run='$(T)' +endif + +ifneq ($(origin COV), undefined) + RUNARGS += $(COVERAGEARGS) +endif default: build @@ -27,11 +47,20 @@ lintcheck: golangci-lint run ./... test: - CGO_ENABLED=0 go test ./... - # commenting this out for release tooling, please run testacc instead + @branch=$$(git rev-parse --abbrev-ref HEAD); \ + printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿" + go test $(TEST) \ + -timeout=30s \ + -parallel=4 \ + -v \ + -run '^Test[^A]|^TestA[^c]|^TestAc[^c]' \ + $(RUNARGS) $(TESTARGS) \ + -count 1; testacc: - TF_ACC=1 CGO_ENABLED=0 go test -run "^TestAcc*" $(TEST) -v $(TESTARGS) -timeout 120m -count=1 + @branch=$$(git rev-parse --abbrev-ref HEAD); \ + printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿" + TF_ACC=1 CGO_ENABLED=0 go test $(TEST) -v $(RUNARGS) $(TESTARGS) -timeout 120m -count=1 test-compile: @if [ "$(TEST)" = "./..." ]; then \ From 4f17f9d0b6c2847730be25cead4f15cbb244dd1b Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 26 Dec 2025 00:35:16 +0200 Subject: [PATCH 2/8] Ensure `make testacc` only ever runs `TestAcc` prefixed tests Signed-off-by: Timo Sand --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index f1b27fab5e..2942e22951 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -60,7 +60,7 @@ test: testacc: @branch=$$(git rev-parse --abbrev-ref HEAD); \ printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿" - TF_ACC=1 CGO_ENABLED=0 go test $(TEST) -v $(RUNARGS) $(TESTARGS) -timeout 120m -count=1 + TF_ACC=1 CGO_ENABLED=0 go test $(TEST) -v -run '^TestAcc' $(RUNARGS) $(TESTARGS) -timeout 120m -count=1 test-compile: @if [ "$(TEST)" = "./..." ]; then \ From 4f1dd9af2d7ee2d78580b1fc7ce4e624d88fbb05 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Wed, 31 Dec 2025 23:06:27 +0200 Subject: [PATCH 3/8] Move `CGO_ENABLED` as a global export Signed-off-by: Timo Sand --- GNUmakefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 2942e22951..3bad74bb39 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,6 +4,7 @@ WEBSITE_REPO=github.com/hashicorp/terraform-website PKG_NAME=github COVERAGEARGS?=-race -coverprofile=coverage.txt -covermode=atomic +export CGO_ENABLED=0 # VARIABLE REFERENCE: # @@ -32,7 +33,7 @@ tools: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 build: lintcheck - CGO_ENABLED=0 go build -ldflags="-s -w" ./... + go build -ldflags="-s -w" ./... fmt: @echo "==> Fixing source code formatting..." @@ -68,7 +69,7 @@ test-compile: echo " make test-compile TEST=./$(PKG_NAME)"; \ exit 1; \ fi - CGO_ENABLED=0 go test -c $(TEST) $(TESTARGS) + go test -c $(TEST) $(TESTARGS) sweep: @echo "WARNING: This will destroy infrastructure. Use only in development accounts." From 1b5b02bae2f4a63a09a27caae766445b22a3492c Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Sun, 4 Jan 2026 21:50:58 +0200 Subject: [PATCH 4/8] Remove leftover inlined `CGO_ENABLED` Signed-off-by: Timo Sand --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 3bad74bb39..5d053d35cd 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -61,7 +61,7 @@ test: testacc: @branch=$$(git rev-parse --abbrev-ref HEAD); \ printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿" - TF_ACC=1 CGO_ENABLED=0 go test $(TEST) -v -run '^TestAcc' $(RUNARGS) $(TESTARGS) -timeout 120m -count=1 + TF_ACC=1 go test $(TEST) -v -run '^TestAcc' $(RUNARGS) $(TESTARGS) -timeout 120m -count=1 test-compile: @if [ "$(TEST)" = "./..." ]; then \ From 7b84e4298fce8489a74d355e2671c66676d0de1b Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Thu, 8 Jan 2026 23:51:24 +0200 Subject: [PATCH 5/8] Revert global `CGO_ENABLED=0` export Signed-off-by: Timo Sand --- GNUmakefile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 5d053d35cd..5044a604a2 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -4,7 +4,6 @@ WEBSITE_REPO=github.com/hashicorp/terraform-website PKG_NAME=github COVERAGEARGS?=-race -coverprofile=coverage.txt -covermode=atomic -export CGO_ENABLED=0 # VARIABLE REFERENCE: # @@ -33,7 +32,7 @@ tools: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 build: lintcheck - go build -ldflags="-s -w" ./... + CGO_ENABLED=0 go build -ldflags="-s -w" ./... fmt: @echo "==> Fixing source code formatting..." @@ -49,8 +48,8 @@ lintcheck: test: @branch=$$(git rev-parse --abbrev-ref HEAD); \ - printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿" - go test $(TEST) \ + printf "==> Running unit tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿" + CGO_ENABLED=0 go test $(TEST) \ -timeout=30s \ -parallel=4 \ -v \ @@ -61,7 +60,7 @@ test: testacc: @branch=$$(git rev-parse --abbrev-ref HEAD); \ printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿" - TF_ACC=1 go test $(TEST) -v -run '^TestAcc' $(RUNARGS) $(TESTARGS) -timeout 120m -count=1 + TF_ACC=1 CGO_ENABLED=0 go test $(TEST) -v -run '^TestAcc' $(RUNARGS) $(TESTARGS) -timeout 120m -count=1 test-compile: @if [ "$(TEST)" = "./..." ]; then \ @@ -69,7 +68,7 @@ test-compile: echo " make test-compile TEST=./$(PKG_NAME)"; \ exit 1; \ fi - go test -c $(TEST) $(TESTARGS) + CGO_ENABLED=0 go test -c $(TEST) $(TESTARGS) sweep: @echo "WARNING: This will destroy infrastructure. Use only in development accounts." From ea2e337b163bd78135a30b4b6be4a4490cff4938 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Thu, 8 Jan 2026 23:52:37 +0200 Subject: [PATCH 6/8] Set `TEST` to package name to get real-time output for each test execution Signed-off-by: Timo Sand --- GNUmakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 5044a604a2..2453d36cd4 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,7 +1,7 @@ -TEST?=$$(go list ./... |grep -v 'vendor') SWEEP?=repositories,teams -WEBSITE_REPO=github.com/hashicorp/terraform-website PKG_NAME=github +TEST?=./$(PKG_NAME)/... +WEBSITE_REPO=github.com/hashicorp/terraform-website COVERAGEARGS?=-race -coverprofile=coverage.txt -covermode=atomic From 517ecc7364f4004961b8bc56ae8c642b202db124 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 9 Jan 2026 00:02:10 +0200 Subject: [PATCH 7/8] Use `-skip` in unit test target Signed-off-by: Timo Sand --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index 2453d36cd4..32589d29c1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -53,7 +53,7 @@ test: -timeout=30s \ -parallel=4 \ -v \ - -run '^Test[^A]|^TestA[^c]|^TestAc[^c]' \ + -skip '^TestAcc' \ $(RUNARGS) $(TESTARGS) \ -count 1; From 64c8c1003c27e22b4a54834c6382503430b7a483 Mon Sep 17 00:00:00 2001 From: Timo Sand Date: Fri, 9 Jan 2026 23:21:09 +0200 Subject: [PATCH 8/8] Remove unused target Signed-off-by: Timo Sand --- GNUmakefile | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 32589d29c1..4d39de3b47 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -62,14 +62,6 @@ testacc: printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿" TF_ACC=1 CGO_ENABLED=0 go test $(TEST) -v -run '^TestAcc' $(RUNARGS) $(TESTARGS) -timeout 120m -count=1 -test-compile: - @if [ "$(TEST)" = "./..." ]; then \ - echo "ERROR: Set TEST to a specific package. For example,"; \ - echo " make test-compile TEST=./$(PKG_NAME)"; \ - exit 1; \ - fi - CGO_ENABLED=0 go test -c $(TEST) $(TESTARGS) - sweep: @echo "WARNING: This will destroy infrastructure. Use only in development accounts." go test $(TEST) -v -sweep=$(SWEEP) $(SWEEPARGS) @@ -92,4 +84,4 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO))) endif @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME) -.PHONY: build test testacc fmt lint lintcheck tools test-compile website website-lint website-test sweep +.PHONY: build test testacc fmt lint lintcheck tools website website-lint website-test sweep