github.com/ojiry/terraform@v0.8.2-0.20161218223921-e50cec712c4a/Makefile (about)

     1  TEST?=$$(go list ./... | grep -v '/terraform/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..." && \
    33  		go test -tags 'core' $(TESTARGS) $(shell go list ./... | grep -v -E 'terraform/(builtin|vendor)')
    34  
    35  # Shorthand for building and installing just one plugin for local testing.
    36  # Run as (for example): make plugin-dev PLUGIN=provider-aws
    37  plugin-dev: generate
    38  	go install github.com/hashicorp/terraform/builtin/bins/$(PLUGIN)
    39  	mv $(GOPATH)/bin/$(PLUGIN) $(GOPATH)/bin/terraform-$(PLUGIN)
    40  
    41  # test runs the unit tests
    42  test: fmtcheck errcheck generate
    43  	TF_ACC= go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4
    44  
    45  # testacc runs acceptance tests
    46  testacc: fmtcheck generate
    47  	@if [ "$(TEST)" = "./..." ]; then \
    48  		echo "ERROR: Set TEST to a specific package. For example,"; \
    49  		echo "  make testacc TEST=./builtin/providers/aws"; \
    50  		exit 1; \
    51  	fi
    52  	TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
    53  
    54  test-compile: fmtcheck generate
    55  	@if [ "$(TEST)" = "./..." ]; then \
    56  		echo "ERROR: Set TEST to a specific package. For example,"; \
    57  		echo "  make test-compile TEST=./builtin/providers/aws"; \
    58  		exit 1; \
    59  	fi
    60  	go test -c $(TEST) $(TESTARGS)
    61  
    62  # testrace runs the race checker
    63  testrace: fmtcheck generate
    64  	TF_ACC= go test -race $(TEST) $(TESTARGS)
    65  
    66  cover:
    67  	@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
    68  		go get -u golang.org/x/tools/cmd/cover; \
    69  	fi
    70  	go test $(TEST) -coverprofile=coverage.out
    71  	go tool cover -html=coverage.out
    72  	rm coverage.out
    73  
    74  # vet runs the Go source code static analysis tool `vet` to find
    75  # any common errors.
    76  vet:
    77  	@echo "go tool vet $(VETARGS) ."
    78  	@go tool vet $(VETARGS) $$(ls -d */ | grep -v vendor) ; if [ $$? -eq 1 ]; then \
    79  		echo ""; \
    80  		echo "Vet found suspicious constructs. Please check the reported constructs"; \
    81  		echo "and fix them if necessary before submitting the code for review."; \
    82  		exit 1; \
    83  	fi
    84  
    85  # generate runs `go generate` to build the dynamically generated
    86  # source files.
    87  generate:
    88  	@which stringer > /dev/null; if [ $$? -ne 0 ]; then \
    89  	  go get -u golang.org/x/tools/cmd/stringer; \
    90  	fi
    91  	go generate $$(go list ./... | grep -v /terraform/vendor/)
    92  	@go fmt command/internal_plugin_list.go > /dev/null
    93  
    94  fmt:
    95  	gofmt -w $(GOFMT_FILES)
    96  
    97  fmtcheck:
    98  	@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
    99  
   100  errcheck:
   101  	@sh -c "'$(CURDIR)/scripts/errcheck.sh'"
   102  
   103  .PHONY: bin default generate test vet fmt fmtcheck tools