From f0759f24c25f8286c3cbc983a56686e5b8e86bee Mon Sep 17 00:00:00 2001 From: Alex Burke Date: Sat, 25 Oct 2025 15:45:38 +0200 Subject: [PATCH] Add a "coverage" target to the Makefile that generates a coverage report. --- Makefile | 16 ++++++++++++++++ local-requirements.txt | 1 + 2 files changed, 17 insertions(+) diff --git a/Makefile b/Makefile index cd4f81d89..2098c76a2 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,22 @@ clean: @rm -f ./envhelp/py3.imageid @rm -f ./envhelp/local.depends +.PHONY: coverage +coverage: +ifneq ($(MIG_ENV),'local') + @echo "unavailable outside local development environment" + @exit 1 +endif + @$(LOCAL_PYTHON_BIN) -m coverage run -m unittest discover ./tests + +.PHONY: coverage-report +coverage-report: +ifneq ($(MIG_ENV),'local') + @echo "unavailable outside local development environment" + @exit 1 +endif + @$(LOCAL_PYTHON_BIN) -m coverage html + .PHONY: distclean distclean: clean @rm -rf ./envhelp/venv diff --git a/local-requirements.txt b/local-requirements.txt index 7faf3b026..944b832c1 100644 --- a/local-requirements.txt +++ b/local-requirements.txt @@ -3,6 +3,7 @@ # This list is mainly used to specify addons needed for the unit tests. # We only need autopep8 on py 3 as it's used in 'make fmt' (with py3) autopep8;python_version >= "3" +coverage # We need paramiko for the ssh unit tests # NOTE: paramiko-3.0.0 dropped python2 and python3.6 support paramiko;python_version >= "3.7"