-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile.gobuild
52 lines (41 loc) · 1.4 KB
/
Makefile.gobuild
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
CUR_DIR = $(shell pwd)
# ".build" references will cause that package under src/ to be built
%.build:
GOPATH=$(CUR_DIR) go install -v $(subst .build,,$@)
clean:
test ! -d $(CUR_DIR)/pkg || rm -rvf $(CUR_DIR)/pkg; \
test ! -d $(CUR_DIR)/bin || rm -rvf $(CUR_DIR)/bin
spellcheck:
@ ( \
misspell -error `find $(PROJECT_ROOT) -not -path '*/vendor/*' -name '*.go'`; \
);
%.compliant: spellcheck
@ ( \
cd "$(PROJECT_ROOT)/$(subst .compliant,,$@)" >/dev/null || exit 1; \
go fmt || exit 1; \
GOPATH=$(CUR_DIR)/ golint || exit 1; \
GOPATH=$(CUR_DIR)/ go vet || exit 1; \
);
prep_coverage:
@ ( \
echo "mode: count" > coverage.out; \
);
%.test: prep_coverage
@ ( \
safe_nom=`echo "$(subst .test,,$@)" | sed 's/\//_/g'`; \
GOPATH=$(CUR_DIR) go test -v -cover -covermode=count -coverprofile=_coverage_$$safe_nom.out $(subst .test,,$@); \
tail -n +2 _coverage_$$safe_nom.out >> coverage.out; \
rm _coverage_$$safe_nom.out; \
);
%.benchmark:
@ ( \
safe_nom=`echo "$(subst .benchmark,,$@)" | sed 's/\//_/g'`; \
cd "$(PROJECT_ROOT)/$(subst .benchmark,,$@)" >/dev/null || exit 1; \
GOPATH=$(CUR_DIR) go test -run=XXX -v -bench=. -cpuprofile=$(CUR_DIR)/$$safe_nom.cpuprofile -memprofile=$(CUR_DIR)/$$safe_nom.memprofile; \
);
%.test:
GOPATH=$(CUR_DIR) go test $(subst .test,,$@)
check: $(GO_TESTS)
bench: $(GO_BENCH)
coverage: check
GOPATH=$(CUR_DIR)/ go tool cover -html=coverage.out -o coverage.html