From f7844fa30d0d3e877aa889e4f1c22efa4c4dacc8 Mon Sep 17 00:00:00 2001 From: black-desk Date: Thu, 19 Oct 2023 23:56:08 +0800 Subject: [PATCH] build: add coverage profile Signed-off-by: black-desk --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 21e6c34..cd13c68 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,8 @@ SHELL ?= sh CGROUPFS ?= /tmp/io.github.black-desk.cgtproxy-test/cgroupfs +COVERAGE ?= /tmp/io.github.black-desk.cgtproxy-test/coverage.out + .PHONY: test test: $(SYSTEMD_RUN) \ @@ -35,7 +37,7 @@ test: mount -t cgroup2 none $(CGROUPFS) && \ export CGTPROXY_TEST_CGROUP_ROOT=$(CGROUPFS) && \ export CGTPROXY_TEST_NFTMAN=1 && \ - $(GO) test ./... --tags=$(GOTAGS) -v --ginkgo.vv\ + $(GO) test ./... --tags=$(GOTAGS) -v --ginkgo.vv -coverprofile=$(COVERAGE) \ " PREFIX ?= /usr/local @@ -47,3 +49,9 @@ install: $(DESTDIR)$(PREFIX)/bin/cgtproxy install -m644 -D misc/systemd/cgtproxy.service \ $(DESTDIR)$(PREFIX)/lib/systemd/system/cgtproxy.service + +COVERAGE_REPORT ?= /tmp/io.github.black-desk.cgtproxy-test/coverage.txt + +.PHONY: test-coverage +test-coverage: + go tool cover -func=$(COVERAGE) -o=$(COVERAGE_REPORT)