-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
52 lines (37 loc) · 1.49 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
COVERDIR=$(CURDIR)/.cover
COVERAGEFILE=$(COVERDIR)/cover.out
EXAMPLES=$(shell ls ./examples/)
$(EXAMPLES): %:
$(eval EXAMPLE=$*)
@:
run:
@test ! -z "$(EXAMPLE)" && go run ./examples/$(EXAMPLE) || echo "Usage: make [$(EXAMPLES)] run"
build:
@test -d ./examples && $(foreach example,$(EXAMPLES),go build "-ldflags=$(LDFLAGS)" -o ./bin/$(example) -v ./examples/$(example) &&) :
vet:
@go vet ./...
fmt:
@go fmt ./...
test:
@go run github.com/onsi/ginkgo/ginkgo --failFast ./...
test-watch:
@go run github.com/onsi/ginkgo/ginkgo watch -cover -r ./...
bench:
@mkdir -p ./bench-results
@go test -benchmem -run=github.com/lab259/hermes -bench=$(TARGET)$$ -test.parallel=1 -cpuprofile ./bench-results/cpu.prof -memprofile ./bench-results/mem.prof
plot-cpu:
@go tool pprof -http :8080 ./bench-results/cpu.prof
plot-mem:
@go tool pprof -alloc_space -http :8080 ./bench-results/mem.prof
coverage-ci:
@mkdir -p $(COVERDIR)
@go run github.com/onsi/ginkgo/ginkgo -r -covermode=count --cover --trace ./...
@echo "mode: count" > "${COVERAGEFILE}"
@find . -type f -name '*.coverprofile' -exec cat {} \; -exec rm -f {} \; | grep -h -v "^mode:" >> ${COVERAGEFILE}
coverage: coverage-ci
@sed -i -e "s|_$(CURDIR)/|./|g" "${COVERAGEFILE}"
@cp "${COVERAGEFILE}" coverage.txt
coverage-html: coverage
@go tool cover -html="${COVERAGEFILE}" -o .cover/report.html
@xdg-open .cover/report.html 2> /dev/null > /dev/null
.PHONY: run build fmt vet test test-watch coverage coverage-ci coverage-html bench plot-cpu plot-mem