Skip to content

Commit 0e21531

Browse files
committed
feat: Improve code coverage reporting.
1 parent 65fa14c commit 0e21531

6 files changed

+232
-1
lines changed

COVERAGE.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Code coverage highlights
2+
3+
## Unit tests
4+
5+
![Unit tests](unit-coverage.png)
6+
7+
## Acceptance tests
8+
9+
![Acceptance tests](acc-coverage.png)

Makefile

+12-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ install-tools-go:
6262
$(GO) install github.com/google/osv-scanner/cmd/osv-scanner@v1
6363
$(GO) install github.com/goph/licensei/cmd/licensei@latest
6464
$(GO) install github.com/nikolaydubina/go-binsize-treemap@latest
65+
$(GO) install github.com/nikolaydubina/go-cover-treemap@latest
6566
$(GO) install github.com/orlangure/gocovsh@latest
6667
$(GO) install github.com/pelletier/go-toml/v2/cmd/tomljson@latest
6768
$(GO) install github.com/securego/gosec/v2/cmd/gosec@latest
@@ -322,13 +323,17 @@ ifeq ($(DEBUG), true)
322323
else
323324
TF_ACC=1 gotestsum --format testname -- -run=TestAcc$(NAME) -count=1 -parallel=$(shell nproc) -timeout 30m -coverpkg=./corefuncprovider/... -coverprofile=__coverage.out -v ./corefuncprovider/...
324325
endif
326+
go-cover-treemap -coverprofile __coverage.out > acc-coverage.svg
327+
rsvg-convert --width=2000 --format=png --output="acc-coverage.png" "acc-coverage.svg"
325328

326329
.PHONY: unit
327330
## unit: [test] Runs unit tests. Set NAME= (without 'Test') to run a specific test by name
328331
unit:
329332
@ $(ECHO) " "
330333
@ $(ECHO) "\033[1;33m=====> Running unit tests...\033[0m"
331334
gotestsum --format testname -- -run=Test$(NAME) -count=1 -parallel=$(shell nproc) -timeout 30s -coverpkg=./corefunc/... -coverprofile=__coverage.out -v ./corefunc/...
335+
go-cover-treemap -coverprofile __coverage.out > unit-coverage.svg
336+
rsvg-convert --width=2000 --format=png --output="unit-coverage.png" "unit-coverage.svg"
332337

333338
.PHONY: examples
334339
## examples: [test] Runs tests for examples. Set NAME= (without 'Example') to run a specific test by name
@@ -347,16 +352,22 @@ fuzz:
347352
.PHONY: quickbench
348353
## quickbench: [test]* Runs the benchmarks with minimal data for a quick check
349354
quickbench:
355+
@ $(ECHO) " "
356+
@ $(ECHO) "\033[1;33m=====> Running "quick" benchmark...\033[0m"
350357
$(GO) test -bench=. -timeout 60m ./corefunc
351358

352359
.PHONY: bench
353360
## bench: [test]* Runs the benchmarks with enough data for analysis with benchstat.
354361
bench:
362+
@ $(ECHO) " "
363+
@ $(ECHO) "\033[1;33m=====> Running "full" benchmark...\033[0m"
355364
$(GO) test -bench=. -count=6 -timeout 60m -benchmem -cpuprofile=__cpu.out -memprofile=__mem.out -trace=__trace.out ./corefunc | tee __bench-$(shell date --utc "+%Y%m%dT%H%M%SZ").out
356365

357366
.PHONY: pgo
358367
## pgo: [test] Runs the benchmarks with enough data for use with Profile-Guided Optimization.
359368
pgo:
369+
@ $(ECHO) " "
370+
@ $(ECHO) "\033[1;33m=====> Running benchmark for PGO data...\033[0m"
360371
TF_ACC=1 go test -run=^TestAcc -count=6 -cpuprofile=default.pgo -parallel=$(shell nproc) -timeout 60m ./corefuncprovider/...
361372

362373
.PHONY: view-cov-cli
@@ -382,7 +393,7 @@ view-mempprof:
382393
.PHONY: view-trace
383394
## view-trace: [test] After running bench, this will launch a browser to view the trace results.
384395
view-trace:
385-
$(GO) tool trace _trace.out
396+
$(GO) tool trace __trace.out
386397

387398
#-------------------------------------------------------------------------------
388399
# Git Tasks

acc-coverage.png

79.5 KB
Loading

acc-coverage.svg

+151
Loading

unit-coverage.png

42.8 KB
Loading

unit-coverage.svg

+60
Loading

0 commit comments

Comments
 (0)