From 862e29fefb6050bee335686bfde0ffbc1c9e68cd Mon Sep 17 00:00:00 2001 From: Alexander Todorov Date: Mon, 25 May 2015 05:09:51 -0400 Subject: [PATCH] Parameterize Makefile test targets on Python version. Check that dependencies for testing are available. --- Makefile | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 823b948ef..a2b2f5c30 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,25 @@ RELEASE_TAG=$(PKGNAME)-$(VERSION)-$(RELEASE) VERSION_TAG=$(PKGNAME)-$(VERSION) PYTHON=python2 +COVERAGE=coverage +ifeq ($(PYTHON),python3) + COVERAGE=coverage3 +endif + ZANATA_PULL_ARGS = --transdir ./po/ ZANATA_PUSH_ARGS = --srcdir ./po/ --push-type source --force MOCKCHROOT ?= fedora-rawhide-x86_64 +TEST_DEPENDENCIES = $(shell grep "^Requires:" python-blivet.spec | cut -f2 -d: | cut -f1 -d">") +TEST_DEPENDENCIES += python-mock python3-mock +TEST_DEPENDENCIES += cryptsetup-python cryptsetup-python3 +TEST_DEPENDENCIES += python3-gobject +TEST_DEPENDENCIES += python-coverage python3-coverage +TEST_DEPENDENCIES += xfsprogs hfsplus-tools +TEST_DEPENDENCIES += python3-pocketlint +TEST_DEPENDENCIES := $(shell echo $(sort $(TEST_DEPENDENCIES)) | uniq) + all: $(MAKE) -C po @@ -26,17 +40,20 @@ po-empty: exit 1 ; \ done -test: - @echo "*** Running unittests ***" +check-requires: + @echo "*** Checking if the dependencies required for testing and analysis are available ***" + @echo $(TEST_DEPENDENCIES) | xargs rpm -q + +test: check-requires + @echo "*** Running unittests with $(PYTHON) ***" PYTHONPATH=.:tests/ $(PYTHON) -m unittest discover -v -s tests/ -p '*_test.py' -coverage: - @which coverage || (echo "*** Please install python-coverage ***"; exit 2) - @echo "*** Running unittests with coverage ***" - PYTHONPATH=.:tests/ coverage run --branch -m unittest discover -v -s tests/ -p '*_test.py' - coverage report --include="blivet/*" +coverage: check-requires + @echo "*** Running unittests with $(COVERAGE) for $(PYTHON) ***" + PYTHONPATH=.:tests/ $(COVERAGE) run --branch -m unittest discover -v -s tests/ -p '*_test.py' + $(COVERAGE) report --include="blivet/*" --show-missing -check: +check: check-requires PYTHONPATH=. tests/pylint/runpylint.py clean: