From 60ef28a1de5f20ae13c4a5a01cb5aa6ee92d31b0 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 20 Jan 2023 17:43:02 +0700 Subject: make: print total test coverage and generate coverage files --- .gitignore | 2 ++ Makefile | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 7366af2..9d97b82 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ ## SPDX-FileCopyrightText: 2022 M. Shulhan ## SPDX-License-Identifier: GPL-3.0-or-later *.json +cover.html +cover.out diff --git a/Makefile b/Makefile index e9c36dd..4869220 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,15 @@ ## SPDX-FileCopyrightText: 2022 M. Shulhan ## SPDX-License-Identifier: GPL-3.0-or-later +COVER_OUT=cover.out +COVER_HTML=cover.html + .PHONY: all test all: test test: - CGO_ENABLED=1 go test -race ./... + CGO_ENABLED=1 go test -race -coverprofile=$(COVER_OUT) ./... + go tool cover -html=$(COVER_OUT) -o $(COVER_HTML) + go tool cover -func=$(COVER_OUT) | tail -n1 fieldalignment ./... -- cgit v1.3