[openstack-dev] [nova] running pep8 tests much faster

Matthew Booth mbooth at redhat.com
Mon Aug 18 13:39:34 UTC 2014

On 18/08/14 12:51, Daniel P. Berrange wrote:
> We recently had a change merged to the run_tests.sh script that Nova
> developers would really benefit from knowing about:
>    https://review.openstack.org/#/c/110746/
> Basically, it provides a way to run the pep8 tests *only* against the files
> which you have actually touched in your patch. For most patches this has a
> huge benefit in running time since instead of checking 3000+ files it only
> has to check a handful.
> Old way, checking all of nova codebase at once:
> $ time ./run_tests.sh -p
>   Running flake8 ...
>   real	2m4.410s
>   user	2m3.530s
>   sys	0m0.637s
> New way, checking only changed files:
>   $ time ./run_tests.sh -8
>   Running flake8 on nova/tests/virt/libvirt/test_driver.py nova/virt/libvirt/driver.py 
>   real	0m8.117s
>   user	0m7.785s
>   sys	0m0.287s
> I'm guessing I know which most people will prefer :)
> NB, this only checks files in the most recent patch in your checkout. ie
> if you are sitting on a 10-patch series it is only validating the last
> patch in that series. Probably not an issue for most people since you
> need to explicitly check each patch individually during rebase regardless.

Incidentally, in case people aren't familiar with it, git rebase -x is
an excellent tool for running this kind of thing against a 10-patch series:

git rebase -i -x './run_tests.sh -8' -x './run_tests.sh vmwareapi' <base>

This will give you an interactive rebase (-x requires -i) on to <base>.
After applying each patch it will run each of the 2 given commands. If
either fails it will pause. After resolving any issues you can continue
with 'git rebase --continue'.

Matthew Booth
Red Hat Engineering, Virtualisation Team

Phone: +442070094448 (UK)
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

More information about the OpenStack-dev mailing list