test isolation: default ignores & repository acquisition

Robert Collins robertc at robertcollins.net
Wed Sep 16 03:56:59 BST 2009


We've got two significant things with test isolation that cause some
overhead/work in the test suite.

Firstly is the defaut ignores. These are written to in ~/.bazaar/ignore,
if the file doesn't exist. Because of this, every test that invokes
directly or indirectly 'bzrlib.ignore.get_user_ignores' must have an
overridden, created homedir. While we could make one homedir and check
it hasn't been written to, I think I'd rather make a hook for this,
which can control obtaining these ignores. Then the test suite
infrastructure can by default install a hook to satisfy these from the
constants rather than from disk. Tests that test the management of
default ignores would reset that hook and use an overridden homedir.
Any thoughts on this?

Secondly, the repository acquisition logic, which reads up containing
directories to find shared repositories and/or branching policy triggers
reads outside the test suite, if we don't have a manually created
repository there. I'd like to get to the point of only having a
containing repository when we actually want to test the full stack. I
can't think of an easy catch-all for this particular issue, but perhaps
I've missed something? Anyhow, I think the approach I'm going to drive
for is to only create the containing catchall repository on
TestCaseWithTransport.

I propose the following test classes:
TestCase:
 - isolates environment variables
 - has facilities for transports and servers, defaulting to
   all memory and no local disk
 - hooks and isolates the default ignores
TestCaseWithTempDir(TestCase):
 - adds a temporary directory on disk
TestCaseWithHomeDir(TestCaseWithTempDir):
 - adds a fake HOME
TestCaseWithMemoryTransport(TestCaseWithHomeDir):
 - adds a 'safety net repository'
TestCaseWithTransport(TestCaseWithMemoryTransport):
 - sets the vfs transport to local disk

Then tests can choose what they need to use:
 - use OS locks in the repository
  - TestCaseWithTransport
 - clone to a working tree
  - TestCaseWithMemoryTransport
 - write to home/config settings
  - TestCaseWithHomeDir
 - use actual files [$TEMPDIR doesn't count]
  - TestCaseWithTempDir
 - anything else
  - TestCase

-Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090916/9730686a/attachment-0002.pgp 


More information about the bazaar mailing list