From 4a426be6b8fe0d3e54a8b8269b9848be4df27fe4 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Fri, 20 May 2016 09:40:52 -0400 Subject: Adding generation of coverage files to build (#3066) --- .gitignore | 3 +++ Makefile | 43 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 39 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 1fba4cd03..08c2665f8 100644 --- a/.gitignore +++ b/.gitignore @@ -71,6 +71,9 @@ api/data/* enterprise +cover.out +ecover.out + .agignore .ctags tags diff --git a/Makefile b/Makefile index 584b84cd2..4b6fbe274 100644 --- a/Makefile +++ b/Makefile @@ -153,15 +153,34 @@ check-style: check-client-style check-server-style test-server: start-docker prepare-enterprise @echo Running server tests - $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=340s ./api || exit 1 - $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s ./model || exit 1 - $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=180s ./store || exit 1 - $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./utils || exit 1 - $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s ./web || exit 1 + rm -f cover.out + echo "mode: count" > cover.out + + $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=340s -covermode=count -coverprofile=capi.out ./api || exit 1 + $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=12s -covermode=count -coverprofile=cmodel.out ./model || exit 1 + $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=180s -covermode=count -coverprofile=cstore.out ./store || exit 1 + $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s -covermode=count -coverprofile=cutils.out ./utils || exit 1 + $(GO) test $(GOFLAGS) -run=$(TESTS) -test.v -test.timeout=120s -covermode=count -coverprofile=cweb.out ./web || exit 1 + + tail -n +2 capi.out >> cover.out + tail -n +2 cmodel.out >> cover.out + tail -n +2 cstore.out >> cover.out + tail -n +2 cutils.out >> cover.out + tail -n +2 cweb.out >> cover.out + rm -f capi.out cmodel.out cstore.out cutils.out cweb.out + ifeq ($(BUILD_ENTERPRISE_READY),true) @echo Running Enterprise tests - $(GO) test $(GOFLAGS) -run=$(TESTS) -c ./enterprise/ldap && ./ldap.test -test.v -test.timeout=120s || exit 1 - $(GO) test $(GOFLAGS) -run=$(TESTS) -c ./enterprise/compliance && ./compliance.test -test.v -test.timeout=120s || exit 1 + + rm -f ecover.out + echo "mode: count" > ecover.out + + $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/ldap && ./ldap.test -test.v -test.timeout=120s -test.coverprofile=cldap.out || exit 1 + $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -c ./enterprise/compliance && ./compliance.test -test.v -test.timeout=120s -test.coverprofile=ccompliance.out || exit 1 + + tail -n +2 cldap.out >> ecover.out + tail -n +2 ccompliance.out >> ecover.out + rm -f cldap.out ccompliance.out rm -r ldap.test rm -r compliance.test endif @@ -176,6 +195,12 @@ test-client: start-docker prepare-enterprise test: test-server test-client +cover: + @echo Opening coverage info in browser. If this failed run make test first + + $(GO) tool cover -html=cover.out + $(GO) tool cover -html=ecover.out + .prebuild: @echo Preparation for running go code go get $(GOFLAGS) github.com/Masterminds/glide @@ -330,6 +355,10 @@ clean: stop-docker rm -f api/mattermost.log rm -f .prepare-go rm -f enterprise + rm -f cover.out + rm -f ecover.out + rm -f *.out + rm -f *.test nuke: clean clean-docker @echo BOOM -- cgit v1.2.3-1-g7c22