Skip to content

Commit ba93ac0

Browse files
ethervoidpracucci
andauthored
Simplify unit tests runner (cortexproject#4087)
* WIP Signed-off-by: Mario de Frutos <mario@defrutos.org> * Simplify the test targets - Remove the complex tools/test script in favor of simplicity - Created test and cover tasks in the Makefile that will call go test directly Signed-off-by: Mario de Frutos <mario@defrutos.org> * Update Makefile Co-authored-by: Marco Pracucci <marco@pracucci.com> Signed-off-by: Mario de Frutos <mario@defrutos.org> * Remove covermode in test target for the makefile Signed-off-by: Mario de Frutos <mario@defrutos.org> Co-authored-by: Marco Pracucci <marco@pracucci.com>
1 parent ce89b16 commit ba93ac0

File tree

2 files changed

+10
-134
lines changed

2 files changed

+10
-134
lines changed

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# WARNING: do not commit to a repository!
33
-include Makefile.local
44

5-
.PHONY: all test clean images protos exes dist doc clean-doc check-doc
5+
.PHONY: all test cover clean images protos exes dist doc clean-doc check-doc
66
.DEFAULT_GOAL := all
77

88
# Version number
@@ -115,7 +115,7 @@ GOVOLUMES= -v $(shell pwd)/.cache:/go/cache:delegated,z \
115115
-v $(shell pwd)/.pkg:/go/pkg:delegated,z \
116116
-v $(shell pwd):/go/src/github.com/cortexproject/cortex:delegated,z
117117

118-
exes $(EXES) protos $(PROTO_GOS) lint test shell mod-check check-protos web-build web-pre web-deploy doc: build-image/$(UPTODATE)
118+
exes $(EXES) protos $(PROTO_GOS) lint test cover shell mod-check check-protos web-build web-pre web-deploy doc: build-image/$(UPTODATE)
119119
@mkdir -p $(shell pwd)/.pkg
120120
@mkdir -p $(shell pwd)/.cache
121121
@echo
@@ -200,7 +200,14 @@ lint:
200200
kubeval ./k8s/*
201201

202202
test:
203-
./tools/test -netgo
203+
go test -tags netgo -timeout 30m -race -count 1 ./...
204+
205+
cover:
206+
$(eval COVERDIR := $(shell mktemp -d coverage.XXXXXXXXXX))
207+
$(eval COVERFILE := $(shell mktemp $(COVERDIR)/unit.XXXXXXXXXX))
208+
go test -tags netgo -timeout 30m -race -count 1 -coverprofile=$(COVERFILE) ./...
209+
go tool cover -html=$(COVERFILE) -o cover.html
210+
go tool cover -func=cover.html | tail -n1
204211

205212
shell:
206213
bash

tools/test

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)