Merge lp:~jaypipes/nova/bug615906 into lp:~hudson-openstack/nova/trunk

Proposed by Jay Pipes
Status: Merged
Approved by: Eric Day
Approved revision: 221
Merged at revision: 246
Proposed branch: lp:~jaypipes/nova/bug615906
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 73 lines (+57/-3)
1 file modified
run_tests.sh (+57/-3)
To merge this branch: bzr merge lp:~jaypipes/nova/bug615906
Reviewer Review Type Date Requested Status
Eric Day (community) Approve
Soren Hansen (community) Needs Fixing
termie Pending
Review via email: mp+32391@code.launchpad.net

This proposal supersedes a proposal from 2010-08-11.

Commit message

No longer installs a virtualenv automatically and adds new options to bypass the interactive prompt.

Description of the change

Makes a few changes to the run_tests.sh script:

1) No longer installs a virtualenv automatically. The default
   behaviour (running script with no options) is to assume the
   user wishes to run the test suite(s) in a virtualenv, but to
   ask the user if they wish to create a virtualenv if one does
   not already exist
2) Adds -V command line option to override the interactive prompt
   and automatically create a virtualenv if not found
3) Adds -N command line option to override the interactive prompt
   and only run the tests in the local environment, and never create
   a virtualenv

To post a comment you must log in.
Revision history for this message
Soren Hansen (soren) wrote :

> +function process_option {
> + option=$1
> + case $option in
> + --help) usage;;
> + -h) usage;;
> + -V) let always_venv=1; let never_venv=0;;
> + --virtual-env) let always_venv=1; let never_venv=0;;
> + -N) let always_venv=0; let never_venv=1;;
> + --no-virtual-env) let always_venv=0; let never_venv=1;;
> + esac
> +}

Can you group these options, please? Something like:

case "$option" in
  -h|--help) usage;;
  -V|--virtual-env) blah;;
  -N|--no-virtual-env) other blah;;
esac

It makes it clearer that those options really are the same. Other than
that, it looks fine.

 review needsfixing

--
Soren Hansen
Ubuntu Developer
http://www.ubuntu.com/

review: Needs Fixing
lp:~jaypipes/nova/bug615906 updated
221. By Jay Pipes

Merge case statement options

Revision history for this message
Jay Pipes (jaypipes) wrote :

Fixed case statement. Sorry, was due to my bad bash-foo.

Revision history for this message
Jay Pipes (jaypipes) wrote :

pinging again...

Revision history for this message
Eric Day (eday) wrote :

lgtm

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'run_tests.sh'
2--- run_tests.sh 2010-08-10 16:44:38 +0000
3+++ run_tests.sh 2010-08-13 14:16:44 +0000
4@@ -1,12 +1,66 @@
5-#!/bin/bash
6+#!/bin/bash
7+
8+function usage {
9+ echo "Usage: $0 [OPTION]..."
10+ echo "Run Nova's test suite(s)"
11+ echo ""
12+ echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
13+ echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
14+ echo " -h, --help Print this usage message"
15+ echo ""
16+ echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
17+ echo " If no virtualenv is found, the script will ask if you would like to create one. If you "
18+ echo " prefer to run tests NOT in a virtual environment, simply pass the -N option."
19+ exit
20+}
21+
22+function process_options {
23+ array=$1
24+ elements=${#array[@]}
25+ for (( x=0;x<$elements;x++)); do
26+ process_option ${array[${x}]}
27+ done
28+}
29+
30+function process_option {
31+ option=$1
32+ case $option in
33+ -h|--help) usage;;
34+ -V|--virtual-env) let always_venv=1; let never_venv=0;;
35+ -N|--no-virtual-env) let always_venv=0; let never_venv=1;;
36+ esac
37+}
38
39 venv=.nova-venv
40 with_venv=tools/with_venv.sh
41+always_venv=0
42+never_venv=0
43+options=("$@")
44+
45+process_options $options
46+
47+if [ $never_venv -eq 1 ]; then
48+ # Just run the test suites in current environment
49+ python run_tests.py
50+ exit
51+fi
52
53 if [ -e ${venv} ]; then
54 ${with_venv} python run_tests.py $@
55 else
56- echo "No virtual environment found...creating one"
57- python tools/install_venv.py
58+ if [ $always_venv -eq 1 ]; then
59+ # Automatically install the virtualenv
60+ python tools/install_venv.py
61+ else
62+ echo -e "No virtual environment found...create one? (Y/n) \c"
63+ read use_ve
64+ if [ "x$use_ve" = "xY" ]; then
65+ # Install the virtualenv and run the test suite in it
66+ python tools/install_venv.py
67+ else
68+ python run_tests.py
69+ exit
70+ fi
71+ fi
72 ${with_venv} python run_tests.py $@
73 fi