selftest performance: landing our code faster and developing quicker.

Martin Pool mbp at canonical.com
Wed Sep 2 00:09:24 BST 2009


2009/9/2 John Arbash Meinel <john at arbash-meinel.com>:
> One thing that could benefit here, is making it easier to get access to
> memory-only actions.
>
> Specifically, we have "TestCaseWithMemoryTransport", but it is not easy
> to actually get what you need. Because the direct subclass is
> TestCaseWithTransport, and that is the base class for all of the
> TestCaseWithBzrdir/Branch/Repository/etc classes.
>
> And neither self.make_branch_builder() nor self.make_branch_and_tree()
> are able to create something in memory. (They both take a relpath, which
> must be a relative path, and never something like 'memory:///')

I have to say I like the approach of saying "I need a working
transport" or ".. a tree and branch" much more than I like the
approach of declaring it using a subclass.  It is visible in the file,
but it's not very visible, and people tend to either put methods on
the wrong subclass, or inherit from the wrong one, therefore either
using something more expensive than they need, or accidentally writing
to an external directory when they don't need to.  At least in the
past there were methods on base TestCase that only made sense if you
also derived from a transport, or vice versa.  Also it's possible that
of a set of related tests, only some will need these resources.

> We could also improve things by just making "initialize()" return a
> write-locked object. Rather than taking out a write lock, building the
> thing, unlocking it, and then returning it so that we have to lock it again.

Of course that would also be great in non-test use.

-- 
Martin <http://launchpad.net/~mbp/>



More information about the bazaar mailing list