def testVisitchildrensetM2never(self): m1 = matchmod.alwaysmatcher(b'', b'') m2 = matchmod.nevermatcher(b'', b'') dm = matchmod.differencematcher(m1, m2) # dm should be equivalent to a alwaysmatcher. self.assertEqual(dm.visitchildrenset(b'.'), b'all') self.assertEqual(dm.visitchildrenset(b'dir'), b'all') self.assertEqual(dm.visitchildrenset(b'dir/subdir'), b'all') self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'all') self.assertEqual(dm.visitchildrenset(b'dir/foo'), b'all') self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'all') self.assertEqual(dm.visitchildrenset(b'folder'), b'all')
def testVisitdirM2always(self): m1 = matchmod.alwaysmatcher(b'', b'') m2 = matchmod.alwaysmatcher(b'', b'') dm = matchmod.differencematcher(m1, m2) # dm should be equivalent to a nevermatcher. self.assertFalse(dm.visitdir(b'.')) self.assertFalse(dm.visitdir(b'dir')) self.assertFalse(dm.visitdir(b'dir/subdir')) self.assertFalse(dm.visitdir(b'dir/subdir/z')) self.assertFalse(dm.visitdir(b'dir/foo')) self.assertFalse(dm.visitdir(b'dir/subdir/x')) self.assertFalse(dm.visitdir(b'folder'))
def testVisitchildrensetIncludeInclude(self): m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) dm = matchmod.differencematcher(m1, m2) self.assertEqual(dm.visitchildrenset(b'.'), {b'dir'}) self.assertEqual(dm.visitchildrenset(b'dir'), {b'subdir'}) self.assertEqual(dm.visitchildrenset(b'dir/subdir'), b'all') self.assertEqual(dm.visitchildrenset(b'dir/foo'), set()) self.assertEqual(dm.visitchildrenset(b'folder'), set()) # OPT: We should probably return set() for these; we don't because # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of # an 'all' pattern, just 'this'. self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this') self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this')
def testVisitdirIncludeIncludfe(self): m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) dm = matchmod.differencematcher(m1, m2) self.assertEqual(dm.visitdir(b'.'), True) self.assertEqual(dm.visitdir(b'dir'), True) self.assertEqual(dm.visitdir(b'dir/subdir'), True) self.assertFalse(dm.visitdir(b'dir/foo')) self.assertFalse(dm.visitdir(b'folder')) # OPT: We should probably return False for these; we don't because # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of # an 'all' pattern, just True. self.assertEqual(dm.visitdir(b'dir/subdir/z'), True) self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
def testVisitchildrensetM2SubdirPrefix(self): m1 = matchmod.alwaysmatcher(b'', b'') m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) dm = matchmod.differencematcher(m1, m2) self.assertEqual(dm.visitchildrenset(b'.'), b'this') self.assertEqual(dm.visitchildrenset(b'dir'), b'this') self.assertEqual(dm.visitchildrenset(b'dir/subdir'), set()) self.assertEqual(dm.visitchildrenset(b'dir/foo'), b'all') self.assertEqual(dm.visitchildrenset(b'folder'), b'all') # OPT: We should probably return set() for these; we don't because # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of # an 'all' pattern, just 'this'. self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this') self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this')
def testVisitdirM2never(self): m1 = matchmod.alwaysmatcher(b'', b'') m2 = matchmod.nevermatcher(b'', b'') dm = matchmod.differencematcher(m1, m2) # dm should be equivalent to a alwaysmatcher. OPT: if m2 is a # nevermatcher, we could return 'all' for these. # # We're testing Equal-to-True instead of just 'assertTrue' since # assertTrue does NOT verify that it's a bool, just that it's truthy. # While we may want to eventually make these return 'all', they should # not currently do so. self.assertEqual(dm.visitdir(b'.'), True) self.assertEqual(dm.visitdir(b'dir'), True) self.assertEqual(dm.visitdir(b'dir/subdir'), True) self.assertEqual(dm.visitdir(b'dir/subdir/z'), True) self.assertEqual(dm.visitdir(b'dir/foo'), True) self.assertEqual(dm.visitdir(b'dir/subdir/x'), True) self.assertEqual(dm.visitdir(b'folder'), True)