diff --git a/.bzrignore b/.bzrignore index 14d8028f..583fd551 100644 --- a/.bzrignore +++ b/.bzrignore @@ -13,3 +13,5 @@ nova/vcsversion.py clean.sqlite run_tests.log tests.sqlite +.coverage +covhtml diff --git a/run_tests.sh b/run_tests.sh index b8078e15..ea0d7557 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -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