summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rwxr-xr-xtools/unit_tests.sh21
-rw-r--r--tox.ini9
3 files changed, 23 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index a810c24b9..b15111ab7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,7 @@
.DS_STORE
.DS_Store
/cover
+/coverage/
coverage.xml
coverage-karma
pep8.txt
@@ -19,7 +20,6 @@ pylint.txt
RELEASENOTES.rst
releasenotes/build
releasenotes/notes/reno.cache
-reports
openstack_dashboard/local/*
!openstack_dashboard/local/local_settings.py.example
diff --git a/tools/unit_tests.sh b/tools/unit_tests.sh
index 2a0374af7..45da9e9b1 100755
--- a/tools/unit_tests.sh
+++ b/tools/unit_tests.sh
@@ -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
posargs="${@:2}"
@@ -52,11 +61,15 @@ function run_test {
fi
fi
- report_args="--junitxml=$report_dir/${project}_test_results.xml"
- report_args+=" --html=$report_dir/${project}_test_results.html"
- report_args+=" --self-contained-html"
+ if [ "$coverage" -eq 1 ]; then
+ coverage run -m pytest $target --ds=$settings_module -m "$tag"
+ 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 $?
}
diff --git a/tox.ini b/tox.ini
index fb0fe98f5..0a88f7e97 100644
--- a/tox.ini
+++ b/tox.ini
@@ -49,13 +49,14 @@ commands =
[testenv:cover]
envdir = {toxworkdir}/venv
+whitelist_externals =
+ bash
commands =
coverage erase
- coverage run pytest horizon/test/ --ds=horizon.test.settings {posargs}
- 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}
+ bash {toxinidir}/tools/unit_tests.sh --coverage {toxinidir}
coverage xml
- coverage html
+ coverage html -d coverage
+ coverage report --show-missing --skip-covered
[testenv:selenium]
envdir = {toxworkdir}/venv