diff options
-rw-r--r-- | .travis.yml | 2 | ||||
-rw-r--r-- | CONTRIBUTING.rst | 4 | ||||
-rwxr-xr-x | run_tests.sh | 56 | ||||
-rw-r--r-- | tools/test-requires | 2 | ||||
-rw-r--r-- | tox.ini | 24 |
5 files changed, 52 insertions, 36 deletions
diff --git a/.travis.yml b/.travis.yml index 9e5474a1..6c6e7f42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ env: - TOX_ENV=py34 - TOX_ENV=py35 - TOX_ENV=pypy26 - - TOX_ENV=pep8 + - TOX_ENV=pycodestyle services: - docker diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 8e4945d3..c98c79be 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -20,7 +20,7 @@ style. # You can send patches by "git send-email" command $ git send-email --to="ryu-devel@lists.sourceforge.net" *.patch -Please check your changes with pep8 and run unittests to make sure +Please check your changes with pycodestyle(pep8) and run unittests to make sure that they don't break the existing features. The following command does both for you. @@ -29,7 +29,7 @@ does both for you. # Install dependencies of tests $ pip install -r tools/test-requires - # Execute unit tests and pep8 + # Execute unit tests and pycodestyle(pep8) $ ./run_tests.sh Of course, you are encouraged to add unittests when you add new diff --git a/run_tests.sh b/run_tests.sh index 1ab8aea7..659015fa 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -8,16 +8,16 @@ usage() { echo "Usage: $0 [OPTION]..." echo "Run Ryu's test suite(s)" echo "" - echo " -V, --virtual-env Always use virtualenv. Install automatically if not present" - echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment" - echo " -c, --coverage Generate coverage report" - echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." - echo " -p, --pep8 Just run pep8" - echo " -P, --no-pep8 Don't run pep8" - echo " -l, --pylint Just run pylint" - echo " -i, --integrated Run integrated test" - echo " -v, --verbose Run verbose pylint analysis" - echo " -h, --help Print this usage message" + echo " -V, --virtual-env Always use virtualenv. Install automatically if not present" + echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment" + echo " -c, --coverage Generate coverage report" + echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." + echo " -p, --pycodestyle, --pep8 Just run pycodestyle(pep8)" + echo " -P, --no-pycodestyle, --no-pep8 Don't run pycodestyle(pep8)" + echo " -l, --pylint Just run pylint" + echo " -i, --integrated Run integrated test" + echo " -v, --verbose Run verbose pylint analysis" + echo " -h, --help Print this usage message" echo "" echo "Note: with no options specified, the script will try to run the tests in a virtual environment," echo " If no virtualenv is found, the script will ask if you would like to create one. If you " @@ -31,8 +31,8 @@ process_option() { -V|--virtual-env) always_venv=1; never_venv=0;; -N|--no-virtual-env) always_venv=0; never_venv=1;; -f|--force) force=1;; - -p|--pep8) just_pep8=1; never_venv=1; always_venv=0;; - -P|--no-pep8) no_pep8=1;; + -p|--pycodestyle|--pep8) just_pycodestyle=1; never_venv=1; always_venv=0;; + -P|--no-pycodestyle|--no-pep8) no_pycodestyle=1;; -l|--pylint) just_pylint=1;; -i|--integrated) integrated=1;; -c|--coverage) coverage=1;; @@ -46,8 +46,8 @@ venv=.venv with_venv=tools/with_venv.sh always_venv=0 never_venv=0 -just_pep8=0 -no_pep8=0 +just_pycodestyle=0 +no_pycodestyle=0 just_pylint=0 integrated=0 force=0 @@ -103,20 +103,26 @@ run_pylint() { export PYTHONPATH=$OLD_PYTHONPATH } -run_pep8() { - echo "Running pep8 ..." +run_pycodestyle() { + PYCODESTYLE=$(which pycodestyle || which pep8) + if [ -z "${PYCODESTYLE}" ] + then + echo "Please install pycodestyle or pep8" + return 1 + fi + echo "Running $(basename ${PYCODESTYLE}) ..." - PEP8_OPTIONS="--repeat --show-source" - PEP8_INCLUDE="ryu setup*.py" - PEP8_LOG=pep8.log - ${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE | tee $PEP8_LOG + PYCODESTYLE_OPTIONS="--repeat --show-source" + PYCODESTYLE_INCLUDE="ryu setup*.py" + PYCODESTYLE_LOG=pycodestyle.log + ${wrapper} ${PYCODESTYLE} $PYCODESTYLE_OPTIONS $PYCODESTYLE_INCLUDE | tee $PYCODESTYLE_LOG } run_integrated() { echo "Running integrated test ..." INTEGRATED_TEST_RUNNER="./ryu/tests/integrated/run_tests_with_ovs12.py" - sudo PYTHONPATH=. nosetests -s $INTEGRATED_TEST_RUNNER + sudo PYTHONPATH=. nosetests -s $INTEGRATED_TEST_RUNNER } #NOSETESTS="nosetests $noseopts $noseargs" NOSETESTS="${PYTHON} ./ryu/tests/run_tests.py $noseopts $noseargs" @@ -161,8 +167,8 @@ if [ $coverage -eq 1 ]; then ${wrapper} coverage erase fi -if [ $just_pep8 -eq 1 ]; then - run_pep8 +if [ $just_pycodestyle -eq 1 ]; then + run_pycodestyle exit fi if [ $just_pylint -eq 1 ]; then @@ -177,8 +183,8 @@ fi run_tests RV=$? -if [ $no_pep8 -eq 0 ]; then - run_pep8 +if [ $no_pycodestyle -eq 0 ]; then + run_pycodestyle fi if [ $coverage -eq 1 ]; then diff --git a/tools/test-requires b/tools/test-requires index 9d59a70c..dd90cb5e 100644 --- a/tools/test-requires +++ b/tools/test-requires @@ -1,6 +1,6 @@ coverage mock nose -pep8 +pycodestyle pylint formencode @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,pypy26,pep8 +envlist = py27,py34,py35,pypy26,pycodestyle [testenv] deps = @@ -30,15 +30,25 @@ commands = {[testenv]commands} {[testenv:scenario]commands} -[testenv:pep8] +[testenv:pycodestyle] deps = -U --no-cache-dir - pep8 + pycodestyle commands = - pep8 + pycodestyle -[pep8] -exclude = pbr-*,.venv,.tox,.git,doc,dist,tools,vcsversion.py,.pyc,ryu/contrib,dictconfig.py -ignore = E113,E116,E402,E711,E731,E501,W503 +[pycodestyle] +exclude = pbr-*,.venv,.tox,.git,doc,dist,tools,vcsversion.py,.pyc,ryu/contrib +# W503: line break occurred before a binary operator +# E116: unexpected indentation (comment) +# E402: module level import not at top of file +# E501: line too long (>79 characters) +# E722: do not use bare except, specify exception instead +# E731: do not assign a lambda expression, use a def +# E741: do not use variables named 'l', 'O', or 'I' +ignore = W503,E116,E402,E501,E722,E731,E741 +[pep8] +exclude = pbr-*,.venv,.tox,.git,doc,dist,tools,vcsversion.py,.pyc,ryu/contrib +ignore = W503,E116,E402,E501,E722,E731,E741 |