7
7
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
8
8
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
9
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
9
10
echo " -h, --help Print this usage message"
11
12
echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
17
function process_options {
20
for (( x=0;x<$elements;x++)); do
21
process_option ${array[${x}]}
25
18
function process_option {
29
21
-V|--virtual-env) let always_venv=1; let never_venv=0;;
30
22
-N|--no-virtual-env) let always_venv=0; let never_venv=1;;
23
-f|--force) let force=1;;
24
*) noseargs="$noseargs $1"
35
29
with_venv=tools/with_venv.sh
40
process_options $options
42
if [ $never_venv -eq 1 ]; then
43
41
# Just run the test suites in current environment
44
nosetests --logging-clear-handlers
48
if [ -e ${venv} ]; then
49
${with_venv} nosetests --logging-clear-handlers
51
if [ $always_venv -eq 1 ]; then
52
# Automatically install the virtualenv
53
python tools/install_venv.py
42
${wrapper} rm -f glance.sqlite
43
${wrapper} $NOSETESTS 2> run_tests.err.log
46
NOSETESTS="python run_tests.py $noseargs"
48
if [ $never_venv -eq 0 ]
50
# Remove the virtual environment if --force used
51
if [ $force -eq 1 ]; then
52
echo "Cleaning virtualenv..."
55
if [ -e ${venv} ]; then
56
wrapper="${with_venv}"
55
echo -e "No virtual environment found...create one? (Y/n) \c"
57
if [ "x$use_ve" = "xY" ]; then
58
# Install the virtualenv and run the test suite in it
58
if [ $always_venv -eq 1 ]; then
59
# Automatically install the virtualenv
59
60
python tools/install_venv.py
61
wrapper="${with_venv}"
61
nosetests --logging-clear-handlers
63
echo -e "No virtual environment found...create one? (Y/n) \c"
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
65
${with_venv} nosetests --logging-clear-handlers
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
78
# [1] https://bugs.launchpad.net/bzr/+bug/701898
80
PEP8_EXCLUDE=vcsversion.py
81
PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-pep8 --show-source"
82
PEP8_INCLUDE="bin/* glance tests tools setup.py run_tests.py"
83
run_tests && pep8 $PEP8_OPTIONS $PEP8_INCLUDE || exit 1