~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_globbing.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-21 17:54:58 UTC
  • mfrom: (4948.5.7 ignore-exclusion)
  • Revision ID: pqm@pqm.ubuntu.com-20100121175458-17l0cvckbrf93eea
(John Whitley) implement ! and !! to exclude files from ignore rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
from bzrlib.globbing import (
19
19
    Globster,
 
20
    ExceptionGlobster,
20
21
    _OrderedGlobster,
21
22
    normalize_pattern
22
23
    )
307
308
            self.assertEqual(patterns[x],globster.match(filename))
308
309
        self.assertEqual(None,globster.match('foobar.300'))
309
310
 
 
311
class TestExceptionGlobster(TestCase):
 
312
 
 
313
    def test_exclusion_patterns(self):
 
314
        """test that exception patterns are not matched"""
 
315
        patterns = [ u'*', u'!./local', u'!./local/**/*', u'!RE:\.z.*',u'!!./.zcompdump' ]
 
316
        globster = ExceptionGlobster(patterns)
 
317
        self.assertEqual(u'*', globster.match('tmp/foo.txt'))
 
318
        self.assertEqual(None, globster.match('local'))
 
319
        self.assertEqual(None, globster.match('local/bin/wombat'))
 
320
        self.assertEqual(None, globster.match('.zshrc'))
 
321
        self.assertEqual(None, globster.match('.zfunctions/fiddle/flam'))
 
322
        self.assertEqual(u'!!./.zcompdump', globster.match('.zcompdump'))
 
323
 
 
324
    def test_exclusion_order(self):
 
325
        """test that ordering of exclusion patterns does not matter"""
 
326
        patterns = [ u'static/**/*.html', u'!static/**/versionable.html']
 
327
        globster = ExceptionGlobster(patterns)
 
328
        self.assertEqual(u'static/**/*.html', globster.match('static/foo.html'))
 
329
        self.assertEqual(None, globster.match('static/versionable.html'))
 
330
        self.assertEqual(None, globster.match('static/bar/versionable.html'))
 
331
        globster = ExceptionGlobster(reversed(patterns))
 
332
        self.assertEqual(u'static/**/*.html', globster.match('static/foo.html'))
 
333
        self.assertEqual(None, globster.match('static/versionable.html'))
 
334
        self.assertEqual(None, globster.match('static/bar/versionable.html'))
310
335
 
311
336
class TestOrderedGlobster(TestCase):
312
337