From 3dbb31b81a85125fd97d96161e087acd5dc364f9 Mon Sep 17 00:00:00 2001 From: Kieran Spear Date: Wed, 9 Oct 2013 16:21:22 +1100 Subject: [PATCH] Run flake8 tests automatically on ./run_tests.sh And add a -P option to disable it. Change-Id: Ie0039217c82acbd9c9071da27027f57263b39f25 Closes-bug: #1237202 --- run_tests.sh | 14 ++++++++++++-- tox.ini | 6 +++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index 12d5d91f58..e4b6be2d81 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -25,6 +25,7 @@ function usage { echo " --makemessages Update all translation files." echo " --compilemessages Compile all translation files." echo " -p, --pep8 Just run pep8" + echo " -P, --no-pep8 Don't run pep8 by default" echo " -t, --tabs Check for tab characters in files." echo " -y, --pylint Just run pylint" echo " -q, --quiet Run non-interactively. (Relatively) quiet." @@ -60,6 +61,7 @@ command_wrapper="" destroy=0 force=0 just_pep8=0 +no_pep8=0 just_pylint=0 just_docs=0 just_tabs=0 @@ -91,6 +93,7 @@ function process_option { -V|--virtual-env) always_venv=1; never_venv=0;; -N|--no-virtual-env) always_venv=0; never_venv=1;; -p|--pep8) just_pep8=1;; + -P|--no-pep8) no_pep8=1;; -y|--pylint) just_pylint=1;; -f|--force) force=1;; -t|--tabs) just_tabs=1;; @@ -321,12 +324,19 @@ function run_tests_all { # Remove the leftover coverage files from the -p flag earlier. rm -f .coverage.* - if [ $(($HORIZON_RESULT || $DASHBOARD_RESULT)) -eq 0 ]; then + PEP8_RESULT=0 + if [ $no_pep8 -eq 0 ] && [ $only_selenium -eq 0 ]; then + run_pep8 + PEP8_RESULT=$? + fi + + TEST_RESULT=$(($HORIZON_RESULT || $DASHBOARD_RESULT || $PEP8_RESULT)) + if [ $TEST_RESULT -eq 0 ]; then echo "Tests completed successfully." else echo "Tests failed." fi - exit $(($HORIZON_RESULT || $DASHBOARD_RESULT)) + exit $TEST_RESULT } function run_makemessages { diff --git a/tox.ini b/tox.ini index 45dd51149f..e468417e16 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ setenv = VIRTUAL_ENV={envdir} NOSE_OPENSTACK_SHOW_ELAPSED=1 deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt -commands = /bin/bash run_tests.sh -N +commands = /bin/bash run_tests.sh -N --no-pep8 [testenv:pep8] commands = /bin/bash run_tests.sh -N --pep8 @@ -19,12 +19,12 @@ commands = /bin/bash run_tests.sh -N --pep8 commands = {posargs} [testenv:cover] -commands = /bin/bash run_tests.sh -N --coverage +commands = /bin/bash run_tests.sh -N --no-pep8 --coverage [testenv:py27dj14] basepython = python2.7 commands = pip install django==1.4 - /bin/bash run_tests.sh -N + /bin/bash run_tests.sh -N --no-pep8 [tox:jenkins] downloadcache = ~/cache/pip