13
13
echo " -n, --no-recreate-db Don't recreate the test database."
14
14
echo " -x, --stop Stop running tests after the first error or failure."
15
15
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
16
echo " -p, --pep8 Just run pep8"
17
echo " -P, --no-pep8 Don't run pep8"
18
echo " -H, --hacking Just run HACKING compliance testing"
16
echo " -p, --pep8 Just run PEP8 and HACKING compliance check"
17
echo " -P, --no-pep8 Don't run static code checks"
19
18
echo " -c, --coverage Generate coverage report"
20
19
echo " -h, --help Print this usage message"
21
20
echo " --hide-elapsed Don't print the elapsed time for each test along with slow test list"
39
38
-f|--force) force=1;;
40
39
-p|--pep8) just_pep8=1;;
41
40
-P|--no-pep8) no_pep8=1;;
42
-H|--hacking) just_hacking=1;;
43
41
-c|--coverage) coverage=1;;
44
42
-*) noseopts="$noseopts $1";;
45
43
*) noseargs="$noseargs $1"
100
96
# when running on devstack.
101
97
# NOTE(lzyeval): Avoid selecting *.pyc files to reduce pep8 check-up time
102
98
# when running on devstack.
103
xen_api_path="plugins/xenserver/xenapi/etc/xapi.d/plugins"
99
# NOTE(dprince): Exclude xenapi plugins. They are Python 2.4 code and as such
100
# cannot be expected to work with tools/hacking checks.
104
101
xen_net_path="plugins/xenserver/networking/etc/xensource/scripts"
105
102
srcfiles=`find nova -type f -name "*.py"`
106
103
srcfiles+=" `find bin -type f ! -name "nova.conf*" ! -name "*api-paste.ini*"`"
107
104
srcfiles+=" `find tools -type f -name "*.py"`"
108
srcfiles+=" `find ${xen_api_path} ${xen_net_path} -type f ! -name "*.patch" ! -name "*.pyc"`"
109
105
srcfiles+=" setup.py"
111
107
function run_pep8 {
112
echo "Running pep8 ..."
108
echo "Running PEP8 and HACKING compliance check..."
113
109
# Just run PEP8 in current environment
115
# NOTE(sirp): W602 (deprecated 3-arg raise) is being ignored for the
118
# 1. It's needed to preserve traceback information when re-raising
119
# exceptions; this is needed b/c Eventlet will clear exceptions when
120
# switching contexts.
122
# 2. There doesn't appear to be an alternative, "pep8-tool" compatible way of doing this
123
# in Python 2 (in Python 3 `with_traceback` could be used).
125
# 3. Can find no corroborating evidence that this is deprecated in Python 2
126
# other than what the PEP8 tool claims. It is deprecated in Python 3, so,
127
# perhaps the mistake was thinking that the deprecation applied to Python 2
129
pep8_opts="--ignore=W602 --repeat"
130
${wrapper} pep8 ${pep8_opts} ${srcfiles}
133
function run_hacking {
134
echo "Running hacking compliance testing..."
135
hacking_opts="--ignore=E202,W602 --repeat"
136
${wrapper} python tools/hacking.py ${hacking_opts} ${srcfiles}
112
# Until all these issues get fixed, ignore.
114
${wrapper} python tools/hacking.py ${ignore} ${srcfiles}
200
172
if [ $coverage -eq 1 ]; then
201
173
echo "Generating coverage report in covhtml/"
202
${wrapper} coverage html -d covhtml -i
174
# Don't compute coverage for common code, which is tested elsewhere
175
${wrapper} coverage html --include='nova/*' --omit='nova/openstack/common/*' -d covhtml -i