Fix coverage job
`coverage run pytest` runs coverage against the tests in a file called "pytest", whereas `coverage run -m pytest` uses pytest as the test runner, which is what we really want here. To avoid duplicated maitenance of pytest arguments, unit_tests.sh is updated to handle the coverage run. Co-Authored-By: Akihiro Motoki <amotoki@gmail.com> Change-Id: I106cb5227ca8c4f0a6f9d81c37e745a6f304de45
This commit is contained in:
parent
79e505520f
commit
1202faa709
|
@ -11,6 +11,7 @@
|
||||||
.DS_STORE
|
.DS_STORE
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/cover
|
/cover
|
||||||
|
/coverage/
|
||||||
coverage.xml
|
coverage.xml
|
||||||
coverage-karma
|
coverage-karma
|
||||||
pep8.txt
|
pep8.txt
|
||||||
|
@ -19,7 +20,6 @@ pylint.txt
|
||||||
RELEASENOTES.rst
|
RELEASENOTES.rst
|
||||||
releasenotes/build
|
releasenotes/build
|
||||||
releasenotes/notes/reno.cache
|
releasenotes/notes/reno.cache
|
||||||
reports
|
|
||||||
|
|
||||||
openstack_dashboard/local/*
|
openstack_dashboard/local/*
|
||||||
!openstack_dashboard/local/local_settings.py.example
|
!openstack_dashboard/local/local_settings.py.example
|
||||||
|
|
|
@ -1,3 +1,12 @@
|
||||||
|
# Usage: unit_tests.sh [--coverage] <root_dir> [<test-file>, ...]
|
||||||
|
|
||||||
|
if [ "$1" = "--coverage" ]; then
|
||||||
|
shift
|
||||||
|
coverage=1
|
||||||
|
else
|
||||||
|
coverage=0
|
||||||
|
fi
|
||||||
|
|
||||||
root=$1
|
root=$1
|
||||||
posargs="${@:2}"
|
posargs="${@:2}"
|
||||||
|
|
||||||
|
@ -52,11 +61,15 @@ function run_test {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
report_args="--junitxml=$report_dir/${project}_test_results.xml"
|
if [ "$coverage" -eq 1 ]; then
|
||||||
report_args+=" --html=$report_dir/${project}_test_results.html"
|
coverage run -m pytest $target --ds=$settings_module -m "$tag"
|
||||||
report_args+=" --self-contained-html"
|
else
|
||||||
|
report_args="--junitxml=$report_dir/${project}_test_results.xml"
|
||||||
|
report_args+=" --html=$report_dir/${project}_test_results.html"
|
||||||
|
report_args+=" --self-contained-html"
|
||||||
|
|
||||||
pytest $target --ds=$settings_module -v -m "$tag" $report_args
|
pytest $target --ds=$settings_module -v -m "$tag" $report_args
|
||||||
|
fi
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
9
tox.ini
9
tox.ini
|
@ -49,13 +49,14 @@ commands =
|
||||||
|
|
||||||
[testenv:cover]
|
[testenv:cover]
|
||||||
envdir = {toxworkdir}/venv
|
envdir = {toxworkdir}/venv
|
||||||
|
whitelist_externals =
|
||||||
|
bash
|
||||||
commands =
|
commands =
|
||||||
coverage erase
|
coverage erase
|
||||||
coverage run pytest horizon/test/ --ds=horizon.test.settings {posargs}
|
bash {toxinidir}/tools/unit_tests.sh --coverage {toxinidir}
|
||||||
coverage run -a pytest openstack_dashboard --ds=openstack_dashboard.test.settings -m "not integration" {posargs}
|
|
||||||
coverage run -a pytest openstack_auth/tests --ds=openstack_auth.tests.settings {posargs}
|
|
||||||
coverage xml
|
coverage xml
|
||||||
coverage html
|
coverage html -d coverage
|
||||||
|
coverage report --show-missing --skip-covered
|
||||||
|
|
||||||
[testenv:selenium]
|
[testenv:selenium]
|
||||||
envdir = {toxworkdir}/venv
|
envdir = {toxworkdir}/venv
|
||||||
|
|
Loading…
Reference in New Issue