Fixing the coverage reports for the unittests and adding support for TestR.

Now they work better and also include coverage for the tests invoked by testr.

Change-Id: Ia48cf4664ce9ec46f7ef21929b0d87cad4149580
Fixes: bug #1103637
This commit is contained in:
Dror Kagan 2013-01-23 11:46:29 -08:00
parent 52344398de
commit b8766b336c
2 changed files with 16 additions and 11 deletions

View File

@ -2,8 +2,10 @@
[run]
branch = True
timid=True
include=*reddwarf*
source=.tox/cover/lib/python2.7/site-packages/reddwarf
# replace with previous line once the python path issue is resolved and the tox.ini is fixed accordingly
# source=reddwarf
omit=*reddwarf/tests*,*reddwarf/openstack/common*
[report]
# Regexes for lines to exclude from consideration
@ -24,3 +26,6 @@ exclude_lines =
if __name__ == .__main__.:
ignore_errors = False
[html]
directory=cover

18
tox.ini
View File

@ -6,9 +6,8 @@ setenv = VIRTUAL_ENV={envdir}
deps = -r{toxinidir}/tools/pip-requires
-r{toxinidir}/tools/test-requires
setuptools_git>=0.4
commands = {envpython} run_tests.py {posargs}
bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
bash -c 'testr run --parallel {posargs} ; RET=$? ; echo "Slowest Tests" ; testr slowest && exit $RET'
commands = {envpython} run_tests.py
python setup.py testr --slowest
[tox:jenkins]
sitepackages = True
@ -20,13 +19,14 @@ deps = pep8
commands = pep8 --repeat --show-source --ignore=E125 --exclude=.venv,.tox,dist,doc,openstack,*egg reddwarf
[testenv:cover]
setenv = NOSE_WITH_COVERAGE=1
# TODO(tim.simpson): For some reason, this must run twice before the coverage
# report is accurate.
commands =
{toxinidir}/.tox/cover/bin/coverage erase
{toxinidir}/.tox/cover/bin/coverage run --timid -p run_tests.py {posargs}
{toxinidir}/.tox/cover/bin/coverage html -d covhtml -i --omit=*tests*,*openstack*,*reddwarfclient*
coverage erase
coverage run -m subunit.run discover ./reddwarf/tests/unittests
# replace with above line once the python path issue is resolved
# python setup.py testr --coverage
coverage run -a run_tests.py
coverage html
coverage report
[testenv:venv]