[RFC] Using TestCaseWithMemoryTree

Martin Pool mbp at sourcefrog.net
Wed Apr 25 22:13:56 BST 2007


On 4/26/07, John Arbash Meinel <john at arbash-meinel.com> wrote:
> 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.

> 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)

+1

> 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
> memory....

Sprout and pull should maybe take options saying not to make or update
a working tree...

> 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'").

That sounds reasonable to me.  We could also have a commit option to
disable the out-of-date check (but then should the new revision be
based on the branch tip or on the working tree parent? probably the
branch.)

There are many places where the tests want to eg make a branch, make
some files, and commit them, and more complex cases when constructing
merges.  It would be good to make some standard methods for that.

-- 
Martin



More information about the bazaar mailing list