]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Bug #890028
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Mon, 14 Nov 2011 00:48:28 +0000 (00:48 +0000)
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Wed, 14 Dec 2011 00:33:37 +0000 (00:33 +0000)
Change run_tests.sh for running pep8/pylint validation only
(also adds .pylintrc file)

Resubmitting this time making sure we run pylint for Quantum!
Also run just with -l for total number of messages
Run with -l -v for detailed pylint messages

Change-Id: I593c8aed4e0e6b06204c6c4308934da198778fd6

.pylintrc [new file with mode: 0644]
run_tests.sh
setup_server.py
version.py

diff --git a/.pylintrc b/.pylintrc
new file mode 100644 (file)
index 0000000..bd677fd
--- /dev/null
+++ b/.pylintrc
@@ -0,0 +1,42 @@
+# The format of this file isn't really documented; just use --generate-rcfile
+[MASTER]
+# Add <file or directory> to the black list. It should be a base name, not a
+# path. You may set this option multiple times.
+ignore=test
+
+[Messages Control]
+# NOTE(justinsb): We might want to have a 2nd strict pylintrc in future
+# C0111: Don't require docstrings on every method
+# W0511: TODOs in code comments are fine.
+# W0142: *args and **kwargs are fine.
+# W0622: Redefining id is fine.
+disable=C0111,W0511,W0142,W0622
+
+[Basic]
+# Variable names can be 1 to 31 characters long, with lowercase and underscores
+variable-rgx=[a-z_][a-z0-9_]{0,30}$
+
+# Argument names can be 2 to 31 characters long, with lowercase and underscores
+argument-rgx=[a-z_][a-z0-9_]{1,30}$
+
+# Method names should be at least 3 characters long
+# and be lowecased with underscores
+method-rgx=([a-z_][a-z0-9_]{2,50}|setUp|tearDown)$
+
+# Module names matching quantum-* are ok (files in bin/)
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|(quantum-[a-z0-9_-]+))$
+
+# Don't require docstrings on tests.
+no-docstring-rgx=((__.*__)|([tT]est.*)|setUp|tearDown)$
+
+[Design]
+max-public-methods=100
+min-public-methods=0
+max-args=6
+
+[Variables]
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+# _ is used by our localization
+additional-builtins=_
index 365cde61aa33726facf45ac676ed5b062c4d2645..ddd59a7cec544f6e6bb227b62fc8f1c7b63044e0 100755 (executable)
@@ -8,6 +8,9 @@ function usage {
   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 "  -l, --pylint             Just run pylint"
+  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,"
@@ -22,6 +25,8 @@ function process_option {
     -V|--virtual-env) let always_venv=1; let never_venv=0;;
     -N|--no-virtual-env) let always_venv=0; let never_venv=1;;
     -f|--force) let force=1;;
+    -p|--pep8) let just_pep8=1;let never_venv=1; let always_venv=0;;
+    -l|--pylint) let just_pylint=1; let never_venv=1; let always_venv=0;;
     -c|--coverage) coverage=1;;
     -v|--verbose) verbose=1;;
     -*) noseopts="$noseopts $1";;
@@ -33,6 +38,8 @@ venv=.quantum-venv
 with_venv=tools/with_venv.sh
 always_venv=0
 never_venv=0
+just_pep8=0
+just_pylint=0
 force=0
 noseargs=
 wrapper=""
@@ -69,6 +76,30 @@ function run_tests {
   return $RESULT
 }
 
+function run_pylint {
+  echo "Running pylint ..."
+  PYLINT_OPTIONS="--rcfile=.pylintrc --output-format=parseable"
+  PYLINT_INCLUDE="quantum"
+  OLD_PYTHONPATH=$PYTHONPATH
+  export PYTHONPATH=$PYTHONPATH:.quantum:./client/lib/quantum:./common/lib/quantum
+
+  BASE_CMD="pylint $PYLINT_OPTIONS $PYLINT_INCLUDE"
+  [ $verbose -eq 1 ] && $BASE_CMD || msg_count=`$BASE_CMD | grep 'quantum/' | wc -l`
+  if [ $verbose -eq 0 ]; then
+    echo "Pylint messages count: " $msg_count
+  fi
+  export PYTHONPATH=$OLD_PYTHONPATH
+}
+
+function run_pep8 {
+  echo "Running pep8 ..."
+
+  PEP8_EXCLUDE="vcsversion.py,*.pyc"
+  PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-source"
+  PEP8_INCLUDE="bin/* quantum run_tests.py setup*.py version.py"
+  ${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE
+}
+
 NOSETESTS="python ./$PLUGIN_DIR/run_tests.py $noseopts $noseargs"
 
 if [ -n "$PLUGIN_DIR" ]
@@ -111,17 +142,17 @@ if [ $coverage -eq 1 ]; then
     ${wrapper} coverage erase
 fi
 
-# FIXME(sirp): bzr version-info is not currently pep-8. This was fixed with
-# lp701898 [1], however, until that version of bzr becomes standard, I'm just
-# excluding the vcsversion.py file
-#
-# [1] https://bugs.launchpad.net/bzr/+bug/701898
-#
-PEP8_EXCLUDE="vcsversion.py,*.pyc"
-PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-source"
-PEP8_INCLUDE="bin/* quantum tools run_tests.py setup.py"
+if [ $just_pep8 -eq 1 ]; then
+    run_pep8
+    exit
+fi
+if [ $just_pylint -eq 1 ]; then
+    run_pylint
+    exit
+fi
+
 RV=0
-run_tests && pep8 $PEP8_OPTIONS $PEP8_INCLUDE || RV=1
+run_tests && run_pep8 || RV=1
 
 if [ $coverage -eq 1 ]; then
     echo "Generating coverage report in covhtml/"
index c5590a1a5401ef11b519e7183e1e63625c750f16..ad9e5ac767c2d571eaf30184d9e42eb8104e05ba 100644 (file)
@@ -47,13 +47,14 @@ if [x for x in relative_locations if x in sys.argv]:
 import os
 from distutils.command.build_py import build_py as _build_py
 
+
 class build_py(_build_py):
     def find_data_files(self, package, src_dir):
         files = []
         for p in _build_py.find_data_files(self, package, src_dir):
             if os.path.isdir(p):
-                files.extend(os.path.join(par,f)
-                             for par,dirs,files in os.walk(p) 
+                files.extend(os.path.join(par, f)
+                             for par, dirs, files in os.walk(p)
                              for f in files)
             else:
                 files.append(p)
index 46bf34a5927c002d18fe9c4f68b0bfcd96d8799a..f78426bde69e692049967be74659a71c3906fafd 100644 (file)
@@ -35,7 +35,8 @@ __all__ = ("get_git_version")
 
 from subprocess import Popen, PIPE
 
-FALLBACK_VERSION="2012.1dev"
+FALLBACK_VERSION = "2012.1dev"
+
 
 def call_git_describe(abbrev=4):
     try: