@@ -3,7 +3,6 @@ VERSION=$(shell make -s version)
33PYTHON? =python3
44BINPATH? =$(GOPATH ) /bin
55GOLANGCI_LINT_VERSION =v2.0.2 # version supporting go 1.24
6- COVERAGE_DIR?=$(shell mktemp -d)
76GOOS=$(shell go env GOHOSTOS)
87GOARCH =$(shell go env GOHOSTARCH)
98
@@ -15,12 +14,16 @@ export TZ=UTC
1514# Unit Tests and some sysmte tests rely on expired certificates, turn back the time
1615export TEST_FAKETIME := 2025-01-02 03:04:05
1716
17+ ifeq ($(origin COVERAGE_DIR ) , undefined)
18+ COVERAGE_DIR := $(shell mktemp -d)
19+ endif
20+
1821# run with 'COVERAGE_SKIP=1' to skip coverage checks during system tests
1922ifeq ($(COVERAGE_SKIP ) ,1)
2023COVERAGE_ARG_BUILD :=
2124COVERAGE_ARG_TEST := --coverage-skip
2225else
23- COVERAGE_ARG_BUILD := -coverpkg="./ ..."
26+ COVERAGE_ARG_BUILD := -coverpkg=github.com/aptly-dev/aptly/ ...
2427COVERAGE_ARG_TEST := --coverage-dir $(COVERAGE_DIR )
2528endif
2629
@@ -107,13 +110,16 @@ test: prepare swagger etcd-install ## Run unit tests (add TEST=regex to specify
107110 @echo " \e[33m\e[1mStarting etcd ...\e[0m"
108111 @mkdir -p /tmp/aptly-etcd-data; system/t13_etcd/start-etcd.sh > /tmp/aptly-etcd-data/etcd.log 2>&1 &
109112 @echo " \e[33m\e[1mRunning go test ...\e[0m"
110- faketime " $( TEST_FAKETIME) " go test -v ./... -gocheck.v=true -check.f " $( TEST) " -coverprofile=unit.out ; echo $$? > .unit-test.ret
113+ faketime " $( TEST_FAKETIME) " go test -v ./... -gocheck.v=true -check.f " $( TEST) " -coverprofile=unit-test.cov ; echo $$? > .unit-test.ret
111114 @echo " \e[33m\e[1mStopping etcd ...\e[0m"
112115 @pid=` cat /tmp/etcd.pid` ; kill $$ pid
113116 @rm -f /tmp/aptly-etcd-data/etcd.log
114117 @ret=` cat .unit-test.ret` ; if [ " $$ ret" = " 0" ]; then echo " \n\e[32m\e[1mUnit Tests SUCCESSFUL\e[0m" ; else echo " \n\e[31m\e[1mUnit Tests FAILED\e[0m" ; fi ; rm -f .unit-test.ret; exit $$ ret
118+ @go tool cover -func=unit-test.cov
119+
115120
116121system-test : prepare swagger etcd-install # # Run system tests
122+ @test -f $(BINPATH ) /gocovmerge || GOOS= GOARCH= go install github.com/wadey/gocovmerge@latest
117123 # build coverage binary
118124 go test -v $(COVERAGE_ARG_BUILD ) -c -tags testruncli
119125 # Download fixture-db, fixture-pool, etcd.db
@@ -122,6 +128,9 @@ system-test: prepare swagger etcd-install ## Run system tests
122128 test -f ~ /etcd.db || (curl -o ~ /etcd.db.xz http://repo.aptly.info/system-tests/etcd.db.xz && xz -d ~ /etcd.db.xz)
123129 # Run system tests
124130 PATH=$(BINPATH ) /:$(PATH ) FORCE_COLOR=1 $(PYTHON ) system/run.py --long $(COVERAGE_ARG_TEST ) $(CAPTURE_ARG ) $(TEST )
131+ PATH=$(BINPATH ) /:$(PATH ) gocovmerge $(COVERAGE_DIR ) /* .out > system-test.cov
132+ rm -f $(COVERAGE_DIR ) /* .out
133+ go tool cover -func=system-test.cov
125134
126135bench :
127136 @echo " \e[33m\e[1mRunning benchmark ...\e[0m"
@@ -237,7 +246,7 @@ clean: ## remove local build and module cache
237246 test ! -e .go || find .go/ -type d ! -perm -u=w -exec chmod u+w {} \;
238247 rm -rf .go/
239248 rm -rf build/ obj-* -linux-gnu* tmp/
240- rm -f unit.out aptly.test VERSION docs/docs.go docs/swagger.json docs/swagger.yaml docs/swagger.conf
249+ rm -f unit-test.cov system-test.cov aptly.test VERSION docs/docs.go docs/swagger.json docs/swagger.yaml docs/swagger.conf
241250 find system/ -type d -name __pycache__ -exec rm -rf {} \; 2> /dev/null || true
242251
243252.PHONY : help man prepare swagger version binaries build docker-release docker-system-test docker-unit-test docker-lint docker-build docker-image docker-man docker-shell docker-serve clean releasetype dpkg serve flake8
0 commit comments