[MERGE] Add --coverage option to selftest

Andrew Bennetts andrew at canonical.com
Thu Dec 6 12:25:28 GMT 2007


Andrew Bennetts wrote:
> Hi all,
> 
> I've been thinking selftest ought to have a --coverage option for some time.
> Tonight I finally sat down and wrote it.  It simply uses the trace module from
> the standard library in a pretty simple way (basically the same way that
> Twisted's test runner uses it).  It causes a fair bit of noise on stdout (or
> stderr?) while writing the output at the end of the test run.  Like the
> profiler, it uses sys.settrace so it make the test suite much slower when active
> (and probably doesn't work at the same time as the profiler for that matter).
> Despite the rough corners, I think this is useful enough to merge as is.

Another rough corner I just noticed is that because this installs the trace hook
after building the test suite, it doesn't usually notice the execution of
module-global lines like imports, defs and class statements, and so they're
flagged as never executed.  Maybe it would be better to install the trace hook
earlier, in bzrlib.tests.selftest rather than bzrlib.tests.run_suite, to avoid
this problem?

-Andrew.
 



More information about the bazaar mailing list