nova/tools
Adam Spiers 5df748b2ed Make it easier to run a selection of tests relevant to ongoing work
During development of a new git commit, locally running a whole unit
or functional test suite to check every minor code change is
prohibitively expensive.  For maximum developer productivity and
happiness, it's generally desirable to make the feedback loop of the
traditional red/green cycle as quick as possible.

So add run-tests-for-diff.sh and run-tests.py to the tools/
subdirectory, using a few tricks as explained below to help with this.

run-tests.py takes a list of files on STDIN, filters the list for
tests which can be run in the current tox virtualenv, and then runs
them with the correct stestr options.

run-tests-for-diff.sh is a simple wrapper around run-tests.py which
determines which tests to run using output from "git diff".  This
allows running only the test files changed/added in the working tree:

    tools/run-tests-for-diff.sh

or by a single commit:

    tools/run-tests-for-diff.sh mybranch^!

or a range of commits, e.g. a branch containing a whole patch series
for a blueprint:

    tools/run-tests-for-diff.sh gerrit/master..bp/my-blueprint

It supports the same "-HEAD" invocation syntax as flake8wrap.sh (as
used by the "fast8" tox environment):

    tools/run-tests-for-diff.sh -HEAD

run-tests.py uses two tricks to make test runs as quick as possible:

  1. It's (already) possible to speed up running of tests by
     source'ing the "activate" file for the desired tox virtualenv,
     e.g.

        source .tox/py36/bin/activate

     and then running stestr directly.  This saves a few seconds by
     skipping the overhead introduced by running tox.

  2. When only one test file needs to be run, specifying the -n option
     to stestr will skip the costly test discovery phase, saving
     several more valuable seconds.

Future commits could build on top of this work, harnessing a framework
such as watchdog / watchmedo[0] or Guard[1] in order to automatically
run relevant tests every time your editor saves changes to a .py file.

[0] https://github.com/gorakhargosh/watchdog - Python-based
[1] https://guardgem.org - probably best in class, but Ruby-based so
    maybe unacceptable for use within Nova.

Change-Id: I9a9bda5d29bbb8d8d77f769cd1abf7c42a18c36b
2019-08-19 17:48:39 +01:00
..
db remove db2 support from tree 2016-05-23 07:33:20 -04:00
hooks move gate hooks to gate/ 2017-01-04 11:05:16 +00:00
xenserver Make Xen code py3-compatible 2018-08-10 20:04:19 +00:00
abandon_old_reviews.sh Replace git.openstack.org URLs with opendev.org URLs 2019-04-24 13:59:57 +08:00
build_latex_pdf.sh Add tool to build a doc latex pdf 2015-07-14 16:13:47 -04:00
flake8wrap.sh tox: make it possible to run pep8 on current patch only 2015-07-24 16:15:38 +01:00
nova-manage.bash_completion add nova-manage bash completion script 2012-06-20 17:02:49 +02:00
reserve-migrations.py Prevent blank line at start of migration placeholders 2017-08-25 18:43:19 +01:00
run-tests-for-diff.sh Make it easier to run a selection of tests relevant to ongoing work 2019-08-19 17:48:39 +01:00
run-tests.py Make it easier to run a selection of tests relevant to ongoing work 2019-08-19 17:48:39 +01:00
test-setup.sh Prepare for using standard python tests 2017-02-09 17:52:55 +00:00