Fix coverage report
There's a few things going on here Firstly, we need to install coverage tool in test-requirements Secondly, .testr.conf has to use PYTHON because the coverage report works by resetting PYTHON='coverage run ...' Thirdly, because we call ourselves diskimage-builder but the python module is diskimage_builder that seems to confuse things. We need to use "setup.py test" (note, that is different to "setup.py testr"!) to use the PBR testr wrapper. That exposes a --coverage-package-name argument that calls the coverage tool with the right argument. With this I got a coverage report for our unit tests Change-Id: I9012e18eb7d01bee035140e70afa76c47c27eb01
This commit is contained in:
parent
084937617f
commit
baf3ced0c3
@ -4,7 +4,7 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
|
||||
OS_DEBUG=${OS_DEBUG:-0} \
|
||||
python -m subunit.run discover . $LISTOPT $IDOPTION
|
||||
${PYTHON:-python} -m subunit.run discover . $LISTOPT $IDOPTION
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
|
||||
|
@ -12,3 +12,5 @@ oslosphinx>=4.7.0 # Apache-2.0
|
||||
|
||||
# releasenotes
|
||||
reno>=1.8.0 # Apache-2.0
|
||||
|
||||
coverage>=4.0 # Apache-2.0
|
||||
|
9
tox.ini
9
tox.ini
@ -9,7 +9,7 @@ install_command = pip install -U {opts} {packages}
|
||||
deps= -r{toxinidir}/requirements.txt
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
commands=
|
||||
python setup.py testr --slowest --testr-args='{posargs}'
|
||||
python setup.py test --slowest --testr-args='{posargs}'
|
||||
|
||||
[testenv:pep8]
|
||||
commands =
|
||||
@ -24,9 +24,10 @@ envdir = {toxworkdir}/venv
|
||||
commands = {toxinidir}/tests/run_functests.sh {posargs}
|
||||
|
||||
[testenv:cover]
|
||||
setenv = PYTHON=coverage run --source diskimage_builder
|
||||
commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
|
||||
bash -c 'testr run --parallel ; RET=$? ; coverage combine ; coverage html -d ./cover $OMIT && exit $RET'
|
||||
# NOTE: this is "setup.py test" (*not* testr) which is a pbr wrapper
|
||||
# around testr. This understands --coverage-package-name which we
|
||||
# need due to underscore issues.
|
||||
commands = python setup.py test --coverage --coverage-package-name diskimage_builder --testr-args='{posargs}'
|
||||
|
||||
[testenv:docs]
|
||||
commands = python setup.py build_sphinx
|
||||
|
Loading…
Reference in New Issue
Block a user