summaryrefslogtreecommitdiff
path: root/run_tests.sh
diff options
context:
space:
mode:
authorGorka Eguileor <geguileo@redhat.com>2015-02-19 17:25:58 +0100
committerGorka Eguileor <geguileo@redhat.com>2015-02-19 17:25:58 +0100
commitaa440cc319e8226e39e636726eb97506c70242cb (patch)
tree1e6a0a79e2ad0efe4ba95f12902836f50d69c41f /run_tests.sh
parent138875b7c3051a4f92616df56bffb8c91e669d88 (diff)
downloadglance_store-aa440cc319e8226e39e636726eb97506c70242cb.tar.gz
Add coverage report to run_test.sh
Adds argument -c to run_test.sh to generate HTML coverage reports like Glance has. It also displays coverage stats on terminal. Change-Id: I3439ac43964a59e993253d1ad45ef74af86e2ad9
Diffstat (limited to 'run_tests.sh')
-rwxr-xr-xrun_tests.sh24
1 files changed, 22 insertions, 2 deletions
diff --git a/run_tests.sh b/run_tests.sh
index 6506df0..b77b23b 100755
--- a/run_tests.sh
+++ b/run_tests.sh
@@ -13,6 +13,7 @@ function usage {
echo " -u, --update Update the virtual environment with any newer package versions"
echo " -p, --pep8 Just run PEP8 and HACKING compliance check"
echo " -P, --no-pep8 Don't run static code checks"
+ echo " -c, --coverage Generate coverage report"
echo " -d, --debug Run tests with testtools instead of testr. This allows you to use the debugger."
echo " -h, --help Print this usage message"
echo " --virtual-env-path <path> Location of the virtualenv directory"
@@ -42,6 +43,7 @@ function process_options {
-u|--update) update=1;;
-p|--pep8) just_pep8=1;;
-P|--no-pep8) no_pep8=1;;
+ -c|--coverage) coverage=1;;
-d|--debug) debug=1;;
--virtual-env-path)
(( i++ ))
@@ -80,6 +82,7 @@ testropts=
wrapper=""
just_pep8=0
no_pep8=0
+coverage=0
debug=0
update=0
concurrency=0
@@ -112,13 +115,17 @@ function run_tests {
fi
${wrapper} python -m testtools.run $testropts $testrargs
- # Short circuit because all of the testr stuff
+ # Short circuit because all of the testr and coverage stuff
# below does not make sense when running testtools.run for
# debugging purposes.
return $?
fi
- TESTRTESTS="$TESTRTESTS"
+ if [ $coverage -eq 1 ]; then
+ TESTRTESTS="$TESTRTESTS --coverage"
+ else
+ TESTRTESTS="$TESTRTESTS"
+ fi
# Just run the test suites in current environment
set +e
@@ -142,6 +149,14 @@ function run_tests {
copy_subunit_log
+ if [ $coverage -eq 1 ]; then
+ echo "Generating HTML coverage report in covhtml/"
+ # Don't compute coverage for common code, which is tested elsewhere
+ ${wrapper} coverage combine
+ ${wrapper} coverage html --include='glance_store/*' --omit='glance_store/openstack/common/*' -d covhtml -i
+ ${wrapper} coverage report --include='glance_store/*' --omit='glance_store/openstack/common/*' -i
+ fi
+
return $RESULT
}
@@ -196,6 +211,11 @@ then
fi
fi
+# Delete old coverage data from previous runs
+if [ $coverage -eq 1 ]; then
+ ${wrapper} coverage erase
+fi
+
if [ $just_pep8 -eq 1 ]; then
run_pep8
exit