github.com/jd3nn1s/terraform@v0.9.6-0.20170906225847-13878347b7a1/Makefile (about)

     1  TEST?=./...
     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 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 test -i $(TEST) || exit 1
    34  	go list $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=60s -parallel=4
    35  
    36  # testacc runs acceptance tests
    37  testacc: fmtcheck generate
    38  	@if [ "$(TEST)" = "./..." ]; then \
    39  		echo "ERROR: Set TEST to a specific package. For example,"; \
    40  		echo "  make testacc TEST=./builtin/providers/aws"; \
    41  		exit 1; \
    42  	fi
    43  	TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m
    44  
    45  test-compile: fmtcheck generate
    46  	@if [ "$(TEST)" = "./..." ]; then \
    47  		echo "ERROR: Set TEST to a specific package. For example,"; \
    48  		echo "  make test-compile TEST=./builtin/providers/aws"; \
    49  		exit 1; \
    50  	fi
    51  	go test -c $(TEST) $(TESTARGS)
    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 vet ./...'
    69  	@go vet ./... ; 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 > /dev/null; if [ $$? -ne 0 ]; then \
    80  	  go get -u golang.org/x/tools/cmd/stringer; \
    81  	fi
    82  	go generate ./...
    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  vendor-status:
    92  	@govendor status
    93  
    94  # disallow any parallelism (-j) for Make. This is necessary since some
    95  # commands during the build process create temporary files that collide
    96  # under parallel conditions.
    97  .NOTPARALLEL:
    98  
    99  .PHONY: bin cover default dev fmt fmtcheck generate plugin-dev quickdev test-compile test testacc testrace tools vendor-status vet