Skip to content

Commit 0f367c7

Browse files
Michal Tichákknopers8
authored andcommitted
added coverage step to makefile
1 parent c9532b3 commit 0f367c7

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ tools
99
bin
1010
wf-unprocessed*
1111
wf-processed*
12-
*.*.old
12+
*.*.old
13+
coverage_results

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ SRC_DIRS := ./apricot ./cmd/* ./core ./coconut ./executor ./common ./configurati
7373
TEST_DIRS := ./configuration/cfgbackend ./configuration/componentcfg ./core/task ./core/workflow
7474
GO_TEST_DIRS := ./core/repos ./core/integration/dcs
7575

76+
coverage:COVERAGE_PREFIX := ./coverage_results
77+
coverage:GOTEST_COVERAGE_FILE := $(COVERAGE_PREFIX)/gotest.out
78+
coverage:GOTEST_COVERAGE_FILE_HTML := $(COVERAGE_PREFIX)/gotest.html
79+
7680
# Use linker flags to provide version/build settings to the target
7781
PROD :=-X=$(REPOPATH)/common/product
7882
EXTLDFLAGS :="-static"
@@ -153,6 +157,15 @@ test:
153157
@echo -e "\n[gotest] \033[1;33mgo test -v\033[0m $(GO_TEST_DIRS)\033[0m"
154158
@$(BUILD_FLAGS) go test -v $(GO_TEST_DIRS)
155159

160+
coverage:
161+
mkdir -p $(COVERAGE_PREFIX)
162+
163+
# -ginkgo.show-node-events is not necessary for coverage as it only increases verbosity of logs
164+
@echo -e "\n[gotest] \033[1;33mgo test -coverprofile=$(GOTEST_COVERAGE_FILE) -v\033[0m $(TEST_DIRS) $(GO_TEST_DIRS)\033[0m"
165+
@$(BUILD_FLAGS) go test -coverprofile=$(GOTEST_COVERAGE_FILE) -v $(TEST_DIRS) $(GO_TEST_DIRS)
166+
@echo -e "\n[gotest] \033[1;33mgo tool cover -html=$(GOTEST_COVERAGE_FILE) -o $(GOTEST_COVERAGE_FILE_HTML)\033[0m"
167+
@go tool cover -html=$(GOTEST_COVERAGE_FILE) -o $(GOTEST_COVERAGE_FILE_HTML)
168+
156169
debugtest:
157170
@echo -e "[Ginkgo] \033[1;33mgo test -v\033[0m $(TEST_DIRS)\033[0m"
158171
@$(BUILD_FLAGS) go test -v $(TEST_DIRS) -ginkgo.v -ginkgo.trace -ginkgo.show-node-events

0 commit comments

Comments
 (0)