diff options
| author | Lorin Hochstein <lorin@isi.edu> | 2011-07-19 10:52:38 -0400 |
|---|---|---|
| committer | Lorin Hochstein <lorin@isi.edu> | 2011-07-19 10:52:38 -0400 |
| commit | 05751530cdd3a0833025435403f9312da1e2feee (patch) | |
| tree | 3e89d3b6e5779c3f91041ca2a13ec985e687f56e | |
| parent | 77db06c908f9c08c80beb11241c0e23247129ad6 (diff) | |
Add support for generating local code coverage report
| -rw-r--r-- | .bzrignore | 2 | ||||
| -rwxr-xr-x | run_tests.sh | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/.bzrignore b/.bzrignore index 14d8028f7..583fd551f 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 b8078e150..ea0d75576 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 |
