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: Ibeb2ba6aaa868ff4087721b98eae7a54fa89beef
Paul Goins 2019-03-01 12:11:34 +01:00
parent 56873b0c3e
commit 5ade981919
3 changed files with 29 additions and 7 deletions

View File

@ -1,7 +0,0 @@
# Regexes for lines to exclude from consideration
exclude_lines =
if __name__ == .__main__.:
except UnregisteredHookError as e:

View File

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

View File

@ -39,6 +39,34 @@ deps = -r{toxinidir}/requirements.txt
commands = flake8 {posargs} hooks unit_tests tests actions lib
# Technique based heavily upon
basepython = python3
deps = -r{toxinidir}/requirements.txt
setenv =
PYTHON=coverage run
commands =
coverage erase
ostestr {posargs}
coverage combine
coverage html -d cover
coverage xml -o cover/coverage.xml
coverage report
branch = True
concurrency = multiprocessing
parallel = True
source =
omit =
basepython = python3
commands = {posargs}