Add HACKING compliance testing to run_test.sh

Tests so far:
N101 TODO format
N201 Except format
N301 One import per line
N302 import only modules
N303 Invalid Import
N304 Relative Import

Change-Id: I33c021b842e7199b1f5f1f699ea17f7fa5f8ca49
This commit is contained in:
Joe Gordon
2012-01-20 00:50:56 -08:00
parent 351b435480
commit 93025ede47

View File

@@ -15,6 +15,7 @@ function usage {
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 " -H, --hacking Just run HACKING compliance testing"
echo " -c, --coverage Generate coverage report"
echo " -h, --help Print this usage message"
echo " --hide-elapsed Don't print the elapsed time for each test along with slow test list"
@@ -36,6 +37,7 @@ function process_option {
-f|--force) force=1;;
-p|--pep8) just_pep8=1;;
-P|--no-pep8) no_pep8=1;;
-H|--hacking) just_hacking=1;;
-c|--coverage) coverage=1;;
-*) noseopts="$noseopts $1";;
*) noseargs="$noseargs $1"
@@ -54,6 +56,7 @@ noseopts=
wrapper=""
just_pep8=0
no_pep8=0
just_hacking=0
coverage=0
recreate_db=1
@@ -116,6 +119,21 @@ function run_pep8 {
${wrapper} pep8 ${pep8_opts} ${srcfiles}
}
function run_hacking {
echo "Running hacking compliance testing..."
# Opt-out files from pep8
ignore_scripts="*.sh:*nova-debug:*clean-vlans:*.swp"
ignore_files="*eventlet-patch:*pip-requires"
ignore_dirs="*ajaxterm*"
GLOBIGNORE="$ignore_scripts:$ignore_files:$ignore_dirs"
srcfiles=`find bin -type f ! -name "nova.conf*"`
srcfiles+=" `find tools/*`"
srcfiles+=" nova setup.py plugins/xenserver/xenapi/etc/xapi.d/plugins/glance"
hacking_opts="--ignore=E202,W602 --repeat"
${wrapper} python tools/hacking.py ${hacking_opts} ${srcfiles}
}
NOSETESTS="python nova/testing/runner.py $noseopts $noseargs"
if [ $never_venv -eq 0 ]
@@ -154,6 +172,12 @@ if [ $just_pep8 -eq 1 ]; then
exit
fi
if [ $just_hacking -eq 1 ]; then
run_hacking
exit
fi
if [ $recreate_db -eq 1 ]; then
rm -f tests.sqlite
fi