From 5d55cfde1d9818aaea024b60843751f0cde0f394 Mon Sep 17 00:00:00 2001 From: "Gael Chamoulaud (Strider)" Date: Thu, 26 Nov 2020 11:40:06 +0100 Subject: [PATCH] Make the measuring code coverage test working Change-Id: I9e28b3b08685ea7a7ae1ed73888d8160728f5ded Signed-off-by: Gael Chamoulaud (Strider) --- .coveragerc | 4 ++-- .gitignore | 2 +- .stestr.conf | 2 +- .zuul.yaml | 1 + test-requirements.txt | 2 +- tox.ini | 35 +++++++++++++++++++++++++++-------- 6 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.coveragerc b/.coveragerc index 9fb5d66b..153a8010 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,7 +1,7 @@ [run] branch = True -source = validations-libs -omit = validations-libs/openstack/* +source = validations_libs +omit = validations_libs/tests/* [report] ignore_errors = True diff --git a/.gitignore b/.gitignore index 00453264..ad71cee2 100644 --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,7 @@ cover/ nosetests.xml .testrepository .venv -.stestr/ +.stestr/* # Translations *.mo diff --git a/.stestr.conf b/.stestr.conf index 9aa8d091..15169c49 100644 --- a/.stestr.conf +++ b/.stestr.conf @@ -1,3 +1,3 @@ [DEFAULT] -test_path=./validations_libs/tests +test_path=${TEST_PATH:-./validations_libs/tests} top_dir=./ diff --git a/.zuul.yaml b/.zuul.yaml index 83ae36a1..09a77214 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -22,6 +22,7 @@ check: jobs: - openstack-tox-linters + - openstack-tox-cover - openstack-tox-docs: &tripleo-docs files: - ^doc/.* diff --git a/test-requirements.txt b/test-requirements.txt index 53edb204..ceccf64c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -10,7 +10,7 @@ pyflakes>=2.1.1 coverage!=4.4,>=4.0 # Apache-2.0 python-subunit>=1.0.0 # Apache-2.0/BSD -stestr>=1.0.0 # Apache-2.0 +stestr>=2.0.0 # Apache-2.0 testscenarios>=0.4 # Apache-2.0/BSD testtools>=2.2.0 # MIT pre-commit # MIT diff --git a/tox.ini b/tox.ini index 16c3d574..0aab79c6 100644 --- a/tox.ini +++ b/tox.ini @@ -3,18 +3,27 @@ minversion = 3.2.0 envlist = linters,docs,py38 skipdist = True +# Automatic envs (pyXX) will only use the python version appropriate to that +# env and ignore basepython inherited from [testenv] if we set +# ignore_basepython_conflict. +ignore_basepython_conflict = True + [testenv] usedevelop = True -passenv = * +passenv = + TERM setenv = # pip: Avoid 2020-01-01 warnings: https://github.com/pypa/pip/issues/6207 # paramiko CryptographyDeprecationWarning: https://github.com/ansible/ansible/issues/52598 PYTHONWARNINGS=ignore:DEPRECATION::pip._internal.cli.base_command,ignore::UserWarning PIP_DISABLE_PIP_VERSION_CHECK=1 + VIRTUAL_ENV={envdir} + LANG=en_US.UTF-8 + LANGUAGE=en_US:en + LC_ALL=C + HOME={envdir} commands = - stestr run {posargs} - stestr slowest -sitepackages = True + stestr run --slowest --color {posargs} deps = -c {env:TOX_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt} -r {toxinidir}/requirements.txt @@ -57,11 +66,21 @@ commands = {[testenv:whitespace]commands} {[testenv:shebangs]commands} +[testenv:venv] +commands = {posargs} +passenv = * + [testenv:cover] -deps = - -r {toxinidir}/requirements.txt - -r {toxinidir}/test-requirements.txt -commands = python setup.py test --coverage --testr-args='{posargs}' +setenv = + PYTHON=coverage run --source validations_libs --parallel-mode + HOME={envdir} +commands = + coverage erase + stestr run --color {posargs} + coverage combine + coverage html -d cover + coverage xml -o cover/coverage.xml + coverage report [testenv:docs] deps =