Skip to content

Commit e6007fe

Browse files
committed
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 <timo.sand@f-secure.com>
1 parent 3109c39 commit e6007fe

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

GNUmakefile

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,27 @@ TEST?=$$(go list ./... |grep -v 'vendor')
22
WEBSITE_REPO=github.com/hashicorp/terraform-website
33
PKG_NAME=github
44

5-
export TESTARGS=-race -coverprofile=coverage.txt -covermode=atomic
5+
COVERAGEARGS?=-race -coverprofile=coverage.txt -covermode=atomic
6+
7+
# VARIABLE REFERENCE:
8+
#
9+
# Test-specific variables:
10+
# T=<pattern> - Test name pattern (e.g., TestAccGithubRepository)
11+
# COV=true - Enable coverage
12+
#
13+
#
14+
# Examples:
15+
# make test T=TestMigrate # Run only schema migration unit tests
16+
# make test COV=true # Run all unit tests with coverage
17+
# make testacc T=TestAccGithubRepositories\$$ COV=true # Run only acceptance tests for a specific Test name with coverage
18+
19+
ifneq ($(origin T), undefined)
20+
RUNARGS = -run='$(T)'
21+
endif
22+
23+
ifneq ($(origin COV), undefined)
24+
RUNARGS += $(COVERAGEARGS)
25+
endif
626

727
default: build
828

@@ -26,11 +46,20 @@ lintcheck:
2646
golangci-lint run ./...
2747

2848
test:
29-
CGO_ENABLED=0 go test ./...
30-
# commenting this out for release tooling, please run testacc instead
49+
@branch=$$(git rev-parse --abbrev-ref HEAD); \
50+
printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿"
51+
go test $(TEST) \
52+
-timeout=30s \
53+
-parallel=4 \
54+
-v \
55+
-run '^Test[^A]|^TestA[^c]|^TestAc[^c]' \
56+
$(RUNARGS) $(TESTARGS) \
57+
-count 1;
3158

3259
testacc:
33-
TF_ACC=1 CGO_ENABLED=0 go test -run "^TestAcc*" $(TEST) -v $(TESTARGS) -timeout 120m -count=1
60+
@branch=$$(git rev-parse --abbrev-ref HEAD); \
61+
printf "==> Running acceptance tests on branch: \033[1m%s\033[0m...\n" "🌿 $$branch 🌿"
62+
TF_ACC=1 CGO_ENABLED=0 go test $(TEST) -v $(RUNARGS) $(TESTARGS) -timeout 120m -count=1
3463

3564
test-compile:
3665
@if [ "$(TEST)" = "./..." ]; then \

0 commit comments

Comments
 (0)