~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_globbing.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-04 04:33:24 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100804043324-1ldc2v2w1kza7ox4
get into the nitty gritty for the _key_to_sha1 function.

It doesn't seem to help to op-out of the actual unhexlify call, so at least
that doesn't seem to be the performance overhead.
We get down to around 19.9us for _key_to_sha1 across 120 keys, which is
0.166us per key.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
17
 
 
18
import re
 
19
 
 
20
from bzrlib import errors
18
21
from bzrlib.globbing import (
19
22
    Globster,
20
23
    ExceptionGlobster,
308
311
            self.assertEqual(patterns[x],globster.match(filename))
309
312
        self.assertEqual(None,globster.match('foobar.300'))
310
313
 
 
314
    def test_bad_pattern(self):
 
315
        """Ensure that globster handles bad patterns cleanly."""
 
316
        patterns = [u'RE:[', u'/home/foo', u'RE:*.cpp']
 
317
        g = Globster(patterns)
 
318
        e = self.assertRaises(errors.InvalidPattern, g.match, 'filename')
 
319
        self.assertContainsRe(e.msg,
 
320
            "File.*ignore.*contains error.*RE:\[.*RE:\*\.cpp", flags=re.DOTALL)
 
321
 
 
322
 
311
323
class TestExceptionGlobster(TestCase):
312
324
 
313
325
    def test_exclusion_patterns(self):