Skip to content

Commit

Permalink
make: Add PKG and TESTS
Browse files Browse the repository at this point in the history
  • Loading branch information
YakDriver committed Nov 17, 2021
1 parent 2481f6c commit 8d2bc3b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
34 changes: 21 additions & 13 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
SWEEP?=us-west-2,us-east-1,us-east-2
TEST?=./...
SWEEP_DIR?=./internal/sweep
PKG=internal
TEST_COUNT?=1
ACCTEST_TIMEOUT?=180m
ACCTEST_PARALLELISM?=20
SWEEP ?= us-west-2,us-east-1,us-east-2
TEST ?= ./...
SWEEP_DIR ?= ./internal/sweep
PKG_NAME ?= internal
TEST_COUNT ?= 1
ACCTEST_TIMEOUT ?= 180m
ACCTEST_PARALLELISM ?= 20

ifneq ($(origin PKG), undefined)
PKG_NAME = internal/service/$(PKG)
endif

ifneq ($(origin TESTS), undefined)
TESTARGS = -run='$(TESTS)'
endif

default: build

Expand Down Expand Up @@ -34,11 +42,11 @@ testacc: fmtcheck
echo "See the contributing guide for more information: https://github.com/hashicorp/terraform-provider-aws/blob/main/docs/contributing/running-and-writing-acceptance-tests.md"; \
exit 1; \
fi
TF_ACC=1 go test ./$(PKG)/... -v -count $(TEST_COUNT) -parallel $(ACCTEST_PARALLELISM) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT)
TF_ACC=1 go test ./$(PKG_NAME)/... -v -count $(TEST_COUNT) -parallel $(ACCTEST_PARALLELISM) $(TESTARGS) -timeout $(ACCTEST_TIMEOUT)

fmt:
@echo "==> Fixing source code with gofmt..."
gofmt -s -w ./$(PKG) $(filter-out ./providerlint/go% ./providerlint/README.md ./providerlint/vendor, $(wildcard ./providerlint/*))
gofmt -s -w ./$(PKG_NAME) $(filter-out ./providerlint/go% ./providerlint/README.md ./providerlint/vendor, $(wildcard ./providerlint/*))

# Currently required by tf-deploy compile
fmtcheck:
Expand Down Expand Up @@ -87,7 +95,7 @@ lint: golangci-lint providerlint importlint

golangci-lint:
@echo "==> Checking source code with golangci-lint..."
@golangci-lint run ./$(PKG)/...
@golangci-lint run ./$(PKG_NAME)/...

providerlint:
@echo "==> Checking source code with providerlint..."
Expand All @@ -114,11 +122,11 @@ providerlint:
-XR005=false \
-XS001=false \
-XS002=false \
./$(PKG)/service/... ./$(PKG)/provider/...
./$(PKG_NAME)/service/... ./$(PKG_NAME)/provider/...

importlint:
@echo "==> Checking source code with importlint..."
@impi --local . --scheme stdThirdPartyLocal ./$(PKG)/...
@impi --local . --scheme stdThirdPartyLocal ./$(PKG_NAME)/...

tools:
cd providerlint && go install .
Expand All @@ -133,7 +141,7 @@ tools:
test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./$(PKG)"; \
echo " make test-compile TEST=./$(PKG_NAME)"; \
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing/contribution-checklists.md
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ More details about this code generation, including fixes for potential error mes
}
```

- Verify all acceptance testing passes for the resource (e.g., `make testacc TESTARGS='-run=TestAccEKSCluster_' PKG=internal/service/eks`)
- Verify all acceptance testing passes for the resource (e.g., `make testacc TESTS=TestAccEKSCluster_ PKG=eks`)

### Resource Tagging Documentation Implementation

Expand Down Expand Up @@ -792,7 +792,7 @@ resource "aws_{service}_tag" "test" {
}
```

- Run `make testacc TESTARGS='-run=TestAcc{Service}Tags_' PKG=internal/service/{Service}` and ensure there are no failures.
- Run `make testacc TESTS=TestAcc{Service}Tags_ PKG={Service}` and ensure there are no failures.
- Create `website/docs/r/{service}_tag.html.markdown` with initial documentation similar to the following:

``````markdown
Expand Down
6 changes: 3 additions & 3 deletions docs/contributing/running-and-writing-acceptance-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Tests can then be run by specifying a regular expression defining the tests to
run and the package in which the tests are defined:

```sh
$ make testacc TESTARGS='-run=TestAccCloudWatchDashboard_updateName' PKG=internal/service/cloudwatch
$ make testacc TESTS=TestAccCloudWatchDashboard_updateName PKG=cloudwatch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudwatch/... -v -count 1 -parallel 20 -run=TestAccCloudWatchDashboard_updateName -timeout 180m
=== RUN TestAccCloudWatchDashboard_updateName
Expand All @@ -111,7 +111,7 @@ write the regular expression. For example, to run all tests of the
can start testing like this:

```sh
$ make testacc TESTARGS='-run=TestAccCloudWatchDashboard' PKG=internal/service/cloudwatch
$ make testacc TESTS=TestAccCloudWatchDashboard PKG=cloudwatch
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cloudwatch/... -v -count 1 -parallel 20 -run=TestAccCloudWatchDashboard -timeout 180m
=== RUN TestAccCloudWatchDashboard_basic
Expand Down Expand Up @@ -141,7 +141,7 @@ Please Note: On macOS 10.14 and later (and some Linux distributions), the defaul
Certain testing requires multiple AWS accounts. This additional setup is not typically required and the testing will return an error (shown below) if your current setup does not have the secondary AWS configuration:

```console
$ make testacc TESTARGS='-run=TestAccRDSInstance_DBSubnetGroupName_ramShared' PKG=internal/service/rds
$ make testacc TESTS=TestAccRDSInstance_DBSubnetGroupName_ramShared PKG=rds
TF_ACC=1 go test ./internal/service/rds/... -v -count 1 -parallel 20 -run=TestAccRDSInstance_DBSubnetGroupName_ramShared -timeout 180m
=== RUN TestAccRDSInstance_DBSubnetGroupName_ramShared
=== PAUSE TestAccRDSInstance_DBSubnetGroupName_ramShared
Expand Down

0 comments on commit 8d2bc3b

Please sign in to comment.