From c292242d9769fe85f3ff604c78e3dc0653edaa74 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Nov 27 2019 14:42:34 +0000 Subject: PR#723: improve test and clean targets in Makefiles Merges #723 https://pagure.io/koji/pull-request/723 Fixes: #1539 improve test and clean targets in Makefiles https://pagure.io/koji/issue/1539 --- diff --git a/.coveragerc b/.coveragerc index 14a1aca..5d00ff0 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,6 +1,8 @@ [run] +data_file = .coverage2 omit = + setup.py /usr/* tests/* @@ -8,3 +10,6 @@ omit = exclude_lines = pragma: no cover no cover: 2.x + +[html] +directory = htmlcov/py2 diff --git a/.coveragerc3 b/.coveragerc3 index 7d4bec1..e7f85d3 100644 --- a/.coveragerc3 +++ b/.coveragerc3 @@ -1,8 +1,10 @@ [run] +data_file = .coverage3 ; extra omissions for py3 for now omit = + setup.py /usr/* tests/* @@ -11,3 +13,6 @@ exclude_lines = pragma: no cover no cover 3.x if six.PY2 + +[html] +directory = htmlcov/py3 diff --git a/.gitignore b/.gitignore index dbcbef6..59b5da0 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ util/koji-shadowc # # coverage artifacts .coverage +.coverage[23] htmlcov/ *,cover # diff --git a/Makefile b/Makefile index 8378769..a1b9496 100644 --- a/Makefile +++ b/Makefile @@ -61,29 +61,39 @@ _default: clean: rm -f *.o *.so *.pyc *~ koji*.bz2 koji*.src.rpm + rm -rf __pycache__ + rm -rf devtools/fakehubc devtools/fakewebc devtools/__pycache__ rm -rf koji-$(VERSION) for d in $(SUBDIRS); do make -s -C $$d clean; done - coverage erase ||: + find ./tests -name "__pycache__" -exec rm -rf {} \; ||: + find ./tests -name "*.pyc" -exec rm -f {} \; + rm -rf docs/source/__pycache__ docs/source/*.pyc + coverage2 erase ||: + coverage3 erase --rcfile .coveragerc3 ||: + rm -rf htmlcov git-clean: @git clean -d -q -x -test: +test: test2 test3 + @echo "All tests are finished for python 2&3" + +test2: coverage2 erase PYTHONPATH=hub/.:plugins/hub/.:plugins/builder/.:plugins/cli/.:cli/.:www/lib coverage2 run \ --source . /usr/bin/nosetests coverage2 report coverage2 html - @echo Full coverage report at file://$(CURDIR)/htmlcov/index.html + @echo Full coverage report at file://${CURDIR}/htmlcov/py2/index.html test3: - coverage3 erase + coverage3 erase --rcfile .coveragerc3 PYTHONPATH=hub/.:plugins/hub/.:plugins/builder/.:plugins/cli/.:cli/.:www/lib coverage3 run \ --rcfile .coveragerc3 --source . \ /usr/bin/nosetests-3 coverage3 report --rcfile .coveragerc3 coverage3 html --rcfile .coveragerc3 - @echo Full coverage report at file://$(CURDIR)/htmlcov/index.html + @echo Full coverage report at file://${CURDIR}/htmlcov/py3/index.html test-tarball: @rm -rf .koji-$(VERSION) diff --git a/builder/Makefile b/builder/Makefile index da56c47..9d16298 100644 --- a/builder/Makefile +++ b/builder/Makefile @@ -8,6 +8,7 @@ _default: clean: rm -f *.o *.so *.pyc *~ kojidc + rm -rf __pycache__ _install: diff --git a/cli/Makefile b/cli/Makefile index 605c9ea..d5cca84 100644 --- a/cli/Makefile +++ b/cli/Makefile @@ -13,6 +13,8 @@ _default: clean: rm -f *.o *.so *.pyc *~ kojic + rm -rf __pycache__ + for d in $(SUBDIRS); do make -s -C $$d clean; done install: @if [ "$(DESTDIR)" = "" ]; then \ diff --git a/cli/koji_cli/Makefile b/cli/koji_cli/Makefile index baf78d3..c7c460a 100644 --- a/cli/koji_cli/Makefile +++ b/cli/koji_cli/Makefile @@ -11,6 +11,7 @@ _default: clean: rm -f *.o *.so *.pyc *~ + rm -rf __pycache__ install: @if [ "$(DESTDIR)" = "" ]; then \ diff --git a/hub/Makefile b/hub/Makefile index 59e0f9f..e8fe651 100644 --- a/hub/Makefile +++ b/hub/Makefile @@ -13,6 +13,7 @@ _default: clean: rm -f *.o *.so *.pyc *~ + rm -rf __pycache__ install: @if [ "$(DESTDIR)" = "" ]; then \ diff --git a/koji/Makefile b/koji/Makefile index 7a3925a..df2991c 100644 --- a/koji/Makefile +++ b/koji/Makefile @@ -12,7 +12,7 @@ _default: clean: rm -f *.o *.so *.pyc *~ - for d in $(SUBDIRS); do make -s -C $$d clean; done + rm -rf __pycache__ install: mkdir -p $(DESTDIR)/$(PKGDIR) diff --git a/plugins/Makefile b/plugins/Makefile index 500d944..690e5c3 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -21,7 +21,8 @@ _default: @echo "nothing to make. try make install" clean: - rm -f *.o *.so *.pyc *.pyo *~ + find . -name "__pycache__" -exec rm -rf {} \; ||: + find . -name "*.pyc" -exec rm -f {} \; install: @if [ "$(DESTDIR)" = "" ]; then \ diff --git a/runtests b/runtests index bc1c25c..5eeea2c 100755 --- a/runtests +++ b/runtests @@ -26,8 +26,8 @@ def checkout_run(cmd, ref='HEAD'): return output -def run_test(): - return checkout_run(['make', 'test']) +def run_test2(): + return checkout_run(['make', 'test2']) def run_test3(): @@ -38,7 +38,7 @@ def main(): """Run our test targets in parallel using fresh checkouts of HEAD""" print("Running tests...") p = Pool(2) - results = [p.apply_async(f) for f in [run_test, run_test3]] + results = [p.apply_async(f) for f in [run_test2, run_test3]] for r in results: print(r.get().decode('utf-8')) p.close() diff --git a/util/Makefile b/util/Makefile index 3310b51..bcaddc9 100644 --- a/util/Makefile +++ b/util/Makefile @@ -7,6 +7,7 @@ _default: clean: rm -f *.o *.so *.pyc *~ + rm -rf __pycache__ for b in $(BINFILES); do rm -f $${b}c; done _install: diff --git a/www/kojiweb/Makefile b/www/kojiweb/Makefile index 4feda33..214a88a 100644 --- a/www/kojiweb/Makefile +++ b/www/kojiweb/Makefile @@ -8,6 +8,7 @@ _default: clean: rm -f *.o *.so *.pyc *~ + rm -rf __pycache__ for d in $(SUBDIRS); do make -s -C $$d clean; done install: diff --git a/www/lib/kojiweb/Makefile b/www/lib/kojiweb/Makefile index 84e8b03..e23fb4d 100644 --- a/www/lib/kojiweb/Makefile +++ b/www/lib/kojiweb/Makefile @@ -13,6 +13,7 @@ _default: clean: rm -f *.o *.so *.pyc *~ + rm -rf __pycache__ for d in $(SUBDIRS); do make -s -C $$d clean; done install: