Enhances tox to not rely on run_tests

Several changes:
 - Dont rely on run_tests.sh and run the commands directly
 - Move the coverage options to the setup.cfg
 - Set py27 envs under the same umbrella
 - Split horizon and openstack_dashboard tests into 2
different envs
 - Remove usedevelop from most envs as its not needed
 - Set basepython to 27 on the default env
 - Allow adding posargs to py34 env
 - Add npm environment which defaults to npm run test
 - Add runserver as a new env
 - Move pep8 to be the first tests so we fail fast
 - Provide an env to tests against system packages, useful
for package builders that DONT want to test against pip
install but their local packages installation.
 - Allow to pass TOX_EXTRA_DEPS to the system_packages
tests in case some extra pip packages are needed
 - Add a manage env to pass commands to manage.py
 - Add an environment to createmessages
 - Add an environment to check only if we can create
messages
 - pep8 environment also runs the check for messages
 - All python commands use {envpython} so no escape
from the venv is possible
 - Uses {toxinidir} for a clear indication of where
the files to be executed are
 - Moves all keywords for pybabel to the setup.cfg
 - Removes not needed whitelist_external for all envs
and uses only git for one specific env

Change-Id: Ia1be8f60265d9dab2639a05912b4b7c51f1d4033
Implements: blueprint enhance-tox
This commit is contained in:
Itxaka 2015-12-17 13:23:36 +01:00 committed by Itxaka
parent 457e0483b0
commit a67d75fa58
2 changed files with 128 additions and 31 deletions

View File

@ -38,3 +38,21 @@ source-dir = doc/source
[nosetests] [nosetests]
verbosity=2 verbosity=2
detailed-errors=1 detailed-errors=1
[coverage:report]
ignore_errors = True
include =
horizon/*
openstack_dashboard/*
omit =
/usr*
setup.py
*egg*
.venv/*
[coverage:html]
directory = reports
[extract_messages]
keywords = gettext_noop gettext_lazy ngettext_lazy:1,2 ugettext_noop ugettext_lazy ungettext_lazy:1,2 npgettext:1c,2,3 pgettext_lazy:1c,2 npgettext_lazy:1c,2,3
add_comments = Translators:

141
tox.ini
View File

@ -1,67 +1,146 @@
[tox] [tox]
envlist = py27,py27dj18,pep8,py34,releasenotes envlist = pep8,py27{-horizon,-openstack_dashboard,dj18},py34,releasenotes
minversion = 1.6 minversion = 1.6
skipsdist = True skipsdist = True
[testenv] [testenv]
usedevelop = True basepython=python2.7
install_command = pip install -U {opts} {packages} install_command = pip install -U {opts} {packages}
setenv = VIRTUAL_ENV={envdir} setenv =
NOSE_WITH_OPENSTACK=1 VIRTUAL_ENV={envdir}
NOSE_OPENSTACK_COLOR=1 INTEGRATION_TESTS=0
NOSE_OPENSTACK_RED=0.05 SELENIUM_HEADLESS=0
NOSE_OPENSTACK_YELLOW=0.025 SELENIUM_PHANTOMJS=0
NOSE_OPENSTACK_SHOW_ELAPSED=1 NOSE_WITH_OPENSTACK=1
deps = -r{toxinidir}/requirements.txt NOSE_OPENSTACK_SHOW_ELAPSED=1
-r{toxinidir}/test-requirements.txt deps =
whitelist_externals = /bin/bash -r{toxinidir}/requirements.txt
commands = /bin/bash run_tests.sh -N --no-pep8 {posargs} -r{toxinidir}/test-requirements.txt
commands =
horizon: {envpython} {toxinidir}/manage.py test horizon --settings=horizon.test.settings {posargs}
openstack_dashboard: {envpython} {toxinidir}/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings --exclude-dir=openstack_dashboard/test/integration_tests {posargs}
[testenv:py27]
commands =
{envpython} {toxinidir}/manage.py test horizon --settings=horizon.test.settings {posargs}
{envpython} {toxinidir}/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings --exclude-dir=openstack_dashboard/test/integration_tests {posargs}
# Django-1.8 is LTS
[testenv:py27dj18]
commands =
pip install django>=1.8,<1.9
{envpython} {toxinidir}/manage.py test horizon --settings=horizon.test.settings {posargs}
{envpython} {toxinidir}/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings --exclude-dir=openstack_dashboard/test/integration_tests {posargs}
[testenv:py34] [testenv:py34]
basepython = python3.4
setenv =
{[testenv]setenv}
PYTHONUNBUFFERED=1
commands = commands =
python -u manage.py test --settings=horizon.test.settings horizon.test.tests {envpython} {toxinidir}/manage.py test --settings=horizon.test.settings horizon.test.tests {posargs}
python -u manage.py test --settings=openstack_dashboard.test.settings \ {envpython} {toxinidir}/manage.py test --settings=openstack_dashboard.test.settings \
--exclude-dir=openstack_dashboard/test/integration_tests \ --exclude-dir=openstack_dashboard/test/integration_tests \
openstack_dashboard openstack_dashboard {posargs}
[testenv:pep8] [testenv:pep8]
usedevelop = True
whitelist_externals =
git
setenv =
{[testenv]setenv}
DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings
commands = commands =
/bin/bash run_tests.sh -N --pep8 {[testenv:extractmessages_check]commands}
/bin/bash run_tests.sh -N --makemessages --check-only flake8
[testenv:extractmessages]
usedevelop = True
setenv =
{[testenv]setenv}
commands =
{envpython} {toxinidir}/setup.py extract_messages -F babel-django.cfg -o horizon/locale/django.pot --input-dirs horizon/
{envpython} {toxinidir}/setup.py extract_messages -F babel-djangojs.cfg -o horizon/locale/djangojs.pot --input-dirs horizon/
{envpython} {toxinidir}/setup.py extract_messages -F babel-django.cfg -o openstack_dashboard/locale/django.pot --input-dirs openstack_dashboard/
{envpython} {toxinidir}/setup.py extract_messages -F babel-djangojs.cfg -o openstack_dashboard/locale/djangojs.pot --input-dirs openstack_dashboard/
[testenv:extractmessages_check]
# Only checks to see if translation files can be extracted and cleans afterwards
usedevelop = True
whitelist_externals =
git
setenv =
{[testenv]setenv}
commands =
{[testenv:extractmessages]commands}
git checkout -- horizon/locale/django*.pot
git checkout -- openstack_dashboard/locale/django*.pot
[testenv:compilemessages]
usedevelop = False
commands =
/bin/bash {toxinidir}/run_tests.sh --compilemessages -N
[testenv:venv] [testenv:venv]
commands = {posargs} commands = {posargs}
[testenv:cover] [testenv:manage]
commands = /bin/bash run_tests.sh -N --no-pep8 --coverage {posargs} # Env to launch manage.py commands
commands = {envpython} {toxinidir}/manage.py {posargs}
# Django-1.8 is LTS [testenv:cover]
[testenv:py27dj18] commands =
basepython = python2.7 coverage erase
commands = pip install django>=1.8,<1.9 coverage run {toxinidir}/manage.py test horizon --settings=horizon.test.settings {posargs}
/bin/bash run_tests.sh -N --no-pep8 {posargs} coverage run {toxinidir}/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings --exclude-dir=openstack_dashboard/test/integration_tests {posargs}
coverage combine
coverage xml
coverage html
[testenv:py27dj19] [testenv:py27dj19]
commands = pip install django>=1.9,<1.10 commands = pip install django>=1.9,<1.10
/bin/bash run_tests.sh -N --no-pep8 {posargs} /bin/bash run_tests.sh -N --no-pep8 {posargs}
[testenv:py27integration] [testenv:py27integration]
# Run integration tests only
setenv =
PYTHONHASHSEED=0
INTEGRATION_TESTS=1
SELENIUM_HEADLESS=1
NOSE_WITH_OPENSTACK=1
NOSE_OPENSTACK_SHOW_ELAPSED=1
basepython = python2.7 basepython = python2.7
commands = /bin/bash run_tests.sh -N --integration --selenium-headless {posargs} commands = nosetests openstack_dashboard.test.integration_tests {posargs}
[testenv:eslint] [testenv:npm]
passenv = * commands =
commands = nodeenv -p nodeenv -p
npm install npm install
/bin/bash run_tests.sh -N --eslint npm run {posargs:test}
[testenv:docs] [testenv:docs]
setenv = DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings setenv = DJANGO_SETTINGS_MODULE=openstack_dashboard.test.settings
commands = python setup.py build_sphinx commands = {envpython} {toxinidir}/setup.py build_sphinx
[testenv:releasenotes] [testenv:releasenotes]
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
[testenv:runserver]
commands = {envpython} {toxinidir}/manage.py runserver {posargs}
[testenv:tests_system_packages]
# Provide an environment for system packagers that dont want anything from pip
# Any extra deps needed for this env can be passed by setting TOX_EXTRA_DEPS
sitepackages = True
passenv = TOX_EXTRA_DEPS
# Sets deps to an empty list so nothing is installed from pip
deps =
commands =
pip install -U {env:TOX_EXTRA_DEPS:}
{envpython} {toxinidir}/manage.py test horizon --settings=horizon.test.settings {posargs}
{envpython} {toxinidir}/manage.py test openstack_dashboard --settings=openstack_dashboard.test.settings {posargs}
[flake8] [flake8]
exclude = .venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject exclude = .venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,panel_template,dash_template,local_settings.py,*/local/*,*/test/test_plugins/*,.ropeproject
# H405 multi line docstring summary not separated with an empty line # H405 multi line docstring summary not separated with an empty line