updating run_tests.sh to mimic other openstack projects, pep8, pylint, coverage
This commit is contained in:
parent
0a359002ef
commit
6d633a9ec7
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,6 +1,8 @@
|
||||
*.pyc
|
||||
*.swp
|
||||
django-openstack/.coverage
|
||||
.coverage
|
||||
coverage.xml
|
||||
reports
|
||||
django-openstack/.installed.cfg
|
||||
django-openstack/bin
|
||||
django-openstack/develop-eggs/
|
||||
|
42
.pylintrc
Normal file
42
.pylintrc
Normal file
@ -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 keystone-* are ok (files in bin/)
|
||||
module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+)|(keystone-[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=_
|
@ -27,6 +27,7 @@ eggs =
|
||||
django-mailer
|
||||
httplib2
|
||||
python-cloudfiles
|
||||
coverage
|
||||
interpreter = python
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ PasteDeploy
|
||||
sqlalchemy-migrate
|
||||
eventlet
|
||||
xattr
|
||||
coverage
|
||||
|
||||
bzr+https://launchpad.net/glance#egg=glance
|
||||
bzr+https://launchpad.net/quantum#egg=quantum
|
||||
|
154
run_tests.sh
154
run_tests.sh
@ -1,18 +1,146 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd django-openstack
|
||||
python bootstrap.py
|
||||
bin/buildout
|
||||
bin/test
|
||||
# get results of the django-openstack tests
|
||||
OPENSTACK_RESULT=$?
|
||||
function usage {
|
||||
echo "Usage: $0 [OPTION]..."
|
||||
echo "Run Maestro's test suite(s)"
|
||||
echo ""
|
||||
echo " -V, --virtual-env Always use virtualenv. Install automatically"
|
||||
echo " if not present"
|
||||
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local"
|
||||
echo " environment"
|
||||
echo " -f, --force Force a clean re-build of the virtual"
|
||||
echo " environment. Useful when dependencies have"
|
||||
echo " been added."
|
||||
echo " -p, --pep8 Just run pep8"
|
||||
echo " -y, --pylint Just run pylint"
|
||||
echo " -h, --help Print this usage message"
|
||||
echo ""
|
||||
echo "Note: with no options specified, the script will try to run the tests in"
|
||||
echo " a virtual environment, If no virtualenv is found, the script will ask"
|
||||
echo " if you would like to create one. If you prefer to run tests NOT in a"
|
||||
echo " virtual environment, simply pass the -N option."
|
||||
exit
|
||||
}
|
||||
|
||||
cd ../openstack-dashboard
|
||||
python tools/install_venv.py
|
||||
function process_option {
|
||||
case "$1" in
|
||||
-h|--help) usage;;
|
||||
-V|--virtual-env) let always_venv=1; let never_venv=0;;
|
||||
-N|--no-virtual-env) let always_venv=0; let never_venv=1;;
|
||||
-p|--pep8) let just_pep8=1;;
|
||||
-y|--pylint) let just_pylint=1;;
|
||||
-f|--force) let force=1;;
|
||||
*) testargs="$testargs $1"
|
||||
esac
|
||||
}
|
||||
|
||||
cp local/local_settings.py.example local/local_settings.py
|
||||
tools/with_venv.sh dashboard/manage.py test
|
||||
# get results of the openstack-dashboard tests
|
||||
DASHBOARD_RESULT=$?
|
||||
function run_pylint {
|
||||
echo "Running pylint ..."
|
||||
PYLINT_INCLUDE="openstack-dashboard/dashboard django-openstack/django_openstack"
|
||||
${wrapper} pylint --rcfile=.pylintrc -f parseable $PYLINT_INCLUDE > pylint.txt
|
||||
CODE=$?
|
||||
grep Global -A2 pylint.txt
|
||||
if [ $CODE -lt 32 ]
|
||||
then
|
||||
exit 0
|
||||
else
|
||||
exit $CODE
|
||||
fi
|
||||
}
|
||||
|
||||
exit $(($OPENSTACK_RESULT || $DASHBOARD_RESULT))
|
||||
function run_pep8 {
|
||||
echo "Running pep8 ..."
|
||||
PEP8_EXCLUDE=vcsversion.py
|
||||
PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-pep8 --show-source"
|
||||
PEP8_INCLUDE="openstack-dashboard/dashboard django-openstack/django_openstack"
|
||||
${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE > pep8.txt
|
||||
#perl string strips out the [ and ] characters
|
||||
#${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE | perl -ple 's/: ([WE]\d+)/: [$1]/' > pep8.txt
|
||||
}
|
||||
|
||||
|
||||
# DEFAULTS FOR RUN_TESTS.SH
|
||||
#
|
||||
venv=openstack-dashboard/.dashboard-venv
|
||||
django_with_venv=openstack-dashboard/tools/with_venv.sh
|
||||
dashboard_with_venv=tools/with_venv.sh
|
||||
always_venv=0
|
||||
never_venv=0
|
||||
force=0
|
||||
testargs=""
|
||||
django_wrapper=""
|
||||
dashboard_wrapper=""
|
||||
just_pep8=0
|
||||
just_pylint=0
|
||||
|
||||
# PROCESS ARGUMENTS, OVERRIDE DEFAULTS
|
||||
for arg in "$@"; do
|
||||
process_option $arg
|
||||
done
|
||||
|
||||
if [ $never_venv -eq 0 ]
|
||||
then
|
||||
# Remove the virtual environment if --force used
|
||||
if [ $force -eq 1 ]; then
|
||||
echo "Cleaning virtualenv..."
|
||||
rm -rf ${venv}
|
||||
fi
|
||||
if [ -e ${venv} ]; then
|
||||
django_wrapper="${django_with_venv}"
|
||||
dashboard_wrapper="${dashboard_with_venv}"
|
||||
else
|
||||
if [ $always_venv -eq 1 ]; then
|
||||
# Automatically install the virtualenv
|
||||
python tools/install_venv.py
|
||||
django_wrapper="${django_with_venv}"
|
||||
dashboard_wrapper="${dashboard_with_venv}"
|
||||
else
|
||||
echo -e "No virtual environment found...create one? (Y/n) \c"
|
||||
read use_ve
|
||||
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
|
||||
# Install the virtualenv and run the test suite in it
|
||||
python tools/install_venv.py
|
||||
django_wrapper="${django_with_venv}"
|
||||
dashboard_wrapper="${dashboard_with_venv}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
function run_tests {
|
||||
echo "Running django-openstack (core django) tests"
|
||||
${django_wrapper} coverage erase
|
||||
cd django-openstack
|
||||
python bootstrap.py
|
||||
bin/buildout
|
||||
cd ..
|
||||
${django_wrapper} coverage run django-openstack/bin/test
|
||||
# get results of the django-openstack tests
|
||||
OPENSTACK_RESULT=$?
|
||||
|
||||
echo "Running openstack-dashboard (django website) tests"
|
||||
cd openstack-dashboard
|
||||
cp local/local_settings.py.example local/local_settings.py
|
||||
${dashboard_wrapper} coverage run dashboard/manage.py test
|
||||
# get results of the openstack-dashboard tests
|
||||
DASHBOARD_RESULT=$?
|
||||
cd ..
|
||||
|
||||
echo "Generating coverage reports"
|
||||
${django_wrapper} coverage combine
|
||||
${django_wrapper} coverage xml --omit='/usr*,setup.py,*egg*'
|
||||
${django_wrapper} coverage html --omit='/usr*,setup.py,*egg*' -d reports
|
||||
exit $(($OPENSTACK_RESULT || $DASHBOARD_RESULT))
|
||||
}
|
||||
|
||||
if [ $just_pep8 -eq 1 ]; then
|
||||
run_pep8
|
||||
exit $?
|
||||
fi
|
||||
|
||||
if [ $just_pylint -eq 1 ]; then
|
||||
run_pylint
|
||||
exit $?
|
||||
fi
|
||||
|
||||
run_tests || exit
|
||||
|
Loading…
Reference in New Issue
Block a user