forked from aristanetworks/goeapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (73 loc) · 2.05 KB
/
Makefile
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#
GO := go
GOTEST_FLAGS :=
TEST_TIMEOUT := 120s
# Code Coverage Related
COV_FILE := coverage.txt
COV_FUNC_OUT := coverage_func.out
COVER_MODE := count
# External Tools
EXTERNAL_TOOLS=\
golang.org/x/tools/cmd/cover \
golang.org/x/tools/cmd/vet
PKGS := $(shell go list ./... | grep -v /examples)
ifndef GOBIN
GOBIN = $(GOPATH)/bin
endif
GOLINT := $(GOBIN)/golint
all: install
install:
$(GO) install $(PKGS)
test: unittest vet
systest:
$(GO) test $(PKGS) $(GOTEST_FLAGS) -timeout=$(TEST_TIMEOUT) -run SystemTest$
unittest:
$(GO) test $(PKGS) $(GOTEST_FLAGS) -timeout=$(TEST_TIMEOUT) -run UnitTest$
updatedeps:
$(GO) get -u github.com/mitchellh/mapstructure
$(GO) get -u github.com/vaughan0/go-ini
coverdata:
@$(GO) tool cover 2>/dev/null; if [ $$? -eq 3 ]; then \
$(GO) get -u golang.org/x/tools/cmd/cover; \
fi
@echo 'mode: $(COVER_MODE)' > $(COV_FILE)
@for dir in $(PKGS); do \
$(GO) test -covermode=$(COVER_MODE) -coverprofile=cov_tmp.out -run UnitTest$ $$dir || exit; \
tail -n +2 cov_tmp.out >> $(COV_FILE) && \
rm -f cov_tmp.out; \
done;
coverage: coverdata
$(GO) tool cover -html=$(COV_FILE)
@rm -f $(COV_FILE)
coveragefunc: coverdata
$(GO) tool cover -func=$(COV_FILE)
#$(GO) tool cover -func=$(COV_FILE) > $(COV_FUNC_OUT)
@rm -f $(COV_FILE)
# see 'go doc cmd/vet'
# 'go tool vet .' recursively descends the directory,
# vetting each package it finds.
vet:
@$(GO) tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \
$(GO) get golang.org/x/tools/cmd/vet; \
fi
@echo "go tool vet ."
@$(GO) tool vet . ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Please check the reported files and constructs for errors "; \
echo "and fix before submitting the code for review."; \
fi
# go get https://github.com/golang/lint
lint:
$(GOLINT) ./...
fmt:
$(GO) fmt ./...
doc:
godoc -http=:6060 -index
clean:
rm -f $(COV_FILE) $(COV_FUNC_OUT)
bootstrap:
@for tool in $(EXTERNAL_TOOLS) ; do \
echo "Installing $$tool" ; \
go get $$tool; \
done
.PHONY: test unittest systest updatedeps coverdata coverage coveragefunc vet lint fmt doc clean bootstrap