From a65345a42749c3ced5f9598b6632129bfdb0de47 Mon Sep 17 00:00:00 2001
From: Saurabh Kumar <theskumar@users.noreply.github.com>
Date: Tue, 30 Aug 2022 08:12:36 +0530
Subject: [PATCH] make the makefile more readable

Break test target into smaller targets
---
 Makefile | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index da77c0ee2..39de3e839 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,9 @@ help:
 	@echo "Usage:"
 	@echo "    make help             prints this help."
 	@echo "    make lint             run all python linting."
-	@echo "    make test             run all python linting and test"
+	@echo "    make test             run linting and test and generate html coverage report"
+	@echo "    make py-test          run all python tests and display coverage"
+	@echo "    make cov-html         generate html coverage report"
 	@echo "    make sort             run the isort import linter."
 	@echo "    make sort-fix         fix import sort order."
 	@echo "    make style            run the python code style linter."
@@ -23,7 +25,20 @@ sort-fix:
 style:
 	@echo "Checking code style with flake8" && flake8 .
 
-test: lint
-	pytest --reuse-db --cov --cov-report term:skip-covered
+.PHONY: cov-htmlcov
+cov-html:
+ifneq ("$(wildcard .coverage)","")
 	@rm -rf htmlcov
-	coverage html
+	@echo "Generate html coverage report..." && coverage html
+	@echo "Open 'htmlcov/index.html' in your browser to see the report."
+else
+	$(error Unable to generate html coverage report, please run 'make test' or 'make py-test')
+endif
+
+.PHONY: py-test
+py-test:
+	@echo "Running python tests"
+	pytest --reuse-db --cov --cov-report term:skip-covered
+
+.PHONY: test
+test: lint py-test cov-html
-- 
GitLab