[MERGE] Automatic discovery of tests

John Arbash Meinel john at arbash-meinel.com
Tue Nov 6 22:11:43 GMT 2007


Attached is a patch which changes how we find tests to run.

It adds a "bzrlib.tests.load_and_adapt_modules" function, which allows us
to simply find tests which need to be run based on the module names. This
means that we don't need to explicitly list the name of new test files.
I've actually been using some of this code in plugins that I've written,
and I've found it very nice to just pop a new "test_foo.py" file into my
tests/ directory and have it just work.

It is set up so that at package levels (foo/__init__.py) you can define
your own "test_suite()" function, which it will call, rather than
auto-discovering any tests that are present. This is what allows us to
have 'repository_implementations/' use a different adapter than other
subdirectories.

Overall, I think this greatly simplifies the implementations of
'test_suite()', and it means we just have less mental overhead to managing
our tests.

Off-hand, the only downside is that it will break for the standalone
bzr.exe. It could certainly be updated to look in .zip files if we really
want to bring that back. But as 'bzr.exe' is meant as an installed
executable, I'm not sure that we really need to have the test suite
available. (Developers need to run the test suite more than users need
to.) 

Having automatic loading was also meant to help me do *partial* loading,
so that we don't have to load the entire test suite before we figure out
that we only want to run 20/9000 tests. However, in discussing with
Martin, there could be other routes to go. (But in my case, it is taking
10s just to load the test suite, which is a big impediment when trying to
do TDD.)

John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-patch
Size: 104531 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20071106/fcc61e9e/attachment-0001.bin 


More information about the bazaar mailing list