Use stestr for running unit tests, add a coverage environment

stestr [1] is a fork of the testrunner python test runner.

Coverage tests can be run using 'tox -e cover'.

Adds a job for checking coverage to Zuul check and gate.

[1] http://stestr.readthedocs.io/en/latest/

Change-Id: I25cd407677a4013d022f87d124c6db43ab6bb2e0
Story: #2001637
Task: #6648
This commit is contained in:
Mark Goddard 2018-02-22 12:00:02 +00:00
parent ab5938065f
commit 048fd82bef
6 changed files with 32 additions and 3 deletions

6
.coveragerc Normal file
View File

@ -0,0 +1,6 @@
[run]
branch = True
source = kayobe
[report]
ignore_errors = True

3
.gitignore vendored
View File

@ -26,6 +26,9 @@ cover/
.coverage*
!.coveragerc
.tox
nosetests.xml
.testrepository
.stestr
.venv
# Mr Developer

3
.stestr.conf Normal file
View File

@ -0,0 +1,3 @@
[DEFAULT]
test_path=${TESTS_DIR:-./kayobe/tests/unit/}
top_dir=./

View File

@ -11,3 +11,4 @@ hacking>=0.12.0,<0.13 # Apache-2.0
molecule<3 # MIT
oslotest>=1.10.0 # Apache-2.0
sphinx>=1.5.1 # BSD
stestr # Apache-2.0

20
tox.ini
View File

@ -1,6 +1,6 @@
[tox]
minversion = 2.0
envlist = py34,py27,pypy,pep8
envlist = py35,py27,pep8
skipsdist = True
[testenv]
@ -13,9 +13,11 @@ whitelist_externals =
setenv =
VIRTUAL_ENV={envdir}
PYTHONWARNINGS=default::DeprecationWarning
TESTS_DIR=./kayobe/tests/unit/
OS_STDOUT_CAPTURE=1
OS_STDERR_CAPTURE=1
OS_TEST_TIMEOUT=60
deps = -r{toxinidir}/test-requirements.txt
commands = unit2 discover {posargs}
commands = stestr run {posargs}
[testenv:pep8]
commands =
@ -80,6 +82,18 @@ commands =
-not -name idrac-bootstrap.yml) \
{posargs}"
[testenv:cover]
setenv =
VIRTUAL_ENV={envdir}
PYTHON=coverage run --source kayobe --parallel-mode
commands =
coverage erase
stestr run {posargs}
coverage combine
coverage report
coverage html -d cover
coverage xml -o cover/coverage.xml
[flake8]
# E123, E125 skipped as they are invalid PEP-8.

View File

@ -5,6 +5,7 @@
- openstack-tox-pep8
- openstack-tox-py27
- openstack-tox-py35
- openstack-tox-cover
- build-openstack-sphinx-docs
- kayobe-tox-ansible-syntax
- kayobe-tox-ansible
@ -15,6 +16,7 @@
- openstack-tox-pep8
- openstack-tox-py27
- openstack-tox-py35
- openstack-tox-cover
- build-openstack-sphinx-docs
- kayobe-tox-ansible-syntax
- kayobe-tox-ansible