-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (31 loc) · 1.06 KB
/
Makefile
File metadata and controls
39 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
SHELL := bash
.ONESHELL:
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
GO ?= go
TEST := $(GO) test
TEST_FLAGS ?= -v -tags conformance
TEST_TARGET ?= .
GO111MODULE = on
PROJECT_NAME := $(shell basename $(PWD))
.PHONY: test coverage clean download
download: go.sum
go.sum: go.mod
$(GO) mod tidy
test: go.sum clean
@
CGO_ENABLED=1 $(TEST) $(TEST_FLAGS) -cover $(TEST_TARGET) -json > tests.json || true
CGO_ENABLED=0 $(TEST) $(TEST_FLAGS) -cover $(TEST_TARGET) -json >> tests.json || true
go tool tparse -file tests.json
coverage: go.sum clean
@mkdir ./_coverage
CGO_ENABLED=1 $(TEST) $(TEST_FLAGS) -covermode=count -args -test.gocoverdir="$(PWD)/_coverage" $(TEST_TARGET) > /dev/null || true
CGO_ENABLED=0 $(TEST) $(TEST_FLAGS) -covermode=count -args -test.gocoverdir="$(PWD)/_coverage" $(TEST_TARGET) > /dev/null || true
$(GO) tool covdata percent -i=./_coverage/ -o $(PROJECT_NAME).coverprofile
@$(RM) -r ./_coverage
clean:
@$(RM) -r ./_coverage
@$(RM) -v *.coverprofile
@$(RM) -v tests.json