[RFC] Using TestCaseWithMemoryTree
John Arbash Meinel
john at arbash-meinel.com
Wed Apr 25 19:11:38 BST 2007
I've started switching new test cases over to using
"make_branch_and_memory_tree()", and in general, I'm very happy about
the performance improvements. Especially on my Mac laptop, it makes
setting up the tests a lot faster.
The only deficiency I'm specifically aware of deals with the ability to
add files and directories (and modify their contents). If we were able
to do that, then probably 90% of the tests could be rewritten. Tests for
WorkingTree have to stay on disk, and we probably need a test or two
that Branch and Repository can work on the disk, but both of those
classes should be completely abstracted through Transport, and we have a
very rigorous interface testing of Transport functionality.
I think one of the limitations is that MemoryTree creates its own
MemoryTransport which it doesn't expose for TestCase.build_tree() to
modify. If we exposed the transport, we could do:
self.build_tree(['a', 'b'], transport=mem_tree.transport)
The only other part I'm aware of, is that MemoryTree doesn't support
sprout() and merge/pull_from_branch(). Part of the reason is that those
functions need to modify the working tree, and we can't do that in
In my latest tests I've worked around that by directly calling
"tree.branch.set_last_revision_info()" and "tree.set_parent_ids()".
Which lets me create whatever ancestry I want, by just jumping around as
necessary. In the past I've done it by creating one Tree, sprouting it
to another, and then merging between the two.
Is this a reasonable way of doing it? If so, it would be nice to have a
Test function to make it easier. Because right now you need to change
both the Tree and the Branch to be at the right location (or when you
commit you get "Out of date, please run 'bzr update'").
More information about the bazaar