From e0cf99c53dd329c42c501866a35cfa343254e658 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Fri, 18 Jan 2019 03:17:58 -0800 Subject: [PATCH] Makefile: use go-acc for coverage --- Makefile | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index c19c70a0..53b7a262 100644 --- a/Makefile +++ b/Makefile @@ -4,11 +4,13 @@ ESCPKG := github.com\/lightningnetwork\/lnd BTCD_PKG := github.com/btcsuite/btcd GOVERALLS_PKG := github.com/mattn/goveralls LINT_PKG := gopkg.in/alecthomas/gometalinter.v2 +GOACC_PKG := github.com/ory/go-acc GO_BIN := ${GOPATH}/bin BTCD_BIN := $(GO_BIN)/btcd GOVERALLS_BIN := $(GO_BIN)/goveralls LINT_BIN := $(GO_BIN)/gometalinter.v2 +GOACC_BIN := $(GO_BIN)/go-acc BTCD_DIR :=${GOPATH}/src/$(BTCD_PKG) @@ -21,6 +23,8 @@ BTCD_COMMIT := $(shell cat go.mod | \ awk -F " " '{ print $$2 }' | \ awk -F "/" '{ print $$1 }') +GOACC_COMMIT := ddc355013f90fea78d83d3a6c71f1d37ac07ecd5 + GOBUILD := GO111MODULE=on go build -v GOINSTALL := GO111MODULE=on go install -v GOTEST := GO111MODULE=on go test -v @@ -39,23 +43,6 @@ include make/testing_flags.mk DEV_TAGS := $(if ${tags},$(DEV_TAGS) ${tags},$(DEV_TAGS)) -COVER = for dir in $(GOLISTCOVER); do \ - $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" \ - -covermode=count \ - -coverprofile=$$dir/profile.tmp $$dir; \ - \ - if [ $$? != 0 ] ; \ - then \ - exit 1; \ - fi ; \ - \ - if [ -f $$dir/profile.tmp ]; then \ - cat $$dir/profile.tmp | \ - tail -n +2 >> profile.cov; \ - $(RM) $$dir/profile.tmp; \ - fi \ - done - LINT = $(LINT_BIN) \ --disable-all \ --enable=gofmt \ @@ -88,6 +75,11 @@ $(LINT_BIN): @$(call print, "Fetching gometalinter.v2") GO111MODULE=off go get -u $(LINT_PKG) +$(GOACC_BIN): + @$(call print, "Fetching go-acc") + go get -u -v $(GOACC_PKG)@$(GOACC_COMMIT) + $(GOINSTALL) $(GOACC_PKG) + btcd: @$(call print, "Installing btcd.") GO111MODULE=on go get -v github.com/btcsuite/btcd/@$(BTCD_COMMIT) @@ -130,10 +122,9 @@ unit: btcd @$(call print, "Running unit tests.") $(UNIT) -unit-cover: +unit-cover: $(GOACC_BIN) @$(call print, "Running unit coverage tests.") - echo "mode: count" > profile.cov - $(COVER) + $(GOACC_BIN) $$(go list ./... | grep -v lnrpc) -- -test.tags="$(DEV_TAGS) $(LOG_TAGS)" unit-race: @$(call print, "Running unit race tests.") @@ -141,7 +132,7 @@ unit-race: goveralls: $(GOVERALLS_BIN) @$(call print, "Sending coverage report.") - $(GOVERALLS_BIN) -coverprofile=profile.cov -service=travis-ci + $(GOVERALLS_BIN) -coverprofile=coverage.txt -service=travis-ci travis-race: btcd unit-race