Skip to content

Commit

Permalink
Simplify unit tests runner (#4087)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
ethervoid and pracucci authored May 5, 2021
1 parent ce89b16 commit ba93ac0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 134 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# WARNING: do not commit to a repository!
-include Makefile.local

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

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

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

test:
./tools/test -netgo
go test -tags netgo -timeout 30m -race -count 1 ./...

cover:
$(eval COVERDIR := $(shell mktemp -d coverage.XXXXXXXXXX))
$(eval COVERFILE := $(shell mktemp $(COVERDIR)/unit.XXXXXXXXXX))
go test -tags netgo -timeout 30m -race -count 1 -coverprofile=$(COVERFILE) ./...
go tool cover -html=$(COVERFILE) -o cover.html
go tool cover -func=cover.html | tail -n1

shell:
bash
Expand Down
131 changes: 0 additions & 131 deletions tools/test

This file was deleted.

0 comments on commit ba93ac0

Please sign in to comment.