Enable test coverage in run_test.sh and tox

About run_test.sh, the report of test coverage seems
not create at the moment.
Also tox for cover doesn't work well.
This patch fix it.

Change-Id: I408b4c053c4290c7a205d892c43cb7cd2bbff641
This commit is contained in:
Kenji Ishii 2016-09-12 21:09:34 +09:00
parent ca3548252c
commit 8593eaf9fb
3 changed files with 14 additions and 3 deletions

3
.gitignore vendored
View File

@ -9,3 +9,6 @@ magnum_ui/test/.secret_key_store
*.lock
*.egg*
*.swp
.coverage
coverage.xml
htmlcov

View File

@ -365,6 +365,10 @@ function run_tests_all {
if [ "$NOSE_WITH_HTML_OUTPUT" = '1' ]; then
export NOSE_HTML_OUT_FILE='dashboard_nose_results.html'
fi
if [ $with_coverage -eq 1 ]; then
${command_wrapper} python -m coverage.__main__ erase
coverage_run="python -m coverage.__main__ run -p"
fi
${command_wrapper} ${coverage_run} $root/manage.py test magnum_ui --settings=openstack_dashboard.test.settings $testopts
# get results of the openstack_dashboard tests
DASHBOARD_RESULT=$?
@ -372,8 +376,8 @@ function run_tests_all {
if [ $with_coverage -eq 1 ]; then
echo "Generating coverage reports"
${command_wrapper} python -m coverage.__main__ combine
${command_wrapper} python -m coverage.__main__ xml -i --include="horizon/*,openstack_dashboard/*" --omit='/usr*,setup.py,*egg*,.venv/*'
${command_wrapper} python -m coverage.__main__ html -i --include="horizon/*,openstack_dashboard/*" --omit='/usr*,setup.py,*egg*,.venv/*' -d reports
${command_wrapper} python -m coverage.__main__ xml -i --include="magnum_ui/*" --omit='/usr*,setup.py,*egg*,.venv/*'
${command_wrapper} python -m coverage.__main__ html -i --include="magnum_ui/*" --omit='/usr*,setup.py,*egg*,.venv/*' -d reports
fi
# Remove the leftover coverage files from the -p flag earlier.
rm -f .coverage.*

View File

@ -23,7 +23,11 @@ commands = flake8 {posargs}
commands = {posargs}
[testenv:cover]
commands = python setup.py test --coverage --testr-args='{posargs}'
commands =
coverage erase
coverage run {toxinidir}/manage.py test magnum_ui --settings=magnum_ui.test.settings {posargs} --exclude-dir=magnum_ui/test/integration_tests {posargs}
coverage xml --omit '.tox/cover/*'
coverage html --omit '.tox/cover/*'
[testenv:py27dj18]
basepython = python2.7