From 3c550af069f30bed846ac012457a88b65223306d Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 6 Apr 2024 16:39:26 +0700 Subject: all: run test with coverage Running "make test" now print and generate the coverage in text and HTML format. --- .gitignore | 2 ++ Makefile | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..18aad36 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/cover.html +/cover.txt diff --git a/Makefile b/Makefile index d7ccb28..0735845 100644 --- a/Makefile +++ b/Makefile @@ -2,15 +2,24 @@ ## Use of this source code is governed by a BSD-style ## license that can be found in the LICENSE file. -.PHONY: all install +.PHONY: all +all: test lint install -all: test check install +COVER_TXT:=cover.txt +COVER_HTML:=cover.html + +.PHONY: test +test: CGO_ENABLED=1 test: - go test -v ./... + go test -failfast -timeout=1m -race -coverprofile=$(COVER_TXT) ./... + go tool cover -html=$(COVER_TXT) -o $(COVER_HTML) + -check: +.PHONY: lint +lint: golangci-lint run ./... +.PHONY: install install: go install ./cmd/kamusku -- cgit v1.3