Merge lp:~rackspace-titan/nova/run-tests-pep8-option into lp:~hudson-openstack/nova/trunk

Proposed by Naveed Massjouni
Status: Merged
Approved by: Vish Ishaya
Approved revision: 952
Merged at revision: 1008
Proposed branch: lp:~rackspace-titan/nova/run-tests-pep8-option
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 63 lines (+20/-7)
1 file modified
run_tests.sh (+20/-7)
To merge this branch: bzr merge lp:~rackspace-titan/nova/run-tests-pep8-option
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Devin Carlen (community) Approve
Brian Waldon (community) Approve
Review via email: mp+56669@code.launchpad.net

Description of the change

Added an option to run_tests.sh so you can run just pep8. So now you can:
    ./run_tests.sh --just-pep8
or
    ./run_tests.sh -p

To post a comment you must log in.
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Looks good. Could we call the option "--pep8", or "--pep8-only"? That would line up better with "-p".

review: Approve
Revision history for this message
Naveed Massjouni (ironcamel) wrote :

--pep8-only is fine with me. I would mostly run it with -p anyway :)

Revision history for this message
Devin Carlen (devcamcar) wrote :

--pep8-only seems unnecessarily verbose. suggest --pep8

review: Needs Fixing
951. By Naveed Massjouni

Changed pep8 command line option from --just-pep8 to --pep8.

Revision history for this message
Naveed Massjouni (ironcamel) wrote :

> --pep8-only seems unnecessarily verbose. suggest --pep8

Done.

Revision history for this message
Devin Carlen (devcamcar) wrote :

Cool, lgtm :)

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

doesn't this need a few || exit 1 after the run_tests and pep8 line to make sure the exit code gets passed the same way?

as in:

pep8 --repeat --show-pep8 --show-source --exclude=vcsversion.py ${srcfiles} || exit 1

remove line 41

run_tests || exit 1

I think that will preserve the old exit codes.

review: Needs Fixing
952. By Naveed Massjouni

Exit early if tests fail, before pep8 is run.

Revision history for this message
Naveed Massjouni (ironcamel) wrote :

Vish, thanks for taking a look at this.

> doesn't this need a few || exit 1 after the run_tests and pep8 line to make
> sure the exit code gets passed the same way?
>
> as in:
>
> pep8 --repeat --show-pep8 --show-source --exclude=vcsversion.py ${srcfiles} ||
> exit 1
>

Adding a || exit 1 would be redundant. Consider this code:

    if [ $just_pep8 -eq 1 ]; then
        run_pep8
        exit
    fi

This will correctly exit with an error status if pep8 failed. I manually tested this just to confirm.

> remove line 41

Line 41 cannot be removed. The point of this is to run just pep8 without running the whole test suite. Originally, the option I added was named --just-pep8, but others felt that was too verbose.

>
> run_tests || exit 1

Good point. Done.

>
> I think that will preserve the old exit codes.

Thanks,
Naveed

Revision history for this message
Vish Ishaya (vishvananda) wrote :

ok then 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 2011-03-08 20:39:58 +0000
3+++ run_tests.sh 2011-04-20 20:29:26 +0000
4@@ -7,6 +7,7 @@
5 echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
6 echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
7 echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
8+ echo " -p, --pep8 Just run pep8"
9 echo " -h, --help Print this usage message"
10 echo ""
11 echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
12@@ -21,6 +22,7 @@
13 -V|--virtual-env) let always_venv=1; let never_venv=0;;
14 -N|--no-virtual-env) let always_venv=0; let never_venv=1;;
15 -f|--force) let force=1;;
16+ -p|--pep8) let just_pep8=1;;
17 *) noseargs="$noseargs $1"
18 esac
19 }
20@@ -32,6 +34,7 @@
21 force=0
22 noseargs=
23 wrapper=""
24+just_pep8=0
25
26 for arg in "$@"; do
27 process_option $arg
28@@ -53,6 +56,18 @@
29 return $RESULT
30 }
31
32+function run_pep8 {
33+ echo "Running pep8 ..."
34+ srcfiles=`find bin -type f ! -name "nova.conf*"`
35+ srcfiles+=" nova setup.py plugins/xenserver/xenapi/etc/xapi.d/plugins/glance"
36+ pep8 --repeat --show-pep8 --show-source --exclude=vcsversion.py ${srcfiles}
37+}
38+
39+if [ $just_pep8 -eq 1 ]; then
40+ run_pep8
41+ exit
42+fi
43+
44 NOSETESTS="python run_tests.py $noseargs"
45
46 if [ $never_venv -eq 0 ]
47@@ -81,11 +96,9 @@
48 fi
49 fi
50
51-if [ -z "$noseargs" ];
52-then
53- srcfiles=`find bin -type f ! -name "nova.conf*"`
54- srcfiles+=" nova setup.py plugins/xenserver/xenapi/etc/xapi.d/plugins/glance"
55- run_tests && pep8 --repeat --show-pep8 --show-source --exclude=vcsversion.py ${srcfiles} || exit 1
56-else
57- run_tests
58+run_tests || exit
59+
60+# Also run pep8 if no options were provided.
61+if [ -z "$noseargs" ]; then
62+ run_pep8
63 fi