Details
Details
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | tests/test-match.py (6 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
1269a0b56833 | a4b36576701d | Martin von Zweigbergk | Oct 29 2019, 1:54 PM |
# OPT: We should probably return set() for these; we don't because | # OPT: We should probably return set() for these; we don't because | ||||
# patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of | # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of | ||||
# an 'all' pattern, just 'this'. | # an 'all' pattern, just 'this'. | ||||
self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this') | self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this') | ||||
self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this') | self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this') | ||||
# We're using includematcher instead of patterns because it behaves slightly | # We're using includematcher instead of patterns because it behaves slightly | ||||
# better (giving narrower results) than patternmatcher. | # better (giving narrower results) than patternmatcher. | ||||
def testVisitdirIncludeIncludfe(self): | def testVisitdirIncludeInclude(self): | ||||
m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | ||||
m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | ||||
dm = matchmod.differencematcher(m1, m2) | dm = matchmod.differencematcher(m1, m2) | ||||
self.assertEqual(dm.visitdir(b''), True) | self.assertEqual(dm.visitdir(b''), True) | ||||
self.assertEqual(dm.visitdir(b'dir'), True) | self.assertEqual(dm.visitdir(b'dir'), True) | ||||
self.assertEqual(dm.visitdir(b'dir/subdir'), b'all') | self.assertEqual(dm.visitdir(b'dir/subdir'), b'all') | ||||
self.assertFalse(dm.visitdir(b'dir/foo')) | self.assertFalse(dm.visitdir(b'dir/foo')) | ||||
self.assertFalse(dm.visitdir(b'folder')) | self.assertFalse(dm.visitdir(b'folder')) | ||||
self.assertEqual(im.visitchildrenset(b'dir/foo'), set()) | self.assertEqual(im.visitchildrenset(b'dir/foo'), set()) | ||||
self.assertEqual(im.visitchildrenset(b'folder'), set()) | self.assertEqual(im.visitchildrenset(b'folder'), set()) | ||||
# OPT: We should probably return 'all' for these | # OPT: We should probably return 'all' for these | ||||
self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), b'this') | self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), b'this') | ||||
self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'this') | self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'this') | ||||
# We're using includematcher instead of patterns because it behaves slightly | # We're using includematcher instead of patterns because it behaves slightly | ||||
# better (giving narrower results) than patternmatcher. | # better (giving narrower results) than patternmatcher. | ||||
def testVisitdirIncludeIncludfe(self): | def testVisitdirIncludeInclude(self): | ||||
m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | ||||
m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | ||||
im = matchmod.intersectmatchers(m1, m2) | im = matchmod.intersectmatchers(m1, m2) | ||||
self.assertEqual(im.visitdir(b''), True) | self.assertEqual(im.visitdir(b''), True) | ||||
self.assertEqual(im.visitdir(b'dir'), True) | self.assertEqual(im.visitdir(b'dir'), True) | ||||
self.assertFalse(im.visitdir(b'dir/subdir')) | self.assertFalse(im.visitdir(b'dir/subdir')) | ||||
self.assertFalse(im.visitdir(b'dir/foo')) | self.assertFalse(im.visitdir(b'dir/foo')) | ||||
self.assertFalse(im.visitdir(b'folder')) | self.assertFalse(im.visitdir(b'folder')) | ||||
self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | ||||
self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all') | self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all') | ||||
self.assertEqual(um.visitchildrenset(b'folder'), b'all') | self.assertEqual(um.visitchildrenset(b'folder'), b'all') | ||||
self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all') | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all') | ||||
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all') | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all') | ||||
# We're using includematcher instead of patterns because it behaves slightly | # We're using includematcher instead of patterns because it behaves slightly | ||||
# better (giving narrower results) than patternmatcher. | # better (giving narrower results) than patternmatcher. | ||||
def testVisitdirIncludeIncludfe(self): | def testVisitdirIncludeInclude(self): | ||||
m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | ||||
m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | ||||
um = matchmod.unionmatcher([m1, m2]) | um = matchmod.unionmatcher([m1, m2]) | ||||
self.assertEqual(um.visitdir(b''), True) | self.assertEqual(um.visitdir(b''), True) | ||||
self.assertEqual(um.visitdir(b'dir'), True) | self.assertEqual(um.visitdir(b'dir'), True) | ||||
self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | ||||
self.assertFalse(um.visitdir(b'dir/foo')) | self.assertFalse(um.visitdir(b'dir/foo')) | ||||
self.assertFalse(um.visitdir(b'folder')) | self.assertFalse(um.visitdir(b'folder')) |