From 6f17ede28b3dc1e4220f7deeea226016c6cb77fc Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sat, 9 Feb 2019 19:47:06 +0000 Subject: [PATCH 1/3] Fix incorrect attempt to use coverage Looks like this was a copy and paste mistake --- run_tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_tests b/run_tests index c3c3ea6c..2877ec65 100755 --- a/run_tests +++ b/run_tests @@ -59,7 +59,7 @@ fi --pattern '*_test.py' \ "$@" else - coverage run -a "${UNIT2}" discover \ + "${UNIT2}" discover \ --start-directory "tests/ansible" \ --pattern '*_test.py' \ "$@" From e7d9ec86f99c1f6f37bd9e70b52578616751f7cf Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sat, 9 Feb 2019 19:49:01 +0000 Subject: [PATCH 2/3] Allow independant control of coverage erase and reporting --- run_tests | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/run_tests b/run_tests index 2877ec65..b583af3b 100755 --- a/run_tests +++ b/run_tests @@ -24,16 +24,22 @@ echo # Don't use errexit, so coverage report is still generated when tests fail set -o pipefail +NOCOVERAGE="${NOCOVERAGE:-}" +NOCOVERAGE_ERASE="${NOCOVERAGE_ERASE:-$NOCOVERAGE}" +NOCOVERAGE_REPORT="${NOCOVERAGE_REPORT:-$NOCOVERAGE}" + if [ ! "$UNIT2" ]; then UNIT2="$(which unit2)" fi -[ "$NOCOVERAGE" ] || coverage erase +if [ ! "$NOCOVERAGE_ERASE" ]; then + coverage erase +fi # First run overwites coverage output. [ "$SKIP_MITOGEN" ] || { if [ ! "$NOCOVERAGE" ]; then - coverage run "${UNIT2}" discover \ + coverage run -a "${UNIT2}" discover \ --start-directory "tests" \ --pattern '*_test.py' \ "$@" @@ -67,8 +73,10 @@ fi ANSIBLE_TEST_STATUS=$? } -[ "$NOCOVERAGE" ] || coverage html -[ "$NOCOVERAGE" ] || echo coverage report is at "file://$(pwd)/htmlcov/index.html" +if [ ! "$NOCOVERAGE_REPORT" ]; then + coverage html + echo "coverage report is at file://$(pwd)/htmlcov/index.html" +fi # Exit with a non-zero status if any test run did so exit "$(max $MITOGEN_TEST_STATUS $ANSIBLE_TEST_STATUS)" From 2fa84e096fd86ea0b50edcb37e719ee7e86ed5d7 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Sat, 9 Feb 2019 20:01:01 +0000 Subject: [PATCH 3/3] Aggregate code coverage data across tox all runs Fixes #529 --- docs/changelog.rst | 4 ++++ tox.ini | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index 5e572518..2e5dea4a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -441,12 +441,16 @@ Core Library * `#524 ` : Python 3.6+ emitted a :class:`DeprecationWarning` for :func:`mitogen.utils.run_with_router`. +* `#529 ` : Code coverage of the + test suite was not measured across all Python versions. + Thanks! ~~~~~~~ Mitogen would not be possible without the support of users. A huge thanks for bug reports, testing, features and fixes in this release contributed by +`Alex Willmer `_, `Andreas Krüger `_, `Anton Stroganov `_, `Berend De Schouwer `_, diff --git a/tox.ini b/tox.ini index 80f835ee..8a4ef364 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,12 @@ [tox] envlist = + init, py26, py27, py35, py36, py37, + report, [testenv] usedevelop = True @@ -16,6 +18,24 @@ commands = {posargs:bash run_tests} whitelist_externals = bash +setenv = + NOCOVERAGE_ERASE = 1 + NOCOVERAGE_REPORT = 1 + +[testenv:init] +commands = + coverage erase +deps = + coverage + +[testenv:report] +commands = + coverage html + echo "coverage report is at file://{toxinidir}/htmlcov/index.html" +deps = + coverage +whitelist_externals = + echo [testenv:docs] basepython = python