-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
131 lines (90 loc) · 2.94 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# Original from github.com/pkg/errors
PKG_ERR2 := github.com/lainio/err2
PKG_ASSERT := github.com/lainio/err2/assert
PKG_TRY := github.com/lainio/err2/try
PKG_DEBUG := github.com/lainio/err2/internal/debug
PKG_HANDLER := github.com/lainio/err2/internal/handler
PKG_STR := github.com/lainio/err2/internal/str
PKG_X := github.com/lainio/err2/internal/x
PKGS := $(PKG_ERR2) $(PKG_ASSERT) $(PKG_TRY) $(PKG_DEBUG) $(PKG_HANDLER) $(PKG_STR) $(PKG_X)
SRCDIRS := $(shell go list -f '{{.Dir}}' $(PKGS))
GO ?= go
TEST_ARGS ?= -benchmem
# -"gcflags '-N -l'" both optimization & inlining disabled
# GO ?= go1.20rc2
check: lint vet gofmt test
test_err2:
$(GO) test $(TEST_ARGS) $(PKG_ERR2)
test_assert:
$(GO) test $(TEST_ARGS) $(PKG_ASSERT)
test_try:
$(GO) test $(TEST_ARGS) $(PKG_TRY)
test_debug:
$(GO) test $(TEST_ARGS) $(PKG_DEBUG)
test_handler:
$(GO) test $(TEST_ARGS) $(PKG_HANDLER)
test_str:
$(GO) test $(TEST_ARGS) $(PKG_STR)
test_x:
$(GO) test $(TEST_ARGS) $(PKG_X)
testv:
$(GO) test -v $(TEST_ARGS) $(PKGS)
test:
$(GO) test $(TEST_ARGS) $(PKGS)
escape_err2:
$(GO) test -c -gcflags=-m=2 $(PKG_ERR2) 2>&1 | ag 'escape'
inline_err2:
$(GO) test -c -gcflags=-m=2 $(PKG_ERR2) 2>&1 | ag 'inlin'
tinline_err2:
$(GO) test -c -gcflags=-m=2 $(PKG_ERR2) 2>&1 | ag 'inlin' | ag 'err2_test'
inline_handler:
$(GO) test -c -gcflags=-m=2 $(PKG_HANDLER) 2>&1 | ag 'inlin'
tinline_handler:
$(GO) test -c -gcflags=-m=2 $(PKG_HANDLER) 2>&1 | ag 'inlin'
bench:
$(GO) test $(TEST_ARGS) -bench=. $(PKGS)
bench_goid:
$(GO) test $(TEST_ARGS) -bench='BenchmarkGoid' $(PKG_ASSERT)
bench_reca:
$(GO) test $(TEST_ARGS) -bench='BenchmarkRecursion.*' $(PKG_ERR2)
bench_out:
$(GO) test $(TEST_ARGS) -bench='BenchmarkTryOut_.*' $(PKG_ERR2)
bench_go:
$(GO) test $(TEST_ARGS) -bench='BenchmarkTry_StringGenerics' $(PKG_ERR2)
bench_that:
$(GO) test $(TEST_ARGS) -bench='BenchmarkThat.*' $(PKG_ASSERT)
bench_copy:
$(GO) test $(TEST_ARGS) -bench='Benchmark_CopyBuffer' $(PKG_TRY)
bench_rech:
$(GO) test $(TEST_ARGS) -bench='BenchmarkRecursionWithTryAnd_HeavyPtrPtr_Defer' $(PKG_ERR2)
bench_rece:
$(GO) test $(TEST_ARGS) -bench='BenchmarkRecursionWithTryAnd_Empty_Defer' $(PKG_ERR2)
bench_rec:
$(GO) test $(TEST_ARGS) -bench='BenchmarkRecursionWithOldErrorIfCheckAnd_Defer' $(PKG_ERR2)
bench_err2:
$(GO) test $(TEST_ARGS) -bench=. $(PKG_ERR2)
bench_assert:
$(GO) test $(TEST_ARGS) -bench=. $(PKG_ASSERT)
bench_str:
$(GO) test $(TEST_ARGS) -bench=. $(PKG_STR)
bench_x:
$(GO) test $(TEST_ARGS) -bench=. $(PKG_X)
vet: | test
$(GO) vet $(PKGS)
gofmt:
@echo Checking code is gofmted
@test -z "$(shell gofmt -s -l -d -e $(SRCDIRS) | tee /dev/stderr)"
godoc:
@GO111MODULE=off godoc -http=0.0.0.0:6060
test_cov_out:
go test -p 1 -failfast \
-coverpkg=$(PKG_ERR2)/... \
-coverprofile=coverage.txt \
-covermode=atomic \
./...
test_cov: test_cov_out
go tool cover -html=coverage.txt -o=coverage.html
firefox ./coverage.html 1>&- 2>&- &
lint:
@golangci-lint run
.PHONY: check