Add code-coverage support to run_tests.sh (lp860160)
Change-Id: I404ba58ea882123b8c6669ea32923fa626b27de5
This commit is contained in:
parent
109f366975
commit
342b8362ee
@ -167,6 +167,7 @@ class QuantumTestResult(result.TextTestResult):
|
||||
self.colorizer = None
|
||||
# NOTE(vish, tfukushima): reset stdout for the terminal check
|
||||
stdout = sys.__stdout__
|
||||
sys.stdout = sys.__stdout__
|
||||
for colorizer in [_Win32Colorizer, _AnsiColorizer, _NullColorizer]:
|
||||
if colorizer.supported():
|
||||
self.colorizer = colorizer(self.stream)
|
||||
|
@ -48,6 +48,7 @@ import sys
|
||||
|
||||
from quantum.common.test_lib import run_tests
|
||||
from nose import config
|
||||
from nose import core
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
@ -55,5 +56,6 @@ if __name__ == '__main__':
|
||||
c = config.Config(stream=sys.stdout,
|
||||
env=os.environ,
|
||||
verbosity=3,
|
||||
workingDir=working_dir)
|
||||
workingDir=working_dir,
|
||||
plugins=core.DefaultPluginManager())
|
||||
sys.exit(run_tests(c))
|
||||
|
26
run_tests.sh
26
run_tests.sh
@ -6,6 +6,7 @@ function usage {
|
||||
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 " -h, --help Print this usage message"
|
||||
echo ""
|
||||
@ -21,6 +22,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;;
|
||||
-c|--coverage) coverage=1;;
|
||||
-*) noseopts="$noseopts $1";;
|
||||
*) noseargs="$noseargs $1"
|
||||
esac
|
||||
}
|
||||
@ -32,18 +35,24 @@ never_venv=0
|
||||
force=0
|
||||
noseargs=
|
||||
wrapper=""
|
||||
coverage=0
|
||||
|
||||
for arg in "$@"; do
|
||||
process_option $arg
|
||||
done
|
||||
|
||||
# If enabled, tell nose to collect coverage data
|
||||
if [ $coverage -eq 1 ]; then
|
||||
noseopts="$noseopts --with-coverage --cover-package=quantum"
|
||||
fi
|
||||
|
||||
function run_tests {
|
||||
# Just run the test suites in current environment
|
||||
${wrapper} rm -f ./$PLUGIN_DIR/tests.sqlite
|
||||
${wrapper} $NOSETESTS
|
||||
}
|
||||
|
||||
NOSETESTS="python ./$PLUGIN_DIR/run_tests.py $noseargs"
|
||||
NOSETESTS="python ./$PLUGIN_DIR/run_tests.py $noseopts $noseargs"
|
||||
|
||||
if [ -n "$PLUGIN_DIR" ]
|
||||
then
|
||||
@ -80,6 +89,11 @@ then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Delete old coverage data from previous runs
|
||||
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
|
||||
@ -89,4 +103,12 @@ fi
|
||||
PEP8_EXCLUDE=vcsversion.py
|
||||
PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-source"
|
||||
PEP8_INCLUDE="bin/* quantum tests tools run_tests.py"
|
||||
run_tests && pep8 $PEP8_OPTIONS $PEP8_INCLUDE || exit 1
|
||||
RV=0
|
||||
run_tests && pep8 $PEP8_OPTIONS $PEP8_INCLUDE || RV=1
|
||||
|
||||
if [ $coverage -eq 1 ]; then
|
||||
echo "Generating coverage report in covhtml/"
|
||||
${wrapper} coverage html -d covhtml -i
|
||||
fi
|
||||
|
||||
exit $RV
|
||||
|
@ -1,6 +1,8 @@
|
||||
coverage
|
||||
eventlet>=0.9.12
|
||||
Routes>=1.12.3
|
||||
nose
|
||||
nosexcover
|
||||
Paste
|
||||
PasteDeploy
|
||||
pep8>=0.5.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user