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
This commit is contained in:
parent
138875b7c3
commit
aa440cc319
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,3 +22,4 @@ var/*
|
|||||||
ChangeLog
|
ChangeLog
|
||||||
AUTHORS
|
AUTHORS
|
||||||
subunit.log
|
subunit.log
|
||||||
|
covhtml/
|
||||||
|
24
run_tests.sh
24
run_tests.sh
@ -13,6 +13,7 @@ function usage {
|
|||||||
echo " -u, --update Update the virtual environment with any newer package versions"
|
echo " -u, --update Update the virtual environment with any newer package versions"
|
||||||
echo " -p, --pep8 Just run PEP8 and HACKING compliance check"
|
echo " -p, --pep8 Just run PEP8 and HACKING compliance check"
|
||||||
echo " -P, --no-pep8 Don't run static code checks"
|
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 " -d, --debug Run tests with testtools instead of testr. This allows you to use the debugger."
|
||||||
echo " -h, --help Print this usage message"
|
echo " -h, --help Print this usage message"
|
||||||
echo " --virtual-env-path <path> Location of the virtualenv directory"
|
echo " --virtual-env-path <path> Location of the virtualenv directory"
|
||||||
@ -42,6 +43,7 @@ function process_options {
|
|||||||
-u|--update) update=1;;
|
-u|--update) update=1;;
|
||||||
-p|--pep8) just_pep8=1;;
|
-p|--pep8) just_pep8=1;;
|
||||||
-P|--no-pep8) no_pep8=1;;
|
-P|--no-pep8) no_pep8=1;;
|
||||||
|
-c|--coverage) coverage=1;;
|
||||||
-d|--debug) debug=1;;
|
-d|--debug) debug=1;;
|
||||||
--virtual-env-path)
|
--virtual-env-path)
|
||||||
(( i++ ))
|
(( i++ ))
|
||||||
@ -80,6 +82,7 @@ testropts=
|
|||||||
wrapper=""
|
wrapper=""
|
||||||
just_pep8=0
|
just_pep8=0
|
||||||
no_pep8=0
|
no_pep8=0
|
||||||
|
coverage=0
|
||||||
debug=0
|
debug=0
|
||||||
update=0
|
update=0
|
||||||
concurrency=0
|
concurrency=0
|
||||||
@ -112,13 +115,17 @@ function run_tests {
|
|||||||
fi
|
fi
|
||||||
${wrapper} python -m testtools.run $testropts $testrargs
|
${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
|
# below does not make sense when running testtools.run for
|
||||||
# debugging purposes.
|
# debugging purposes.
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TESTRTESTS="$TESTRTESTS"
|
if [ $coverage -eq 1 ]; then
|
||||||
|
TESTRTESTS="$TESTRTESTS --coverage"
|
||||||
|
else
|
||||||
|
TESTRTESTS="$TESTRTESTS"
|
||||||
|
fi
|
||||||
|
|
||||||
# Just run the test suites in current environment
|
# Just run the test suites in current environment
|
||||||
set +e
|
set +e
|
||||||
@ -142,6 +149,14 @@ function run_tests {
|
|||||||
|
|
||||||
copy_subunit_log
|
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
|
return $RESULT
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,6 +211,11 @@ then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Delete old coverage data from previous runs
|
||||||
|
if [ $coverage -eq 1 ]; then
|
||||||
|
${wrapper} coverage erase
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $just_pep8 -eq 1 ]; then
|
if [ $just_pep8 -eq 1 ]; then
|
||||||
run_pep8
|
run_pep8
|
||||||
exit
|
exit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user