github.com/jrasell/terraform@v0.6.17-0.20160523115548-2652f5232949/Makefile (about)

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