Added tox environment for gathering coverage

This technique was borrowed from the tox "cover" environment in
openstack/nova's tox.ini.  This leverages the fact that stestr lets
you override the python executable via the PYTHON environment
variable.  Doing this allows us to easily generate coverage for our
unit tests.

An important caveat is that this does not provide any coverage for
tests via zaza, amulet, etc.  It is purely focused on the unit tests.

Note that this replaces the previous .coveragerc; coverage
configuration is instead pulled from tox.ini.

Change-Id: I951a813fbb9e3fc51be230dd3f72a4f715ee8c59
This commit is contained in:
Paul Goins 2019-03-01 10:26:41 +01:00
parent 757e2da7ab
commit 81e48a0a65
2 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,4 @@
- project:
templates:
- python35-charm-jobs
- openstack-cover-jobs

27
tox.ini
View File

@ -42,6 +42,33 @@ basepython = python3
deps = -r{toxinidir}/test-requirements.txt
commands = flake8 {posargs} src unit_tests
[testenv:cover]
# Technique based heavily upon
# https://github.com/openstack/nova/blob/master/tox.ini
basepython = python3
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
setenv =
{[testenv]setenv}
PYTHON=coverage run
commands =
coverage erase
ostestr {posargs}
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report
[coverage:run]
branch = True
concurrency = multiprocessing
parallel = True
source =
.
omit =
.tox/*
*/charmhelpers/*
[testenv:venv]
basepython = python3
commands = {posargs}