Mercurial > hg
diff tests/test-match.py @ 51569:b32c3146ec34 stable
match: fix the "visitdir" method on "rootfilesin" matchers
This fixes just the Python side, the fix for the rust side will follow shortly.
author | Arseniy Alekseyev <aalekseyev@janestreet.com> |
---|---|
date | Fri, 12 Apr 2024 15:39:21 +0100 |
parents | 1c31b343e514 |
children |
line wrap: on
line diff
--- a/tests/test-match.py Fri Apr 12 14:21:14 2024 +0100 +++ b/tests/test-match.py Fri Apr 12 15:39:21 2024 +0100 @@ -94,12 +94,14 @@ patterns=[b'rootfilesin:dir/subdir'], ) assert isinstance(m, matchmod.patternmatcher) - self.assertFalse(m.visitdir(b'dir/subdir/x')) + # OPT: we shouldn't visit [x] as a directory, + # but we should still visit it as a file. + # Unfortunately, `visitdir` is used for both. + self.assertTrue(m.visitdir(b'dir/subdir/x')) self.assertFalse(m.visitdir(b'folder')) - # FIXME: These should probably be True. - self.assertFalse(m.visitdir(b'')) - self.assertFalse(m.visitdir(b'dir')) - self.assertFalse(m.visitdir(b'dir/subdir')) + self.assertTrue(m.visitdir(b'')) + self.assertTrue(m.visitdir(b'dir')) + self.assertTrue(m.visitdir(b'dir/subdir')) def testVisitchildrensetRootfilesin(self): m = matchmod.match( @@ -108,13 +110,13 @@ patterns=[b'rootfilesin:dir/subdir'], ) assert isinstance(m, matchmod.patternmatcher) - self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set()) + self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this') self.assertEqual(m.visitchildrenset(b'folder'), set()) - # FIXME: These should probably be {'dir'}, {'subdir'} and 'this', - # respectively, or at least 'this' for all three. - self.assertEqual(m.visitchildrenset(b''), set()) - self.assertEqual(m.visitchildrenset(b'dir'), set()) - self.assertEqual(m.visitchildrenset(b'dir/subdir'), set()) + # OPT: These should probably be {'dir'}, {'subdir'} and 'this', + # respectively + self.assertEqual(m.visitchildrenset(b''), b'this') + self.assertEqual(m.visitchildrenset(b'dir'), b'this') + self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this') def testVisitdirGlob(self): m = matchmod.match(