Slow tests

Robert Collins robertc at robertcollins.net
Thu Sep 17 23:00:55 BST 2009


On Thu, 2009-09-17 at 22:04 +0200, Harald Meland wrote:


> I've done a quick first improvement to this in
> lp:~hmeland/bzr/bzr.faster-test-no-assert by doing a regexp search
> using

Cool!

> I'm also experimenting with a more fancy regexp, something like
> 
>         assert_re = re.compile(r'(?:^|[:;])\s*assert\b', flags=re.MULTILINE)
> 
> but while that will bring the runtime down to ~780ms on my machine,
> I'm not entirely confident that it will catch *all* ways of writing an
> assert statement in Python syntax.
> 
> Should I go with the former or the latter?

Well, the word 'assert' has to be all on one line. so
\bassert\b is fine. re.MULTILINE changes the behaviour of ^ and $, so
isn't relevant for our re. just
assert_re = re.compile(r'\bassert\b')
content = source.read()
if assert_re.search(content):
    # found the word 'assert' in the file: could be in a comment or not
    <whatever>

Its handling of comments and docstrings that probably drove Martin's use
of the AST. If we're not actually using the word assert anywhere, then
I'd just be as simple [and fast:)] as possible.

-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/20090918/d2b29db6/attachment-0002.pgp 


More information about the bazaar mailing list