github.com/danrjohnson/terraform@v0.7.0-rc2.0.20160627135212-d0fc1fa086ff/Makefile (about)

     1  TEST?=$$(go list ./... | grep -v '/vendor/' | grep -v '/builtin/bins/')
     2  VETARGS?=-all
     3  GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
     4  
     5  default: test vet
     6  
     7  tools:
     8  	go get -u github.com/kardianos/govendor
     9  	go get -u golang.org/x/tools/cmd/stringer
    10  	go get -u golang.org/x/tools/cmd/cover
    11  
    12  # bin generates the releaseable binaries for Terraform
    13  bin: fmtcheck generate
    14  	@TF_RELEASE=1 sh -c "'$(CURDIR)/scripts/build.sh'"
    15  
    16  # dev creates binaries for testing Terraform locally. These are put
    17  # into ./bin/ as well as $GOPATH/bin
    18  dev: fmtcheck generate
    19  	@TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'"
    20  
    21  quickdev: generate
    22  	@TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'"
    23  
    24  # Shorthand for quickly building the core of Terraform. Note that some
    25  # changes will require a rebuild of everything, in which case the dev
    26  # target should be used.
    27  core-dev: generate
    28  	go install -tags 'core' github.com/hashicorp/terraform
    29  
    30  # Shorthand for quickly testing the core of Terraform (i.e. "not providers")
    31  core-test: generate
    32  	@echo "Testing core packages..." && go test -tags 'core' $(TESTARGS) $(shell go list ./... | grep -v -E '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 generate
    42  	TF_ACC= go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4
    43  
    44  # testacc runs acceptance tests
    45  testacc: fmtcheck generate
    46  	@if [ "$(TEST)" = "./..." ]; then \
    47  		echo "ERROR: Set TEST to a specific package. For example,"; \
    48  		echo "  make testacc TEST=./builtin/providers/aws"; \
    49  		exit 1; \
    50  	fi
    51  	TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
    52  
    53  # testrace runs the race checker
    54  testrace: fmtcheck generate
    55  	TF_ACC= go test -race $(TEST) $(TESTARGS)
    56  
    57  cover:
    58  	@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
    59  		go get -u golang.org/x/tools/cmd/cover; \
    60  	fi
    61  	go test $(TEST) -coverprofile=coverage.out
    62  	go tool cover -html=coverage.out
    63  	rm coverage.out
    64  
    65  # vet runs the Go source code static analysis tool `vet` to find
    66  # any common errors.
    67  vet:
    68  	@echo "go tool vet $(VETARGS) ."
    69  	@go tool vet $(VETARGS) $$(ls -d */ | grep -v vendor) ; if [ $$? -eq 1 ]; then \
    70  		echo ""; \
    71  		echo "Vet found suspicious constructs. Please check the reported constructs"; \
    72  		echo "and fix them if necessary before submitting the code for review."; \
    73  		exit 1; \
    74  	fi
    75  
    76  # generate runs `go generate` to build the dynamically generated
    77  # source files.
    78  generate:
    79  	@which stringer ; if [ $$? -ne 0 ]; then \
    80  	  go get -u golang.org/x/tools/cmd/stringer; \
    81  	fi
    82  	go generate $$(go list ./... | grep -v /vendor/)
    83  	@go fmt command/internal_plugin_list.go > /dev/null
    84  
    85  fmt:
    86  	gofmt -w $(GOFMT_FILES)
    87  
    88  fmtcheck:
    89  	@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
    90  
    91  .PHONY: bin default generate test vet fmt fmtcheck tools