23
23
24
24
GOTEST_MIN = go test -v -timeout 30s
25
25
GOTEST = $(GOTEST_MIN ) -race
26
- GOTEST_WITH_COVERAGE = $(GOTEST ) -coverprofile=coverage.txt -covermode=atomic
26
+ GOTEST_WITH_COVERAGE = $(GOTEST ) -coverprofile=coverage.out -covermode=atomic -coverpkg=./...
27
27
28
28
.DEFAULT_GOAL := precommit
29
29
@@ -47,12 +47,16 @@ precommit: dependabot-check license-check generate build lint test
47
47
48
48
.PHONY : test-with-coverage
49
49
test-with-coverage :
50
- set -e; for dir in $( ALL_COVERAGE_MOD_DIRS) ; do \
50
+ set -e; \
51
+ printf " " > coverage.txt; \
52
+ for dir in $( ALL_COVERAGE_MOD_DIRS) ; do \
51
53
echo " go test ./... + coverage in $$ {dir}" ; \
52
54
(cd " $$ {dir}" && \
53
55
$(GOTEST_WITH_COVERAGE ) ./... && \
54
- go tool cover -html=coverage.txt -o coverage.html); \
55
- done
56
+ go tool cover -html=coverage.out -o coverage.html); \
57
+ [ -f " $$ {dir}/coverage.out" ] && cat " $$ {dir}/coverage.out" >> coverage.txt; \
58
+ done ; \
59
+ sed -i.bak -e ' 2,$$ { /^mode: /d; }' coverage.txt && rm coverage.txt.bak
56
60
57
61
.PHONY : ci
58
62
ci : precommit check-clean-work-tree test-with-coverage test-386
@@ -65,7 +69,7 @@ test-gocql:
65
69
CMD=cassandra IMG_NAME=cass-integ ./tools/wait.sh; \
66
70
(cd instrumentation/github.com/gocql/gocql/otelgocql && \
67
71
$(GOTEST_WITH_COVERAGE ) . && \
68
- go tool cover -html=coverage.txt -o coverage.html); \
72
+ go tool cover -html=coverage.out -o coverage.html); \
69
73
docker stop cass-integ; \
70
74
fi
71
75
@@ -77,7 +81,7 @@ test-mongo-driver:
77
81
CMD=mongo IMG_NAME=mongo-integ ./tools/wait.sh; \
78
82
(cd instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo && \
79
83
$(GOTEST_WITH_COVERAGE ) . && \
80
- go tool cover -html=coverage.txt -o coverage.html); \
84
+ go tool cover -html=coverage.out -o coverage.html); \
81
85
docker stop mongo-integ; \
82
86
fi
83
87
@@ -89,7 +93,7 @@ test-gomemcache:
89
93
CMD=gomemcache IMG_NAME=gomemcache-integ ./tools/wait.sh; \
90
94
(cd instrumentation/github.com/bradfitz/gomemcache/memcache/otelmemcache && \
91
95
$(GOTEST_WITH_COVERAGE ) . && \
92
- go tool cover -html=coverage.txt -o coverage.html); \
96
+ go tool cover -html=coverage.out -o coverage.html); \
93
97
docker stop gomemcache-integ ; \
94
98
fi
95
99
0 commit comments