@@ -8,6 +8,7 @@ DEST := $(shell echo "$(DESTDIR)/$(PREFIX)" | sed 's:///*:/:g; s://*$$::')
88BINDIR ?= /usr/local/bin
99OUTDIR ?= $(CURDIR ) /_output
1010OS_OUTDIR ?= $(OUTDIR ) /os
11+ COVERAGE_DIR ?= $(CURDIR ) /cov
1112REPORT_DIR ?= $(CURDIR ) /reports
1213RUN_ID ?= $(GITHUB_RUN_ID )
1314RUN_ATTEMPT ?= $(GITHUB_RUN_ATTEMPT )
@@ -174,8 +175,9 @@ finch-unix: finch-all
174175finch-native : GO_BUILD_TAGS += native
175176finch-native : finch-all
176177
178+ E2E_COVERAGE ?=
177179finch-all :
178- $(GO ) build -ldflags $(LDFLAGS ) -tags " $( GO_BUILD_TAGS) " -o $(OUTDIR ) /bin/$(BINARYNAME ) $(PACKAGE ) /cmd/finch
180+ $(GO ) build $( if $( E2E_COVERAGE ) ,-cover) -ldflags $(LDFLAGS ) -tags " $( GO_BUILD_TAGS) " -o $(OUTDIR ) /bin/$(BINARYNAME ) $(PACKAGE ) /cmd/finch
179181
180182.PHONY : release
181183release : check-licenses all download-licenses
@@ -185,7 +187,7 @@ $(OUTDIR)/finch-daemon/finch@.service:
185187
186188.PHONY : coverage
187189coverage :
188- go test $(shell go list ./... | grep -v e2e | grep -v benchmark | grep -v mocks) -coverprofile=test-coverage.out
190+ go test $(shell go list ./... | grep -v e2e | grep -v benchmark | grep -v mocks)
189191 go tool cover -html=test-coverage.out
190192
191193.PHONY : download-licenses
@@ -299,6 +301,10 @@ test-unit:
299301# Container tests and VM tests can be run in any order, but they must be run sequentially.
300302# For more details, see the package-level comment of the e2e package.
301303
304+ .PHONY : create-coverage-dir
305+ create-coverage-dir :
306+ mkdir -p $(COVERAGE_DIR )
307+
302308.PHONY : create-report-dir
303309create-report-dir :
304310 mkdir -p $(REPORT_DIR )
@@ -307,16 +313,20 @@ create-report-dir:
307313test-e2e : test-e2e-vm-serial test-e2e-container
308314
309315.PHONY : test-e2e-vm-serial
310- test-e2e-vm-serial : create-report-dir
311- go test -ldflags $(LDFLAGS ) -timeout 2h ./e2e/vm -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR ) /$(RUN_ID ) -$(RUN_ATTEMPT ) -e2e-vm-serial-report.json --installed=" $( INSTALLED) "
316+ test-e2e-vm-serial : create-report-dir create-coverage-dir
317+ FINCH_GOCOVERDIR= $( COVERAGE_DIR ) go test -coverpkg=./... - ldflags $(LDFLAGS ) -timeout 2h ./e2e/vm -test.v -test.gocoverdir= $( COVERAGE_DIR ) -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR ) /$(RUN_ID ) -$(RUN_ATTEMPT ) -e2e-vm-serial-report.json --installed=" $( INSTALLED) "
312318
313319.PHONY : test-e2e-container
314- test-e2e-container : create-report-dir
315- go test -ldflags $(LDFLAGS ) -timeout 2h ./e2e/container -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR ) /$(RUN_ID ) -$(RUN_ATTEMPT ) -e2e-container-report.json --installed=" $( INSTALLED) "
320+ test-e2e-container : create-report-dir create-coverage-dir
321+ FINCH_GOCOVERDIR= $( COVERAGE_DIR ) go test -coverpkg=./... - ldflags $(LDFLAGS ) -timeout 2h ./e2e/container -test.v -test.gocoverdir= $( COVERAGE_DIR ) -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR ) /$(RUN_ID ) -$(RUN_ATTEMPT ) -e2e-container-report.json --installed=" $( INSTALLED) "
316322
317323.PHONY : test-e2e-vm
318- test-e2e-vm : create-report-dir
319- go test -ldflags $(LDFLAGS ) -timeout 2h ./e2e/vm -test.v -ginkgo.v -ginkgo.timeout=2h -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR ) /$(RUN_ID ) -$(RUN_ATTEMPT ) -e2e-vm-report.json --installed=" $( INSTALLED) " --registry=" $( REGISTRY) "
324+ test-e2e-vm : create-report-dir create-coverage-dir
325+ FINCH_GOCOVERDIR=$(COVERAGE_DIR ) go test -coverpkg=./... -ldflags $(LDFLAGS ) -timeout 2h ./e2e/vm -test.v -test.gocoverdir=$(COVERAGE_DIR ) -ginkgo.v -ginkgo.timeout=2h -ginkgo.focus " updates init-only config values when values are changed after init" -ginkgo.flake-attempts=3 -ginkgo.json-report=$(REPORT_DIR ) /$(RUN_ID ) -$(RUN_ATTEMPT ) -e2e-vm-report.json --installed=" $( INSTALLED) " --registry=" $( REGISTRY) "
326+
327+ .PHONY : test-e2e-cov
328+ test-e2e-cov :
329+ go tool covdata percent -i=$(COVERAGE_DIR ) -pkg=$(shell go list ./... | grep -v e2e | grep -v benchmark | grep -v version | tr '\n' ',')
320330
321331GINKGO = go run github.com/onsi/ginkgo/v2/ginkgo
322332# Common ginkgo options: -v for verbose mode, --focus="test name" for running single tests
0 commit comments