1- TEST? =$$(go list ./... |grep -v 'vendor' )
2- WEBSITE_REPO =github.com/hashicorp/terraform-website
1+ SWEEP? =repositories,teams
32PKG_NAME =github
3+ TEST? =./$(PKG_NAME ) /...
4+ WEBSITE_REPO =github.com/hashicorp/terraform-website
5+
6+ COVERAGEARGS? =-race -coverprofile=coverage.txt -covermode=atomic
7+
8+ # VARIABLE REFERENCE:
9+ #
10+ # Test-specific variables:
11+ # T=<pattern> - Test name pattern (e.g., TestAccGithubRepository)
12+ # COV=true - Enable coverage
13+ #
14+ #
15+ # Examples:
16+ # make test T=TestMigrate # Run only schema migration unit tests
17+ # make test COV=true # Run all unit tests with coverage
18+ # make testacc T=TestAccGithubRepositories\$$ COV=true # Run only acceptance tests for a specific Test name with coverage
419
5- export TESTARGS =-race -coverprofile=coverage.txt -covermode=atomic
20+ ifneq ($(origin T ) , undefined)
21+ RUNARGS = -run='$(T)'
22+ endif
23+
24+ ifneq ($(origin COV ) , undefined)
25+ RUNARGS += $(COVERAGEARGS)
26+ endif
627
728default : build
829
@@ -26,19 +47,24 @@ lintcheck:
2647 golangci-lint run ./...
2748
2849test :
29- CGO_ENABLED=0 go test ./...
30- # commenting this out for release tooling, please run testacc instead
50+ @branch=$$(git rev-parse --abbrev-ref HEAD ) ; \
51+ printf " ==> Running unit tests on branch: \033[1m%s\033[0m...\n" " 🌿 $$ branch 🌿"
52+ CGO_ENABLED=0 go test $(TEST ) \
53+ -timeout=30s \
54+ -parallel=4 \
55+ -v \
56+ -skip ' ^TestAcc' \
57+ $(RUNARGS ) $(TESTARGS ) \
58+ -count 1;
3159
3260testacc :
33- TF_ACC=1 CGO_ENABLED=0 go test -run " ^TestAcc*" $(TEST ) -v $(TESTARGS ) -timeout 120m -count=1
61+ @branch=$$(git rev-parse --abbrev-ref HEAD ) ; \
62+ printf " ==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" " 🌿 $$ branch 🌿"
63+ TF_ACC=1 CGO_ENABLED=0 go test $(TEST ) -v -run ' ^TestAcc' $(RUNARGS ) $(TESTARGS ) -timeout 120m -count=1
3464
35- test-compile :
36- @if [ " $( TEST) " = " ./..." ]; then \
37- echo " ERROR: Set TEST to a specific package. For example," ; \
38- echo " make test-compile TEST=./$( PKG_NAME) " ; \
39- exit 1; \
40- fi
41- CGO_ENABLED=0 go test -c $(TEST ) $(TESTARGS )
65+ sweep :
66+ @echo " WARNING: This will destroy infrastructure. Use only in development accounts."
67+ go test $(TEST ) -v -sweep=$(SWEEP ) $(SWEEPARGS )
4268
4369website :
4470ifeq (,$(wildcard $(GOPATH ) /src/$(WEBSITE_REPO ) ) )
@@ -58,4 +84,4 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
5884endif
5985 @$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
6086
61- .PHONY : build test testacc fmt lint lintcheck tools test-compile website website-lint website-test
87+ .PHONY : build test testacc fmt lint lintcheck tools website website-lint website-test sweep
0 commit comments