11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
1 |
#!/bin/bash
|
2 |
||
3 |
function usage { |
|
4 |
echo "Usage: $0 [OPTION]..." |
|
5 |
echo "Run Glance's test suite(s)" |
|
6 |
echo "" |
|
7 |
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present" |
|
8 |
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment" |
|
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
9 |
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." |
11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
10 |
echo " -h, --help Print this usage message" |
11 |
echo "" |
|
12 |
echo "Note: with no options specified, the script will try to run the tests in a virtual environment," |
|
13 |
echo " If no virtualenv is found, the script will ask if you would like to create one. If you " |
|
14 |
echo " prefer to run tests NOT in a virtual environment, simply pass the -N option." |
|
15 |
exit
|
|
16 |
}
|
|
17 |
||
18 |
function process_option { |
|
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
19 |
case "$1" in |
11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
20 |
-h|--help) usage;; |
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;; |
|
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
23 |
-f|--force) let force=1;; |
24 |
*) noseargs="$noseargs $1" |
|
11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
25 |
esac
|
26 |
}
|
|
27 |
||
28 |
venv=.glance-venv |
|
29 |
with_venv=tools/with_venv.sh |
|
30 |
always_venv=0 |
|
31 |
never_venv=0 |
|
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
32 |
force=0 |
33 |
noseargs= |
|
34 |
wrapper="" |
|
35 |
||
36 |
for arg in "$@"; do |
|
37 |
process_option $arg
|
|
38 |
done
|
|
39 |
||
40 |
function run_tests { |
|
11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
41 |
# Just run the test suites in current environment
|
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
42 |
${wrapper} rm -f glance.sqlite |
43 |
${wrapper} $NOSETESTS 2> run_tests.err.log |
|
44 |
}
|
|
45 |
||
46 |
NOSETESTS="python run_tests.py $noseargs" |
|
47 |
||
48 |
if [ $never_venv -eq 0 ] |
|
49 |
then
|
|
50 |
# Remove the virtual environment if --force used
|
|
51 |
if [ $force -eq 1 ]; then |
|
52 |
echo "Cleaning virtualenv..." |
|
53 |
rm -rf ${venv} |
|
54 |
fi
|
|
55 |
if [ -e ${venv} ]; then |
|
56 |
wrapper="${with_venv}" |
|
11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
57 |
else
|
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
58 |
if [ $always_venv -eq 1 ]; then |
59 |
# Automatically install the virtualenv
|
|
11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
60 |
python tools/install_venv.py |
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
61 |
wrapper="${with_venv}" |
11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
62 |
else
|
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
63 |
echo -e "No virtual environment found...create one? (Y/n) \c" |
64 |
read use_ve
|
|
65 |
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then |
|
66 |
# Install the virtualenv and run the test suite in it
|
|
67 |
python tools/install_venv.py |
|
68 |
wrapper=${with_venv} |
|
69 |
fi
|
|
11.1.1
by jaypipes at gmail
First round of cleaning up the unittests. Adds test suite runner, support for virtualenv setup and library dependencies, resolves issues with ImportErrors on cloudfiles, adds pymox/stubout support and splits the backend testing into distinct unittest cases. |
70 |
fi
|
71 |
fi
|
|
72 |
fi
|
|
35.1.4
by jaypipes at gmail
PEP8 fixes in /glance/store/__init__.py |
73 |
|
59.1.1
by Rick Harris
Adds --sql-connection option |
74 |
# FIXME(sirp): bzr version-info is not currently pep-8. This was fixed with
|
75 |
# lp701898 [1], however, until that version of bzr becomes standard, I'm just
|
|
76 |
# excluding the vcsversion.py file
|
|
77 |
#
|
|
78 |
# [1] https://bugs.launchpad.net/bzr/+bug/701898
|
|
79 |
#
|
|
80 |
PEP8_EXCLUDE=vcsversion.py |
|
81 |
PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-pep8 --show-source" |
|
64.1.3
by Rick Harris
Including tests/ in pep8 |
82 |
PEP8_INCLUDE="bin/* glance tests tools setup.py run_tests.py" |
83 |
run_tests && pep8 $PEP8_OPTIONS $PEP8_INCLUDE || exit 1 |