6
4
echo "Usage: $0 [OPTION]..."
7
5
echo "Run Nova's test suite(s)"
9
7
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
10
8
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
11
echo " -r, --recreate-db Recreate the test database (deprecated, as this is now the default)."
12
echo " -n, --no-recreate-db Don't recreate the test database."
13
echo " -x, --stop Stop running tests after the first error or failure."
14
9
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
15
echo " -p, --pep8 Just run pep8"
16
echo " -c, --coverage Generate coverage report"
17
10
echo " -h, --help Print this usage message"
18
echo " --hide-elapsed Don't print the elapsed time for each test along with slow test list"
20
12
echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
21
13
echo " If no virtualenv is found, the script will ask if you would like to create one. If you "
26
18
function process_option {
29
-V|--virtual-env) always_venv=1; never_venv=0;;
30
-N|--no-virtual-env) always_venv=0; never_venv=1;;
31
-r|--recreate-db) recreate_db=1;;
32
-n|--no-recreate-db) recreate_db=0;;
34
-p|--pep8) just_pep8=1;;
35
-c|--coverage) coverage=1;;
36
-*) noseopts="$noseopts $1";;
37
*) noseargs="$noseargs $1"
21
-V|--virtual-env) let always_venv=1; let never_venv=0;;
22
-N|--no-virtual-env) let always_venv=0; let never_venv=1;;
23
-f|--force) let force=1;;
53
33
for arg in "$@"; do
54
34
process_option $arg
57
# If enabled, tell nose to collect coverage data
58
if [ $coverage -eq 1 ]; then
59
noseopts="$noseopts --with-coverage --cover-package=nova"
37
if [ $never_venv -eq 1 ]; then
63
38
# Just run the test suites in current environment
64
${wrapper} $NOSETESTS 2> run_tests.log
65
# If we get some short import error right away, print the error log directly
67
if [ "$RESULT" -ne "0" ];
69
ERRSIZE=`wc -l run_tests.log | awk '{print \$1}'`
70
if [ "$ERRSIZE" -lt "40" ];
79
echo "Running pep8 ..."
80
# Opt-out files from pep8
81
ignore_scripts="*.sh:*nova-debug:*clean-vlans"
82
ignore_files="*eventlet-patch:*pip-requires"
83
ignore_dirs="*ajaxterm*"
84
GLOBIGNORE="$ignore_scripts:$ignore_files:$ignore_dirs"
85
srcfiles=`find bin -type f ! -name "nova.conf*"`
86
srcfiles+=" `find tools/*`"
87
srcfiles+=" nova setup.py plugins/xenserver/xenapi/etc/xapi.d/plugins/glance"
88
# Just run PEP8 in current environment
89
${wrapper} pep8 --repeat --show-pep8 --show-source \
90
--exclude=vcsversion.py ${srcfiles}
93
NOSETESTS="python run_tests.py $noseopts $noseargs"
95
if [ $never_venv -eq 0 ]
97
# Remove the virtual environment if --force used
98
if [ $force -eq 1 ]; then
99
echo "Cleaning virtualenv..."
102
if [ -e ${venv} ]; then
103
wrapper="${with_venv}"
43
# Remove the virtual environment if --force used
44
if [ $force -eq 1 ]; then
45
echo "Cleaning virtualenv..."
49
if [ -e ${venv} ]; then
50
${with_venv} python run_tests.py $@
52
if [ $always_venv -eq 1 ]; then
53
# Automatically install the virtualenv
54
python tools/install_venv.py
105
if [ $always_venv -eq 1 ]; then
106
# Automatically install the virtualenv
56
echo -e "No virtual environment found...create one? (Y/n) \c"
58
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
59
# Install the virtualenv and run the test suite in it
107
60
python tools/install_venv.py
108
wrapper="${with_venv}"
110
echo -e "No virtual environment found...create one? (Y/n) \c"
112
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
113
# Install the virtualenv and run the test suite in it
114
python tools/install_venv.py
121
# Delete old coverage data from previous runs
122
if [ $coverage -eq 1 ]; then
123
${wrapper} coverage erase
126
if [ $just_pep8 -eq 1 ]; then
131
if [ $recreate_db -eq 1 ]; then
137
# NOTE(sirp): we only want to run pep8 when we're running the full-test suite,
138
# not when we're running tests individually. To handle this, we need to
139
# distinguish between options (noseopts), which begin with a '-', and
140
# arguments (noseargs).
141
if [ -z "$noseargs" ]; then
145
if [ $coverage -eq 1 ]; then
146
echo "Generating coverage report in covhtml/"
147
${wrapper} coverage html -d covhtml -i
66
${with_venv} python run_tests.py $@