github.com/newrelic/newrelic-client-go@v1.1.0/build/test.mk (about)

     1  #
     2  # Makefile fragment for Testing
     3  #
     4  
     5  GO           ?= go
     6  TEST_RUNNER  ?= gotestsum
     7  
     8  COVERAGE_DIR ?= ./coverage/
     9  COVERMODE    ?= atomic
    10  SRCDIR       ?= .
    11  GO_PKGS      ?= $(shell $(GO) list ./... | grep -v -e "/vendor/" -e "/example")
    12  
    13  PROJECT_MODULE ?= $(shell $(GO) list -m)
    14  
    15  LDFLAGS_UNIT ?= '-X $(PROJECT_MODULE)/internal/version.GitTag=$(PROJECT_VER_TAGGED)'
    16  
    17  test: test-only
    18  test-only: test-unit test-integration
    19  
    20  test-unit: tools
    21  	@echo "=== $(PROJECT_NAME) === [ test-unit        ]: running unit tests..."
    22  	@mkdir -p $(COVERAGE_DIR)
    23  	@$(TEST_RUNNER) -f testname --junitfile $(COVERAGE_DIR)/unit.xml -- -v -ldflags=$(LDFLAGS_UNIT) -parallel 4 -tags unit -covermode=$(COVERMODE) -coverprofile $(COVERAGE_DIR)/unit.tmp $(GO_PKGS)
    24  
    25  test-integration: tools
    26  	@echo "=== $(PROJECT_NAME) === [ test-integration ]: running integration tests..."
    27  	@mkdir -p $(COVERAGE_DIR)
    28  	$(TEST_RUNNER) -f testname --junitfile $(COVERAGE_DIR)/integration.xml --rerun-fails=3 --packages "$(GO_PKGS)" -- -v -parallel 4 -tags integration -covermode=$(COVERMODE) -coverprofile $(COVERAGE_DIR)/integration.tmp $(GO_PKGS)
    29  
    30  #
    31  # Coverage
    32  #
    33  cover-clean:
    34  	@echo "=== $(PROJECT_NAME) === [ cover-clean      ]: removing coverage files..."
    35  	@rm -rfv $(COVERAGE_DIR)/*
    36  
    37  cover-report:
    38  	@echo "=== $(PROJECT_NAME) === [ cover-report     ]: generating coverage results..."
    39  	@mkdir -p $(COVERAGE_DIR)
    40  	@echo 'mode: $(COVERMODE)' > $(COVERAGE_DIR)/coverage.out
    41  	@cat $(COVERAGE_DIR)/*.tmp | grep -v 'mode: $(COVERMODE)' >> $(COVERAGE_DIR)/coverage.out || true
    42  	@$(GO) tool cover -html=$(COVERAGE_DIR)/coverage.out -o $(COVERAGE_DIR)/coverage.html
    43  	@echo "=== $(PROJECT_NAME) === [ cover-report     ]:     $(COVERAGE_DIR)coverage.html"
    44  
    45  cover-view: cover-report
    46  	@$(GO) tool cover -html=$(COVERAGE_DIR)/coverage.out
    47  
    48  .PHONY: test test-only test-unit test-integration cover-report cover-view