Improve test coverage
* Refactor some functions to improve unit test coverage. * Use the "coverage" module if available along with unit tests.
This commit is contained in:
24
Makefile
24
Makefile
@@ -19,6 +19,12 @@ RPM_VERSION := $(VERSION)-$(RPM_RELEASE)
|
||||
DEB_VERSION := $(VERSION)~rc$(RELEASE)
|
||||
endif
|
||||
|
||||
# Python stuff
|
||||
PYTHON ?= python3
|
||||
PYLINT ?= pylint
|
||||
BLACK ?= black
|
||||
|
||||
HAVE_COVERAGE := $(shell $(PYTHON) -c 'import coverage' 2>/dev/null && echo yes)
|
||||
|
||||
# Where packages are built
|
||||
BUILD_DIR := build
|
||||
@@ -82,19 +88,23 @@ clean:
|
||||
|
||||
# Check for lint
|
||||
lint:
|
||||
pylint src/pgmon.py
|
||||
pylint src/test_pgmon.py
|
||||
black --check --diff src/pgmon.py
|
||||
black --check --diff src/test_pgmon.py
|
||||
$(PYLINT) src/pgmon.py
|
||||
$(PYLINT) src/test_pgmon.py
|
||||
$(BLACK) --check --diff src/pgmon.py
|
||||
$(BLACK) --check --diff src/test_pgmon.py
|
||||
|
||||
# Format the code using black
|
||||
format:
|
||||
black src/pgmon.py
|
||||
black src/test_pylint.py
|
||||
$(BLACK) src/pgmon.py
|
||||
$(BLACK) src/test_pgmon.py
|
||||
|
||||
# Run unit tests for the script
|
||||
test:
|
||||
cd src ; python3 -m unittest
|
||||
ifeq ($(HAVE_COVERAGE),yes)
|
||||
cd src ; $(PYTHON) -m coverage run -m unittest && python3 -m coverage report -m
|
||||
else
|
||||
cd src ; $(PYTHON) -m unittest
|
||||
endif
|
||||
|
||||
# Run query tests
|
||||
query-tests:
|
||||
|
||||
Reference in New Issue
Block a user