selftest.backtick versus selftest.run_bzr
David Clymer
david at zettazebra.com
Sun Sep 18 00:09:16 BST 2005
On Sat, 2005-09-17 at 14:02 -0400, John A Meinel wrote:
> David Clymer wrote:
> > On Sat, 2005-09-17 at 12:09 -0400, John A Meinel wrote:
> >
> >>I'm trying to write some more test cases. These are supposed to be
> >>external tests (as in making sure that the cmd_* functions are working
> >>correctly from the outside).
> >>
> >>>From what I can tell, there are 2 convenience functions to consider,
> >>self.backtick() and self.run_bzr(). run_bzr() actually just invokes the
> >>in-memory bzr library (which I am okay with), but I can't find a way to
> >>get the output of the command.
> >
> >
> > I think there is an example of capturing output from run_bzr in
> > TestCase.test_add_reports() in blackbox.py using self.apply_redirected()
>
> Thanks. I guess I was wondering why something like that was not already
> builtin.
Working on it.
>
> >
> >
> >>Am I missing a flag? Or should self.run_bzr be updated to support the
> >>"backtick=True" statement like the blackbox.py tests use? Or should I be
> >>subclassing the blackbox testing class instead of just TestCaseInTempDir?
> >
> >
> > I would think that if you are looking at the output of the command, this
> > would be a blackbox test, in which case you probably want to be using
> > ExternalBase and self.runbzr(). Is there a particular reason not to use
> > the external testing class?
>
> Yes and no. There was a discussion recently that it is easier to debug
> test failures if it does not actually spawn a new command. (Because you
> can get nice stack traces, etc).
>
> Also, there is quite a bit of overhead of spawning a new instance.
> Loading all of the python code is not free. On my Mac, "time bzr root"
> takes 0.6 seconds. But doing:
>
> b = bzrlib.branch.Branch.open_containing('.')
> print b.base
>
> Takes only 0.005 seconds.
>
> So if you can re-use the already loaded bzrlib, then the tests can run
> much much faster.
Yeah, I see your point. I guess if I would have just read the docstring
of run_bzr, I would have known all that, eh? ;o)
-davidc
--
gpg-key: http://www.zettazebra.com/files/key.gpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050917/9f25d992/attachment.pgp
More information about the bazaar
mailing list