github.com/candidpartners/terraform@v0.9.5-0.20171005231213-29f5f88820f6/Makefile (about) 1 TEST?=$$(go list ./... | grep -v '/terraform/vendor/' | grep -v '/builtin/bins/') 2 GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor) 3 4 default: test vet 5 6 tools: 7 go get -u github.com/kardianos/govendor 8 go get -u golang.org/x/tools/cmd/stringer 9 go get -u golang.org/x/tools/cmd/cover 10 11 # bin generates the releaseable binaries for Terraform 12 bin: fmtcheck generate 13 @TF_RELEASE=1 sh -c "'$(CURDIR)/scripts/build.sh'" 14 15 # dev creates binaries for testing Terraform locally. These are put 16 # into ./bin/ as well as $GOPATH/bin 17 dev: fmtcheck generate 18 @TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" 19 20 quickdev: generate 21 @TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" 22 23 # Shorthand for quickly building the core of Terraform. Note that some 24 # changes will require a rebuild of everything, in which case the dev 25 # target should be used. 26 core-dev: generate 27 go install -tags 'core' github.com/hashicorp/terraform 28 29 # Shorthand for quickly testing the core of Terraform (i.e. "not providers") 30 core-test: generate 31 @echo "Testing core packages..." && \ 32 go test -tags 'core' $(TESTARGS) $(shell go list ./... | grep -v -E 'terraform/(builtin|vendor)') 33 34 # Shorthand for building and installing just one plugin for local testing. 35 # Run as (for example): make plugin-dev PLUGIN=provider-aws 36 plugin-dev: generate 37 go install github.com/hashicorp/terraform/builtin/bins/$(PLUGIN) 38 mv $(GOPATH)/bin/$(PLUGIN) $(GOPATH)/bin/terraform-$(PLUGIN) 39 40 # test runs the unit tests 41 test: fmtcheck errcheck generate 42 go test -i $(TEST) || exit 1 43 echo $(TEST) | \ 44 xargs -t -n4 go test $(TESTARGS) -timeout=60s -parallel=4 45 46 # testacc runs acceptance tests 47 testacc: fmtcheck generate 48 @if [ "$(TEST)" = "./..." ]; then \ 49 echo "ERROR: Set TEST to a specific package. For example,"; \ 50 echo " make testacc TEST=./builtin/providers/aws"; \ 51 exit 1; \ 52 fi 53 TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m 54 55 test-compile: fmtcheck generate 56 @if [ "$(TEST)" = "./..." ]; then \ 57 echo "ERROR: Set TEST to a specific package. For example,"; \ 58 echo " make test-compile TEST=./builtin/providers/aws"; \ 59 exit 1; \ 60 fi 61 go test -c $(TEST) $(TESTARGS) 62 63 # testrace runs the race checker 64 testrace: fmtcheck generate 65 TF_ACC= go test -race $(TEST) $(TESTARGS) 66 67 cover: 68 @go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \ 69 go get -u golang.org/x/tools/cmd/cover; \ 70 fi 71 go test $(TEST) -coverprofile=coverage.out 72 go tool cover -html=coverage.out 73 rm coverage.out 74 75 # vet runs the Go source code static analysis tool `vet` to find 76 # any common errors. 77 vet: 78 @echo 'go vet $$(go list ./... | grep -v /terraform/vendor/)' 79 @go vet $$(go list ./... | grep -v /terraform/vendor/) ; if [ $$? -eq 1 ]; then \ 80 echo ""; \ 81 echo "Vet found suspicious constructs. Please check the reported constructs"; \ 82 echo "and fix them if necessary before submitting the code for review."; \ 83 exit 1; \ 84 fi 85 86 # generate runs `go generate` to build the dynamically generated 87 # source files. 88 generate: 89 @which stringer > /dev/null; if [ $$? -ne 0 ]; then \ 90 go get -u golang.org/x/tools/cmd/stringer; \ 91 fi 92 go generate $$(go list ./... | grep -v /terraform/vendor/) 93 @go fmt command/internal_plugin_list.go > /dev/null 94 95 fmt: 96 gofmt -w $(GOFMT_FILES) 97 98 fmtcheck: 99 @sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'" 100 101 errcheck: 102 @sh -c "'$(CURDIR)/scripts/errcheck.sh'" 103 104 vendor-status: 105 @govendor status 106 107 # disallow any parallelism (-j) for Make. This is necessary since some 108 # commands during the build process create temporary files that collide 109 # under parallel conditions. 110 .NOTPARALLEL: 111 112 .PHONY: bin core-dev core-test cover default dev errcheck fmt fmtcheck generate plugin-dev quickdev test-compile test testacc testrace tools vendor-status vet