From f31bd85266b8bdb7d95bb6f6e2f6d48967278f9a Mon Sep 17 00:00:00 2001 From: Miroslav Los Date: Wed, 18 Dec 2019 13:29:54 +0100 Subject: Fix tox configuration for coverage Coverage is unable to report on modules unless PYTHONPATH is set. Put test results into separate files for python 2 and 3. Merge coverage of python 2 and 3 in a final report. Silence warnings on xunit2 pytest output format. Signed-off-by: Miroslav Los Issue-ID: DCAEGEN2-2005 Change-Id: I2740231274c153d178e7d9c9103fc70657f7558d --- cdap/cdapplugin/tox-local.ini | 23 +++++++++++++++++++++-- cdap/cdapplugin/tox.ini | 21 +++++++++++++++++++-- clamp-policy/tox-local.ini | 25 +++++++++++++++++++++---- clamp-policy/tox.ini | 22 +++++++++++++++++++--- dcae-policy/tox-local.ini | 25 +++++++++++++++++++++---- dcae-policy/tox.ini | 22 +++++++++++++++++++--- docker/tox.ini | 22 +++++++++++++++++++--- k8s/tox.ini | 22 +++++++++++++++++++--- relationships/tox.ini | 22 +++++++++++++++++++--- 9 files changed, 177 insertions(+), 27 deletions(-) diff --git a/cdap/cdapplugin/tox-local.ini b/cdap/cdapplugin/tox-local.ini index 1664561..d14c8a1 100644 --- a/cdap/cdapplugin/tox-local.ini +++ b/cdap/cdapplugin/tox-local.ini @@ -1,11 +1,30 @@ +# tox -c tox-local.ini [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest coverage pytest-cov commands= - pytest --cov {envsitepackagesdir}/cdapcloudify --cov-report html + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov cdapcloudify + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine + coverage html + +[pytest] +junit_family = xunit2 diff --git a/cdap/cdapplugin/tox.ini b/cdap/cdapplugin/tox.ini index 32445ed..5c399a7 100644 --- a/cdap/cdapplugin/tox.ini +++ b/cdap/cdapplugin/tox.ini @@ -1,12 +1,29 @@ [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest coverage pytest-cov commands= - pytest --junitxml xunit-results.xml --cov cdapcloudify --cov-report xml + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov cdapcloudify + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine coverage xml + +[pytest] +junit_family = xunit2 diff --git a/clamp-policy/tox-local.ini b/clamp-policy/tox-local.ini index e41b3f4..314229c 100644 --- a/clamp-policy/tox-local.ini +++ b/clamp-policy/tox-local.ini @@ -1,13 +1,30 @@ -# tox -c tox-local.ini | tee -a logs/test_clamppolicyplugin.log 2>&1 +# tox -c tox-local.ini [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest coverage pytest-cov -# recreate = True commands= - pytest -v --cov clamppolicyplugin --cov-report html + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov clamppolicyplugin + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine + coverage html + +[pytest] +junit_family = xunit2 diff --git a/clamp-policy/tox.ini b/clamp-policy/tox.ini index 9e09c4a..21ecdb2 100644 --- a/clamp-policy/tox.ini +++ b/clamp-policy/tox.ini @@ -1,13 +1,29 @@ -# content of: tox.ini , put in same dir as setup.py [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest coverage pytest-cov commands= - pytest --junitxml xunit-results.xml --cov clamppolicyplugin --cov-report xml + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov clamppolicyplugin + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine coverage xml + +[pytest] +junit_family = xunit2 diff --git a/dcae-policy/tox-local.ini b/dcae-policy/tox-local.ini index d3ffbb0..125233e 100644 --- a/dcae-policy/tox-local.ini +++ b/dcae-policy/tox-local.ini @@ -1,8 +1,12 @@ -# tox -c tox-local.ini | tee -a logs/test_dcaepolicyplugin.log 2>&1 +# tox -c tox-local.ini [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest @@ -10,7 +14,20 @@ deps= pytest-cov whitelist_externals= /bin/mkdir -# recreate = True commands= mkdir -p logs - pytest -v --cov dcaepolicyplugin --cov-report html + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov dcaepolicyplugin + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine + coverage html + +[pytest] +junit_family = xunit2 diff --git a/dcae-policy/tox.ini b/dcae-policy/tox.ini index 42a4c39..2315666 100644 --- a/dcae-policy/tox.ini +++ b/dcae-policy/tox.ini @@ -1,8 +1,11 @@ -# content of: tox.ini , put in same dir as setup.py [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest @@ -12,5 +15,18 @@ whitelist_externals= /bin/mkdir commands= mkdir -p logs - pytest --junitxml xunit-results.xml --cov dcaepolicyplugin --cov-report xml + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov dcaepolicyplugin + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine coverage xml + +[pytest] +junit_family = xunit2 diff --git a/docker/tox.ini b/docker/tox.ini index c38918a..96c0e1f 100644 --- a/docker/tox.ini +++ b/docker/tox.ini @@ -1,13 +1,29 @@ -# content of: tox.ini , put in same dir as setup.py [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest coverage pytest-cov commands= - pytest --junitxml xunit-results.xml --cov dockerplugin --cov-report xml + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov dockerplugin + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine coverage xml + +[pytest] +junit_family = xunit2 diff --git a/k8s/tox.ini b/k8s/tox.ini index 3bea42d..24fb8d5 100644 --- a/k8s/tox.ini +++ b/k8s/tox.ini @@ -1,13 +1,29 @@ -# content of: tox.ini , put in same dir as setup.py [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest coverage pytest-cov commands= - pytest --junitxml xunit-results.xml --cov configure --cov k8sclient --cov k8splugin --cov msb --cov-report xml + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov configure --cov k8sclient --cov k8splugin --cov msb + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine coverage xml + +[pytest] +junit_family = xunit2 diff --git a/relationships/tox.ini b/relationships/tox.ini index 499accb..c734632 100644 --- a/relationships/tox.ini +++ b/relationships/tox.ini @@ -1,13 +1,29 @@ -# content of: tox.ini , put in same dir as setup.py [tox] -envlist = py27,py36 +envlist = py27,py36,cov [testenv] +# coverage can only find modules if pythonpath is set +setenv= + PYTHONPATH={toxinidir} + COVERAGE_FILE=.coverage.{envname} deps= -rrequirements.txt pytest coverage pytest-cov commands= - pytest --junitxml xunit-results.xml --cov relationshipplugin --cov-report xml + coverage erase + pytest --junitxml xunit-results.{envname}.xml --cov relationshipplugin + +[testenv:cov] +skip_install = true +deps= + coverage +setenv= + COVERAGE_FILE=.coverage +commands= + coverage combine coverage xml + +[pytest] +junit_family = xunit2 -- cgit 1.2.3-korg