Skip to content

Commit 6cc91c1

Browse files
committed
Fixing coverage report to aggregate results from all packages.
1 parent 1aed181 commit 6cc91c1

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

Makefile

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
DEPS=go list -f '{{range .TestImports}}{{.}} {{end}}' ./...
1+
.PHONY: update-deps install-deps fmt lint golint test test-with-coverage
2+
# TODO: When Go 1.9 is released vendor folder should be ignored automatically
3+
PACKAGES=`go list ./... | grep -v vendor | grep -v mocks`
24

35
update-deps:
46
rm -rf Godeps
@@ -9,22 +11,30 @@ update-deps:
911
install-deps:
1012
go get github.com/tools/godep
1113
godep restore
12-
$(DEPS) | xargs -n1 go get -d
1314

1415
fmt:
15-
bash -c 'go list ./... | grep -v vendor | xargs -n1 go fmt'
16+
for pkg in ${PACKAGES}; do \
17+
go fmt $$pkg; \
18+
done;
1619

1720
lint:
18-
bash -c 'gometalinter --disable-all -E vet -E gofmt -E misspell -E ineffassign -E goimports -E deadcode --tests --vendor ./...'
21+
gometalinter --disable-all -E vet -E gofmt -E misspell -E ineffassign -E goimports -E deadcode --tests --vendor ./...
1922

2023
golint:
21-
# TODO: When Go 1.9 is released vendor folder should be ignored automatically
22-
bash -c 'go list ./... | grep -v vendor | grep -v mocks | xargs -n1 golint'
24+
for pkg in ${PACKAGES}; do \
25+
golint $$pkg; \
26+
done;
2327

2428
test:
25-
# TODO: When Go 1.9 is released vendor folder should be ignored automatically
26-
bash -c 'go list ./... | grep -v vendor | xargs -n1 go test -timeout=10s'
29+
for pkg in ${PACKAGES}; do \
30+
go test $$pkg; \
31+
done;
2732

2833
test-with-coverage:
29-
# TODO: When Go 1.9 is released vendor folder should be ignored automatically
30-
bash -c 'go list ./... | grep -v vendor | xargs -n1 go test -timeout=10s -coverprofile=coverage.txt -covermode=set'
34+
echo "" > coverage.out
35+
echo "mode: set" > coverage-all.out
36+
for pkg in ${PACKAGES}; do \
37+
go test -coverprofile=coverage.out -covermode=set $$pkg; \
38+
tail -n +2 coverage.out >> coverage-all.out; \
39+
done;
40+
#go tool cover -html=coverage-all.out

0 commit comments

Comments
 (0)