heat : run_tests.sh allow easier test selection
Allow each category of test (unit/funtional/pep) to be more easily selected via CLI options, default with no args remains unit+pep8 Change-Id: I85bbe0afe6170559a42f8c1619db24df16c6d9b0 Signed-off-by: Steven Hardy <shardy@redhat.com>
This commit is contained in:
parent
51dc63bb07
commit
1ce586c96c
54
run_tests.sh
54
run_tests.sh
@ -10,9 +10,8 @@ function usage {
|
||||
echo " -f, --func Run functional tests"
|
||||
echo " -u, --unit Run unit tests (default when nothing specified)"
|
||||
echo " -p, --pep8 Run pep8 tests"
|
||||
echo " -P, --pep8-only Run pep8 tests exclusively"
|
||||
echo " --all Run all tests"
|
||||
echo " -c, --coverage Generate coverage report"
|
||||
echo " -c, --coverage Generate coverage report (selects --unit)"
|
||||
echo " -h, --help Print this usage message"
|
||||
exit
|
||||
}
|
||||
@ -26,9 +25,8 @@ function process_option {
|
||||
-f|--func) test_func=1; noseargs="$noseargs -a tag=func";;
|
||||
-u|--unit) test_unit=1; noseargs="$noseargs -a tag=unit";;
|
||||
-p|--pep8) test_pep8=1;;
|
||||
-P|--pep8-only) test_pep8=1; just_pep8=1;;
|
||||
--all) test_func=1; test_unit=1; test_pep8=1; noseargs="$noseargs -a tag=func -a tag=unit";;
|
||||
-c|--coverage) coverage=1;;
|
||||
-c|--coverage) coverage=1; test_unit=1; noseargs="$noseargs -a tag=unit";;
|
||||
-h|--help) usage;;
|
||||
*) noseargs="$noseargs $1"
|
||||
esac
|
||||
@ -38,26 +36,9 @@ venv=.venv
|
||||
with_venv=tools/with_venv.sh
|
||||
wrapper=""
|
||||
|
||||
for arg in "$@"; do
|
||||
process_option $arg
|
||||
done
|
||||
|
||||
# run unit tests with pep8 when no arguments are specified
|
||||
if [[ "$test_func" != 1 && "$test_unit" != 1 ]]; then
|
||||
noseargs="$noseargs -a tag=unit"
|
||||
test_pep8=1
|
||||
fi
|
||||
|
||||
|
||||
# If enabled, tell nose to collect coverage data
|
||||
if [ "$coverage" == 1 ]; then
|
||||
noseopts="$noseopts --with-coverage --cover-package=heat"
|
||||
fi
|
||||
|
||||
NOSETESTS="python heat/testing/runner.py $noseopts $noseargs"
|
||||
|
||||
function run_tests {
|
||||
echo 'Running tests'
|
||||
NOSETESTS="python heat/testing/runner.py $noseopts $noseargs"
|
||||
# Just run the test suites in current environment
|
||||
${wrapper} $NOSETESTS 2> run_tests.err.log
|
||||
}
|
||||
@ -69,6 +50,22 @@ function run_pep8 {
|
||||
${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE
|
||||
}
|
||||
|
||||
# run unit tests with pep8 when no arguments are specified
|
||||
# otherwise process CLI options
|
||||
if [[ $# == 0 ]]; then
|
||||
noseargs="$noseargs -a tag=unit"
|
||||
test_pep8=1
|
||||
else
|
||||
for arg in "$@"; do
|
||||
process_option $arg
|
||||
done
|
||||
fi
|
||||
|
||||
# If enabled, tell nose to collect coverage data
|
||||
if [ "$coverage" == 1 ]; then
|
||||
noseopts="$noseopts --with-coverage --cover-package=heat"
|
||||
fi
|
||||
|
||||
if [ "$never_venv" == 0 ]
|
||||
then
|
||||
# Remove the virtual environment if --force used
|
||||
@ -100,16 +97,17 @@ if [ "$coverage" == 1 ]; then
|
||||
${wrapper} coverage erase
|
||||
fi
|
||||
|
||||
# If functional or unit tests have been selected, run them
|
||||
if [ ! -z "$noseargs" ]; then
|
||||
run_tests
|
||||
fi
|
||||
|
||||
# Run pep8 if it was selected
|
||||
if [ "$test_pep8" == 1 ]; then
|
||||
run_pep8
|
||||
fi
|
||||
|
||||
if [ "$just_pep8" == 1 ]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
run_tests
|
||||
|
||||
# Generate coverage report
|
||||
if [ "$coverage" == 1 ]; then
|
||||
echo "Generating coverage report in covhtml/"
|
||||
# Don't compute coverage for common code, which is tested elsewhere
|
||||
|
Loading…
Reference in New Issue
Block a user