github.com/paultyng/terraform@v0.6.11-0.20180227224804-66ff8f8bed40/Makefile (about)

     1  TEST?=./...
     2  GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
     3  
     4  default: test
     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 building and installing just one plugin for local testing.
    24  # Run as (for example): make plugin-dev PLUGIN=provider-aws
    25  plugin-dev: generate
    26  	go install github.com/hashicorp/terraform/builtin/bins/$(PLUGIN)
    27  	mv $(GOPATH)/bin/$(PLUGIN) $(GOPATH)/bin/terraform-$(PLUGIN)
    28  
    29  # test runs the unit tests
    30  # we run this one package at a time here because running the entire suite in
    31  # one command creates memory usage issues when running in Travis-CI.
    32  test: fmtcheck generate
    33  	go list $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=60s -parallel=4
    34  
    35  # testacc runs acceptance tests
    36  testacc: fmtcheck generate
    37  	@if [ "$(TEST)" = "./..." ]; then \
    38  		echo "ERROR: Set TEST to a specific package. For example,"; \
    39  		echo "  make testacc TEST=./builtin/providers/aws"; \
    40  		exit 1; \
    41  	fi
    42  	TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
    43  
    44  # e2etest runs the end-to-end tests against a generated Terraform binary
    45  # The TF_ACC here allows network access, but does not require any special
    46  # credentials since the e2etests use local-only providers such as "null".
    47  e2etest: generate
    48  	TF_ACC=1 go test -v ./command/e2etest
    49  
    50  test-compile: fmtcheck generate
    51  	@if [ "$(TEST)" = "./..." ]; then \
    52  		echo "ERROR: Set TEST to a specific package. For example,"; \
    53  		echo "  make test-compile TEST=./builtin/providers/aws"; \
    54  		exit 1; \
    55  	fi
    56  	go test -c $(TEST) $(TESTARGS)
    57  
    58  # testrace runs the race checker
    59  testrace: fmtcheck generate
    60  	TF_ACC= go test -race $(TEST) $(TESTARGS)
    61  
    62  cover:
    63  	@go tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
    64  		go get -u golang.org/x/tools/cmd/cover; \
    65  	fi
    66  	go test $(TEST) -coverprofile=coverage.out
    67  	go tool cover -html=coverage.out
    68  	rm coverage.out
    69  
    70  # generate runs `go generate` to build the dynamically generated
    71  # source files.
    72  generate:
    73  	@which stringer > /dev/null; if [ $$? -ne 0 ]; then \
    74  	  go get -u golang.org/x/tools/cmd/stringer; \
    75  	fi
    76  	go generate ./...
    77  	@go fmt command/internal_plugin_list.go > /dev/null
    78  
    79  fmt:
    80  	gofmt -w $(GOFMT_FILES)
    81  
    82  fmtcheck:
    83  	@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
    84  
    85  vendor-status:
    86  	@govendor status
    87  
    88  # disallow any parallelism (-j) for Make. This is necessary since some
    89  # commands during the build process create temporary files that collide
    90  # under parallel conditions.
    91  .NOTPARALLEL:
    92  
    93  .PHONY: bin cover default dev e2etest fmt fmtcheck generate plugin-dev quickdev test-compile test testacc testrace tools vendor-status