From c135ffaad2c386b16703b3d488b2e16e87e8ab96 Mon Sep 17 00:00:00 2001 From: wangbo Date: Fri, 27 May 2016 11:54:02 +0800 Subject: [PATCH] Enable tox to run the subset test cases. Now the tox.ini is hardcode that could only run all test cases in horizon/ and openstack_dashboard/. Following usage does not work: "tox -e py27 openstack_dashboard.test.tests.policy:PolicyTestCase" This patch enable pass args to run subset test cases. Remove envs py27{-horizon,-openstack_dashboard}, you could run "tox -e py27 horizon/openstack_dashboard". Partially-Implements: blueprint enhance-tox Change-Id: I21224d49a7a6e07d0184871b21268199def76db6 --- tox.ini | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/tox.ini b/tox.ini index 7d1bd15326..8e654214ff 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = pep8,py27{-horizon,-openstack_dashboard,dj18},py34,releasenotes +envlist = pep8,py27dj18,py27,py34,releasenotes minversion = 1.6 skipsdist = True @@ -16,14 +16,18 @@ setenv = deps = -r{toxinidir}/requirements.txt -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] +whitelist_externals = + bash 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} + bash -c 'project=`echo {posargs} | cut -d. -f1`; \ + if [ -z "$project" ]; then \ + {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}; \ + else \ + {envpython} {toxinidir}/manage.py test {posargs} --settings=$project.test.settings --exclude-dir=openstack_dashboard/test/integration_tests; \ + fi' # Django-1.8 is LTS [testenv:py27dj18] @@ -37,11 +41,16 @@ basepython = python3.4 setenv = {[testenv]setenv} PYTHONUNBUFFERED=1 +whitelist_externals = + bash commands = - {envpython} {toxinidir}/manage.py test --settings=horizon.test.settings horizon.test.tests {posargs} - {envpython} {toxinidir}/manage.py test --settings=openstack_dashboard.test.settings \ - --exclude-dir=openstack_dashboard/test/integration_tests \ - openstack_dashboard {posargs} + bash -c 'project=`echo {posargs} | cut -d. -f1`; \ + if [ -z "$project" ]; then \ + {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}; \ + else \ + {envpython} {toxinidir}/manage.py test {posargs} --settings=$project.test.settings --exclude-dir=openstack_dashboard/test/integration_tests; \ + fi' [testenv:pep8] usedevelop = True