From ebd3ad8842c1d1a27c0573d48a9861d73f148407 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Fri, 30 Apr 2021 18:58:26 +0300 Subject: [PATCH] Makefile: add test and cover targets --- .gitignore | 3 +++ Makefile | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 43e1681..2726d2d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,6 @@ testfile .neofs-cli.yml .cache + +coverage.txt +coverage.html diff --git a/Makefile b/Makefile index 77c7436..1797e7a 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ BINDIR = bin DIRS = $(BINDIR) BINS = "$(BINDIR)/neofs-http-gw" -.PHONY: help all dep clean fmts fmt imports test lint docker/lint +.PHONY: help all dep clean fmts fmt imports test cover lint docker/lint # Make all binaries all: $(BINS) @@ -43,6 +43,15 @@ dep: GO111MODULE=on \ go mod tidy -v && echo OK +# Run tests +test: + @go test ./... -cover + +# Run tests with race detection and produce coverage output +cover: + @go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic + @go tool cover -html=coverage.txt -o coverage.html + # Run all code formatters fmts: fmt imports