Add support for generating local code coverage report

This commit is contained in:
Lorin Hochstein 2011-07-19 10:52:38 -04:00
parent 59ce94a3da
commit c72a3e263f
2 changed files with 16 additions and 0 deletions

View File

@ -13,3 +13,5 @@ nova/vcsversion.py
clean.sqlite
run_tests.log
tests.sqlite
.coverage
covhtml

View File

@ -11,6 +11,7 @@ function usage {
echo " -x, --stop Stop running tests after the first error or failure."
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 " -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"
echo ""
@ -29,6 +30,7 @@ function process_option {
-n|--no-recreate-db) let recreate_db=0;;
-f|--force) let force=1;;
-p|--pep8) let just_pep8=1;;
-c|--coverage) let coverage=1;;
-*) noseopts="$noseopts $1";;
*) noseargs="$noseargs $1"
esac
@ -43,12 +45,18 @@ noseargs=
noseopts=
wrapper=""
just_pep8=0
coverage=0
recreate_db=1
for arg in "$@"; do
process_option $arg
done
if [ $coverage -eq 1 ]; then
${wrapper} coverage erase
noseopts="$noseopts --with-coverage --cover-package=nova"
fi
function run_tests {
# Just run the test suites in current environment
${wrapper} $NOSETESTS 2> run_tests.log
@ -117,6 +125,7 @@ if [ $recreate_db -eq 1 ]; then
rm -f tests.sqlite
fi
run_tests || exit
# NOTE(sirp): we only want to run pep8 when we're running the full-test suite,
@ -126,3 +135,8 @@ run_tests || exit
if [ -z "$noseargs" ]; then
run_pep8
fi
if [ $coverage -eq 1 ]; then
echo "Generating coverage report in covhtml/"
coverage html -d covhtml -i
fi