4
echo "Usage: $0 [OPTION]..."
5
echo "Run python-heatclient's test suite(s)"
7
echo " -p, --pep8 Just run pep8"
8
echo " -h, --help Print this usage message"
10
echo "This script is deprecated and currently retained for compatibility."
11
echo 'You can run the full test suite for multiple environments by running "tox".'
12
echo 'You can run tests for only python 2.7 by running "tox -e py27", or run only'
13
echo 'the pep8 tests with "tox -e pep8".'
6
echo "Usage: $0 [OPTION]..."
7
echo "Run heatclient test suite(s)"
9
echo " -V, --virtual-env Use virtualenv. Install automatically if not present."
10
echo " (Default is to run tests in local environment)"
11
echo " -F, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
12
echo " -f, --func Functional tests have been removed."
13
echo " -u, --unit Run unit tests (default when nothing specified)"
14
echo " -p, --pep8 Run pep8 tests"
15
echo " --all Run pep8 and unit tests"
16
echo " -c, --coverage Generate coverage report"
17
echo " -d, --debug Run tests with testtools instead of testr. This allows you to use the debugger."
18
echo " -h, --help Print this usage message"
17
command -v tox > /dev/null 2>&1
19
echo 'This script requires "tox" to run.'
20
echo 'You can install it with "pip install tox".'
22
# must not assign -a as an option, needed for selecting custom attributes
26
24
function process_option {
29
-p|--pep8) let just_pep8=1;;
37
if [ $just_pep8 -eq 1 ]; then
41
tox -e py27 $toxargs 2>&1 | tee run_tests.err.log || exit 1
42
tox_exit_code=${PIPESTATUS[0]}
43
if [ 0$tox_exit_code -ne 0 ]; then
47
if [ -z "$toxargs" ]; then
26
-V|--virtual-env) no_venv=0;;
28
-f|--func) test_func=1;;
29
-u|--unit) test_unit=1;;
30
-p|--pep8) test_pep8=1;;
31
--all) test_unit=1; test_pep8=1;;
32
-c|--coverage) coverage=1;;
35
*) args="$args $1"; test_unit=1;;
40
with_venv=tools/with_venv.sh
47
if [ $debug -eq 1 ]; then
49
if [ "$args" = "" ]; then
50
# Default to running all tests if specific test is not
52
testrargs="discover ./heatclient/tests"
54
${wrapper} python -m testtools.run $args $testrargs
56
# Short circuit because all of the testr and coverage stuff
57
# below does not make sense when running testtools.run for
62
# Just run the test suites in current environment
63
if [ -n "$args" ] ; then
66
${wrapper} python setup.py testr --slowest $args
70
echo "Running flake8..."
71
bash -c "${wrapper} flake8"
74
# run unit tests with pep8 when no arguments are specified
75
# otherwise process CLI options
76
if [[ $# == 0 ]]; then
85
if [ "$no_venv" == 0 ]
87
# Remove the virtual environment if --force used
88
if [ "$force" == 1 ]; then
89
echo "Cleaning virtualenv..."
92
if [ -e ${venv} ]; then
93
wrapper="${with_venv}"
95
# Automatically install the virtualenv
96
python tools/install_venv.py
97
wrapper="${with_venv}"
103
# If functional or unit tests have been selected, run them
104
if [ "$test_unit" == 1 ] || [ "$debug" == 1 ] ; then
109
# Run pep8 if it was selected
110
if [ "$test_pep8" == 1 ]; then
114
# Generate coverage report
115
if [ "$coverage" == 1 ]; then
116
echo "Generating coverage report in ./cover"
117
${wrapper} python setup.py testr --coverage --slowest
118
${wrapper} python -m coverage report --show-missing