##// END OF EJS Templates
revlog: subclass the new `repository.iverifyproblem` Protocol class...
revlog: subclass the new `repository.iverifyproblem` Protocol class This is the same transformation as 3a90a6fd710d did for dirstate, but the CamelCase naming was already cleaned up here. We shouldn't have to explicitly subclass, but I'm doing so to test the interplay of regular attributes and the `attrs` class. Also, PyCharm has a nifty feature that puts a jump point in the gutter to navigate back and forth between the base class and subclasses (and override functions and base class functions) when there's an explicit subclassing. Additionally, PyCharm will immediately flag signature mismatches without a 40m pytype run.

File last commit:

r52462:b32c3146 stable
r53365:4ef6dbc2 default
Show More
test-match.py
1009 lines | 45.1 KiB | text/x-python | PythonLexer
Martin von Zweigbergk
match: override visitdir() in nevermatcher to return False...
r33583 import unittest
import silenttestrunner
from mercurial import (
match as matchmod,
spectral
match: add tests for visitdir functionality...
r38988 util,
Martin von Zweigbergk
match: override visitdir() in nevermatcher to return False...
r33583 )
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
match: make sure `root` argument is always an absolute path (API)...
r44401 noop_auditor = lambda name: None
spectral
match: add tests for visitdir functionality...
r38988 class BaseMatcherTests(unittest.TestCase):
def testVisitdir(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m = matchmod.basematcher()
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertTrue(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrenset(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m = matchmod.basematcher()
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), b'this')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class AlwaysMatcherTests(unittest.TestCase):
def testVisitdir(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m = matchmod.alwaysmatcher()
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitdir(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitdir(b'dir'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrenset(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m = matchmod.alwaysmatcher()
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
match: override visitdir() in nevermatcher to return False...
r33583 class NeverMatcherTests(unittest.TestCase):
def testVisitdir(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m = matchmod.nevermatcher()
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertFalse(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertFalse(m.visitdir(b'dir'))
Martin von Zweigbergk
match: override visitdir() in nevermatcher to return False...
r33583
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrenset(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m = matchmod.nevermatcher()
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), set())
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class PredicateMatcherTests(unittest.TestCase):
# predicatematcher does not currently define either of these methods, so
# this is equivalent to BaseMatcherTests.
def testVisitdir(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m = matchmod.predicatematcher(lambda *a: False)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertTrue(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrenset(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m = matchmod.predicatematcher(lambda *a: False)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), b'this')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class PatternMatcherTests(unittest.TestCase):
def testVisitdirPrefix(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
)
spectral
match: add tests for visitdir functionality...
r38988 assert isinstance(m, matchmod.patternmatcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertTrue(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir'))
self.assertEqual(m.visitdir(b'dir/subdir'), b'all')
spectral
match: add tests for visitdir functionality...
r38988 # OPT: This should probably be 'all' if its parent is?
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir/subdir/x'))
self.assertFalse(m.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetPrefix(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 assert isinstance(m, matchmod.patternmatcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), b'this')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: This should probably be 'all' if its parent is?
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
self.assertEqual(m.visitchildrenset(b'folder'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirRootfilesin(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 util.localpath(b'/repo'),
b'',
patterns=[b'rootfilesin:dir/subdir'],
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 )
spectral
match: add tests for visitdir functionality...
r38988 assert isinstance(m, matchmod.patternmatcher)
Arseniy Alekseyev
match: fix the "visitdir" method on "rootfilesin" matchers...
r52462 # 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'))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertFalse(m.visitdir(b'folder'))
Arseniy Alekseyev
match: fix the "visitdir" method on "rootfilesin" matchers...
r52462 self.assertTrue(m.visitdir(b''))
self.assertTrue(m.visitdir(b'dir'))
self.assertTrue(m.visitdir(b'dir/subdir'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetRootfilesin(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
Augie Fackler
formating: upgrade to black 20.8b1...
r46554 util.localpath(b'/repo'),
b'',
patterns=[b'rootfilesin:dir/subdir'],
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 )
spectral
match: add visitchildrenset complement to visitdir...
r38990 assert isinstance(m, matchmod.patternmatcher)
Arseniy Alekseyev
match: fix the "visitdir" method on "rootfilesin" matchers...
r52462 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'folder'), set())
Arseniy Alekseyev
match: fix the "visitdir" method on "rootfilesin" matchers...
r52462 # 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')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirGlob(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'glob:dir/z*']
)
spectral
match: add tests for visitdir functionality...
r38988 assert isinstance(m, matchmod.patternmatcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertTrue(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir'))
self.assertFalse(m.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988 # OPT: these should probably be False.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir/subdir'))
self.assertTrue(m.visitdir(b'dir/subdir/x'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetGlob(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'glob:dir/z*']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 assert isinstance(m, matchmod.patternmatcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), b'this')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'folder'), set())
self.assertEqual(m.visitchildrenset(b'dir'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: these should probably be set().
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this')
self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
Raphaël Gomès
match: add `filepath:` pattern to match an exact filepath relative to the root...
r51588 def testVisitdirFilepath(self):
m = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'filepath:dir/z']
)
assert isinstance(m, matchmod.patternmatcher)
self.assertTrue(m.visitdir(b''))
self.assertTrue(m.visitdir(b'dir'))
self.assertFalse(m.visitdir(b'folder'))
self.assertFalse(m.visitdir(b'dir/subdir'))
self.assertFalse(m.visitdir(b'dir/subdir/x'))
def testVisitchildrensetFilepath(self):
m = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'filepath:dir/z']
)
assert isinstance(m, matchmod.patternmatcher)
self.assertEqual(m.visitchildrenset(b''), b'this')
self.assertEqual(m.visitchildrenset(b'folder'), set())
self.assertEqual(m.visitchildrenset(b'dir'), b'this')
self.assertEqual(m.visitchildrenset(b'dir/subdir'), set())
self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class IncludeMatcherTests(unittest.TestCase):
def testVisitdirPrefix(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
spectral
match: add tests for visitdir functionality...
r38988 assert isinstance(m, matchmod.includematcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertTrue(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir'))
self.assertEqual(m.visitdir(b'dir/subdir'), b'all')
spectral
match: add tests for visitdir functionality...
r38988 # OPT: This should probably be 'all' if its parent is?
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir/subdir/x'))
self.assertFalse(m.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetPrefix(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 assert isinstance(m, matchmod.includematcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'})
self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: This should probably be 'all' if its parent is?
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
self.assertEqual(m.visitchildrenset(b'folder'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirRootfilesin(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir/subdir']
)
spectral
match: add tests for visitdir functionality...
r38988 assert isinstance(m, matchmod.includematcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertTrue(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir'))
self.assertTrue(m.visitdir(b'dir/subdir'))
self.assertFalse(m.visitdir(b'dir/subdir/x'))
self.assertFalse(m.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetRootfilesin(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir/subdir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 assert isinstance(m, matchmod.includematcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'})
self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this')
self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
self.assertEqual(m.visitchildrenset(b'folder'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirGlob(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'glob:dir/z*']
)
spectral
match: add tests for visitdir functionality...
r38988 assert isinstance(m, matchmod.includematcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertTrue(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir'))
self.assertFalse(m.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988 # OPT: these should probably be False.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir/subdir'))
self.assertTrue(m.visitdir(b'dir/subdir/x'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetGlob(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'glob:dir/z*']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 assert isinstance(m, matchmod.includematcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'folder'), set())
self.assertEqual(m.visitchildrenset(b'dir'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: these should probably be set().
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this')
self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
Raphaël Gomès
match: add `filepath:` pattern to match an exact filepath relative to the root...
r51588 def testVisitdirFilepath(self):
m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'filepath:dir/z']
)
assert isinstance(m, matchmod.includematcher)
self.assertTrue(m.visitdir(b''))
self.assertTrue(m.visitdir(b'dir'))
self.assertFalse(m.visitdir(b'folder'))
self.assertFalse(m.visitdir(b'dir/subdir'))
self.assertFalse(m.visitdir(b'dir/subdir/x'))
def testVisitchildrensetFilepath(self):
m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'filepath:dir/z']
)
assert isinstance(m, matchmod.includematcher)
self.assertEqual(m.visitchildrenset(b''), {b'dir'})
self.assertEqual(m.visitchildrenset(b'folder'), set())
self.assertEqual(m.visitchildrenset(b'dir'), {b'z'})
self.assertEqual(m.visitchildrenset(b'dir/subdir'), set())
self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class ExactMatcherTests(unittest.TestCase):
def testVisitdir(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments from {always,never,exact}() (API)...
r41825 m = matchmod.exact(files=[b'dir/subdir/foo.txt'])
spectral
match: add tests for visitdir functionality...
r38988 assert isinstance(m, matchmod.exactmatcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertTrue(m.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertTrue(m.visitdir(b'dir'))
self.assertTrue(m.visitdir(b'dir/subdir'))
self.assertFalse(m.visitdir(b'dir/subdir/foo.txt'))
self.assertFalse(m.visitdir(b'dir/foo'))
self.assertFalse(m.visitdir(b'dir/subdir/x'))
self.assertFalse(m.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrenset(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments from {always,never,exact}() (API)...
r41825 m = matchmod.exact(files=[b'dir/subdir/foo.txt'])
spectral
match: add visitchildrenset complement to visitdir...
r38990 assert isinstance(m, matchmod.exactmatcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'})
Kyle Lippincott
match: make exactmatcher.visitchildrenset return file children as well...
r39297 self.assertEqual(m.visitchildrenset(b'dir/subdir'), {b'foo.txt'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
self.assertEqual(m.visitchildrenset(b'dir/subdir/foo.txt'), set())
self.assertEqual(m.visitchildrenset(b'folder'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
Kyle Lippincott
match: make exactmatcher.visitchildrenset return file children as well...
r39297 def testVisitchildrensetFilesAndDirs(self):
Augie Fackler
formatting: blacken the codebase...
r43346 m = matchmod.exact(
files=[
b'rootfile.txt',
b'a/file1.txt',
b'a/b/file2.txt',
# no file in a/b/c
b'a/b/c/d/file4.txt',
]
)
Kyle Lippincott
match: make exactmatcher.visitchildrenset return file children as well...
r39297 assert isinstance(m, matchmod.exactmatcher)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), {b'a', b'rootfile.txt'})
Kyle Lippincott
match: make exactmatcher.visitchildrenset return file children as well...
r39297 self.assertEqual(m.visitchildrenset(b'a'), {b'b', b'file1.txt'})
self.assertEqual(m.visitchildrenset(b'a/b'), {b'c', b'file2.txt'})
self.assertEqual(m.visitchildrenset(b'a/b/c'), {b'd'})
self.assertEqual(m.visitchildrenset(b'a/b/c/d'), {b'file4.txt'})
self.assertEqual(m.visitchildrenset(b'a/b/c/d/e'), set())
self.assertEqual(m.visitchildrenset(b'folder'), set())
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class DifferenceMatcherTests(unittest.TestCase):
def testVisitdirM2always(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.alwaysmatcher()
spectral
match: add tests for visitdir functionality...
r38988 dm = matchmod.differencematcher(m1, m2)
# dm should be equivalent to a nevermatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertFalse(dm.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 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'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2always(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.alwaysmatcher()
spectral
match: add visitchildrenset complement to visitdir...
r38990 dm = matchmod.differencematcher(m1, m2)
# dm should be equivalent to a nevermatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(dm.visitchildrenset(b''), set())
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(dm.visitchildrenset(b'dir'), set())
self.assertEqual(dm.visitchildrenset(b'dir/subdir'), set())
self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), set())
self.assertEqual(dm.visitchildrenset(b'dir/foo'), set())
self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), set())
self.assertEqual(dm.visitchildrenset(b'folder'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirM2never(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.nevermatcher()
spectral
match: add tests for visitdir functionality...
r38988 dm = matchmod.differencematcher(m1, m2)
Pulkit Goyal
match: teach diffmatcher.visitdir() to return 'all' if possible...
r41669 # dm should be equivalent to a alwaysmatcher.
spectral
match: add tests for visitdir functionality...
r38988 #
# 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.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(dm.visitdir(b''), b'all')
Augie Fackler
tests: fix test-match.py on Python3...
r41671 self.assertEqual(dm.visitdir(b'dir'), b'all')
self.assertEqual(dm.visitdir(b'dir/subdir'), b'all')
self.assertEqual(dm.visitdir(b'dir/subdir/z'), b'all')
self.assertEqual(dm.visitdir(b'dir/foo'), b'all')
self.assertEqual(dm.visitdir(b'dir/subdir/x'), b'all')
self.assertEqual(dm.visitdir(b'folder'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2never(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.nevermatcher()
spectral
match: add visitchildrenset complement to visitdir...
r38990 dm = matchmod.differencematcher(m1, m2)
# dm should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(dm.visitchildrenset(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 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')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirM2SubdirPrefix(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m2 = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
)
spectral
match: add tests for visitdir functionality...
r38988 dm = matchmod.differencematcher(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(dm.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(dm.visitdir(b'dir'), True)
self.assertFalse(dm.visitdir(b'dir/subdir'))
spectral
match: add tests for visitdir functionality...
r38988 # 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.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(dm.visitdir(b'dir/subdir/z'), True)
self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
Augie Fackler
tests: fix test-match.py on Python3...
r41671 self.assertEqual(dm.visitdir(b'dir/foo'), b'all')
self.assertEqual(dm.visitdir(b'folder'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2SubdirPrefix(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m2 = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 dm = matchmod.differencematcher(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(dm.visitchildrenset(b''), b'this')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 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')
spectral
match: add visitchildrenset complement to visitdir...
r38990 # 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'.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this')
self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
Martin von Zweigbergk
tests: fix typo "includfe"...
r43692 def testVisitdirIncludeInclude(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
)
spectral
match: add tests for visitdir functionality...
r38988 dm = matchmod.differencematcher(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(dm.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(dm.visitdir(b'dir'), True)
Augie Fackler
tests: fix test-match.py on Python3...
r41671 self.assertEqual(dm.visitdir(b'dir/subdir'), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertFalse(dm.visitdir(b'dir/foo'))
self.assertFalse(dm.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988 # 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.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(dm.visitdir(b'dir/subdir/z'), True)
self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 dm = matchmod.differencematcher(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(dm.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 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())
spectral
match: add visitchildrenset complement to visitdir...
r38990 # 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'.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this')
self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class IntersectionMatcherTests(unittest.TestCase):
def testVisitdirM2always(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.alwaysmatcher()
spectral
match: add tests for visitdir functionality...
r38988 im = matchmod.intersectmatchers(m1, m2)
# im should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitdir(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitdir(b'dir'), b'all')
self.assertEqual(im.visitdir(b'dir/subdir'), b'all')
self.assertEqual(im.visitdir(b'dir/subdir/z'), b'all')
self.assertEqual(im.visitdir(b'dir/foo'), b'all')
self.assertEqual(im.visitdir(b'dir/subdir/x'), b'all')
self.assertEqual(im.visitdir(b'folder'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2always(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.alwaysmatcher()
spectral
match: add visitchildrenset complement to visitdir...
r38990 im = matchmod.intersectmatchers(m1, m2)
# im should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitchildrenset(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir'), b'all')
self.assertEqual(im.visitchildrenset(b'dir/subdir'), b'all')
self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), b'all')
self.assertEqual(im.visitchildrenset(b'dir/foo'), b'all')
self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'all')
self.assertEqual(im.visitchildrenset(b'folder'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirM2never(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.nevermatcher()
spectral
match: add tests for visitdir functionality...
r38988 im = matchmod.intersectmatchers(m1, m2)
# im should be equivalent to a nevermatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertFalse(im.visitdir(b''))
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertFalse(im.visitdir(b'dir'))
self.assertFalse(im.visitdir(b'dir/subdir'))
self.assertFalse(im.visitdir(b'dir/subdir/z'))
self.assertFalse(im.visitdir(b'dir/foo'))
self.assertFalse(im.visitdir(b'dir/subdir/x'))
self.assertFalse(im.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2never(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.nevermatcher()
spectral
match: add visitchildrenset complement to visitdir...
r38990 im = matchmod.intersectmatchers(m1, m2)
# im should be equivalent to a nevermqtcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitchildrenset(b''), set())
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set())
self.assertEqual(im.visitchildrenset(b'folder'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirM2SubdirPrefix(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m2 = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
)
spectral
match: add tests for visitdir functionality...
r38988 im = matchmod.intersectmatchers(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitdir(b'dir'), True)
self.assertEqual(im.visitdir(b'dir/subdir'), b'all')
self.assertFalse(im.visitdir(b'dir/foo'))
self.assertFalse(im.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988 # OPT: We should probably return 'all' for these; we don't because
# patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of
# an 'all' pattern, just True.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitdir(b'dir/subdir/z'), True)
self.assertEqual(im.visitdir(b'dir/subdir/x'), True)
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2SubdirPrefix(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 im = matchmod.intersectmatchers(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'})
self.assertEqual(im.visitchildrenset(b'dir/subdir'), b'all')
self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
self.assertEqual(im.visitchildrenset(b'folder'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: We should probably return 'all' for these
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), b'this')
self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
Martin von Zweigbergk
tests: fix typo "includfe"...
r43692 def testVisitdirIncludeInclude(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
)
spectral
match: add tests for visitdir functionality...
r38988 im = matchmod.intersectmatchers(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitdir(b'dir'), True)
self.assertFalse(im.visitdir(b'dir/subdir'))
self.assertFalse(im.visitdir(b'dir/foo'))
self.assertFalse(im.visitdir(b'folder'))
self.assertFalse(im.visitdir(b'dir/subdir/z'))
self.assertFalse(im.visitdir(b'dir/subdir/x'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 im = matchmod.intersectmatchers(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir'), b'this')
self.assertEqual(im.visitchildrenset(b'dir/subdir'), set())
self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
self.assertEqual(im.visitchildrenset(b'folder'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
def testVisitdirIncludeInclude2(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:folder']
)
spectral
match: add tests for visitdir functionality...
r38988 im = matchmod.intersectmatchers(m1, m2)
# FIXME: is True correct here?
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertFalse(im.visitdir(b'dir'))
self.assertFalse(im.visitdir(b'dir/subdir'))
self.assertFalse(im.visitdir(b'dir/foo'))
self.assertFalse(im.visitdir(b'folder'))
self.assertFalse(im.visitdir(b'dir/subdir/z'))
self.assertFalse(im.visitdir(b'dir/subdir/x'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude2(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:folder']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 im = matchmod.intersectmatchers(m1, m2)
# FIXME: is set() correct here?
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitchildrenset(b''), set())
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir'), set())
self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
self.assertEqual(im.visitchildrenset(b'folder'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
def testVisitdirIncludeInclude3(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
spectral
match: add tests for visitdir functionality...
r38988 im = matchmod.intersectmatchers(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitdir(b'dir'), True)
self.assertEqual(im.visitdir(b'dir/subdir'), True)
self.assertFalse(im.visitdir(b'dir/foo'))
self.assertFalse(im.visitdir(b'folder'))
self.assertFalse(im.visitdir(b'dir/subdir/z'))
spectral
match: add tests for visitdir functionality...
r38988 # OPT: this should probably be 'all' not True.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitdir(b'dir/subdir/x'), True)
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude3(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 im = matchmod.intersectmatchers(m1, m2)
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'})
self.assertEqual(im.visitchildrenset(b'dir/subdir'), {b'x'})
self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
self.assertEqual(im.visitchildrenset(b'folder'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: this should probably be 'all' not 'this'.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
def testVisitdirIncludeInclude4(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
)
spectral
match: add tests for visitdir functionality...
r38988 im = matchmod.intersectmatchers(m1, m2)
# OPT: these next three could probably be False as well.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitdir(b'dir'), True)
self.assertEqual(im.visitdir(b'dir/subdir'), True)
self.assertFalse(im.visitdir(b'dir/foo'))
self.assertFalse(im.visitdir(b'folder'))
self.assertFalse(im.visitdir(b'dir/subdir/z'))
self.assertFalse(im.visitdir(b'dir/subdir/x'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude4(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 im = matchmod.intersectmatchers(m1, m2)
# OPT: these next two could probably be set() as well.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(im.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'})
self.assertEqual(im.visitchildrenset(b'dir/subdir'), set())
self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
self.assertEqual(im.visitchildrenset(b'folder'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class UnionMatcherTests(unittest.TestCase):
def testVisitdirM2always(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.alwaysmatcher()
spectral
match: add tests for visitdir functionality...
r38988 um = matchmod.unionmatcher([m1, m2])
# um should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitdir(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitdir(b'dir/foo'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
self.assertEqual(um.visitdir(b'folder'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2always(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.alwaysmatcher()
spectral
match: add visitchildrenset complement to visitdir...
r38990 um = matchmod.unionmatcher([m1, m2])
# um should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitchildrenset(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
self.assertEqual(um.visitchildrenset(b'folder'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirM1never(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.nevermatcher()
m2 = matchmod.alwaysmatcher()
spectral
match: add tests for visitdir functionality...
r38988 um = matchmod.unionmatcher([m1, m2])
# um should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitdir(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitdir(b'dir/foo'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
self.assertEqual(um.visitdir(b'folder'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM1never(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.nevermatcher()
m2 = matchmod.alwaysmatcher()
spectral
match: add visitchildrenset complement to visitdir...
r38990 um = matchmod.unionmatcher([m1, m2])
# um should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitchildrenset(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
self.assertEqual(um.visitchildrenset(b'folder'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirM2never(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.nevermatcher()
spectral
match: add tests for visitdir functionality...
r38988 um = matchmod.unionmatcher([m1, m2])
# um should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitdir(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitdir(b'dir/foo'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
self.assertEqual(um.visitdir(b'folder'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2never(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
m2 = matchmod.nevermatcher()
spectral
match: add visitchildrenset complement to visitdir...
r38990 um = matchmod.unionmatcher([m1, m2])
# um should be equivalent to a alwaysmatcher.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitchildrenset(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
self.assertEqual(um.visitchildrenset(b'folder'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 def testVisitdirM2SubdirPrefix(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m2 = matchmod.match(
util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
)
spectral
match: add tests for visitdir functionality...
r38988 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitdir(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
self.assertEqual(um.visitdir(b'dir/foo'), b'all')
self.assertEqual(um.visitdir(b'folder'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetM2SubdirPrefix(self):
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 m1 = matchmod.alwaysmatcher()
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitchildrenset(b''), b'all')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir'), 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'folder'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
Martin von Zweigbergk
tests: fix typo "includfe"...
r43692 def testVisitdirIncludeInclude(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
)
spectral
match: add tests for visitdir functionality...
r38988 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir'), True)
self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
self.assertFalse(um.visitdir(b'dir/foo'))
self.assertFalse(um.visitdir(b'folder'))
spectral
match: add tests for visitdir functionality...
r38988 # OPT: These two should probably be 'all' not True.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir/subdir/z'), True)
self.assertEqual(um.visitdir(b'dir/subdir/x'), True)
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir'), b'this')
self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/foo'), set())
self.assertEqual(um.visitchildrenset(b'folder'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: These next two could be 'all' instead of 'this'.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this')
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
def testVisitdirIncludeInclude2(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:folder']
)
spectral
match: add tests for visitdir functionality...
r38988 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir'), True)
self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
self.assertFalse(um.visitdir(b'dir/foo'))
self.assertEqual(um.visitdir(b'folder'), b'all')
spectral
match: add tests for visitdir functionality...
r38988 # OPT: These should probably be 'all' not True.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir/subdir/z'), True)
self.assertEqual(um.visitdir(b'dir/subdir/x'), True)
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude2(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:folder']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitchildrenset(b''), {b'folder', b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/foo'), set())
self.assertEqual(um.visitchildrenset(b'folder'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: These next two could be 'all' instead of 'this'.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this')
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
def testVisitdirIncludeInclude3(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
spectral
match: add tests for visitdir functionality...
r38988 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir'), True)
self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
self.assertFalse(um.visitdir(b'dir/foo'))
self.assertFalse(um.visitdir(b'folder'))
self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
spectral
match: add tests for visitdir functionality...
r38988 # OPT: this should probably be 'all' not True.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir/subdir/z'), True)
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude3(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/foo'), set())
self.assertEqual(um.visitchildrenset(b'folder'), set())
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: this should probably be 'all' not 'this'.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this')
spectral
match: add visitchildrenset complement to visitdir...
r38990
spectral
match: add tests for visitdir functionality...
r38988 # We're using includematcher instead of patterns because it behaves slightly
# better (giving narrower results) than patternmatcher.
def testVisitdirIncludeInclude4(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
)
spectral
match: add tests for visitdir functionality...
r38988 um = matchmod.unionmatcher([m1, m2])
# OPT: these next three could probably be False as well.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitdir(b'dir'), True)
self.assertEqual(um.visitdir(b'dir/subdir'), True)
self.assertFalse(um.visitdir(b'dir/foo'))
self.assertFalse(um.visitdir(b'folder'))
self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrensetIncludeInclude4(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m1 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
)
m2 = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
)
spectral
match: add visitchildrenset complement to visitdir...
r38990 um = matchmod.unionmatcher([m1, m2])
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(um.visitchildrenset(b''), {b'dir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
self.assertEqual(um.visitchildrenset(b'dir/subdir'), {b'x', b'z'})
self.assertEqual(um.visitchildrenset(b'dir/foo'), set())
self.assertEqual(um.visitchildrenset(b'folder'), set())
self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class SubdirMatcherTests(unittest.TestCase):
def testVisitdir(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 sm = matchmod.subdirmatcher(b'dir', m)
spectral
match: add tests for visitdir functionality...
r38988
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(sm.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(sm.visitdir(b'subdir'), b'all')
spectral
match: add tests for visitdir functionality...
r38988 # OPT: These next two should probably be 'all' not True.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(sm.visitdir(b'subdir/x'), True)
self.assertEqual(sm.visitdir(b'subdir/z'), True)
self.assertFalse(sm.visitdir(b'foo'))
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrenset(self):
Matt Harbison
tests: convert the `root` arg of matchmod.match() to local path separators...
r44416 m = matchmod.match(
util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 sm = matchmod.subdirmatcher(b'dir', m)
spectral
match: add visitchildrenset complement to visitdir...
r38990
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(sm.visitchildrenset(b''), {b'subdir'})
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(sm.visitchildrenset(b'subdir'), b'all')
spectral
match: add visitchildrenset complement to visitdir...
r38990 # OPT: These next two should probably be 'all' not 'this'.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(sm.visitchildrenset(b'subdir/x'), b'this')
self.assertEqual(sm.visitchildrenset(b'subdir/z'), b'this')
self.assertEqual(sm.visitchildrenset(b'foo'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
spectral
match: add tests for visitdir functionality...
r38988 class PrefixdirMatcherTests(unittest.TestCase):
def testVisitdir(self):
Augie Fackler
formatting: blacken the codebase...
r43346 m = matchmod.match(
Martin von Zweigbergk
match: make sure `root` argument is always an absolute path (API)...
r44401 util.localpath(b'/root/d'),
b'e/f',
[b'../a.txt', b'b.txt'],
auditor=noop_auditor,
Augie Fackler
formatting: blacken the codebase...
r43346 )
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 pm = matchmod.prefixdirmatcher(b'd', m)
spectral
match: add tests for visitdir functionality...
r38988
# `m` elides 'd' because it's part of the root, and the rest of the
# patterns are relative.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(bool(m(b'a.txt')), False)
self.assertEqual(bool(m(b'b.txt')), False)
self.assertEqual(bool(m(b'e/a.txt')), True)
self.assertEqual(bool(m(b'e/b.txt')), False)
self.assertEqual(bool(m(b'e/f/b.txt')), True)
spectral
match: add tests for visitdir functionality...
r38988
# The prefix matcher re-adds 'd' to the paths, so they need to be
# specified when using the prefixdirmatcher.
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(bool(pm(b'a.txt')), False)
self.assertEqual(bool(pm(b'b.txt')), False)
self.assertEqual(bool(pm(b'd/e/a.txt')), True)
self.assertEqual(bool(pm(b'd/e/b.txt')), False)
self.assertEqual(bool(pm(b'd/e/f/b.txt')), True)
spectral
match: add tests for visitdir functionality...
r38988
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitdir(b'e'), True)
self.assertEqual(m.visitdir(b'e/f'), True)
self.assertEqual(m.visitdir(b'e/f/g'), False)
spectral
match: add tests for visitdir functionality...
r38988
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(pm.visitdir(b''), True)
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(pm.visitdir(b'd'), True)
self.assertEqual(pm.visitdir(b'd/e'), True)
self.assertEqual(pm.visitdir(b'd/e/f'), True)
self.assertEqual(pm.visitdir(b'd/e/f/g'), False)
spectral
match: add tests for visitdir functionality...
r38988
spectral
match: add visitchildrenset complement to visitdir...
r38990 def testVisitchildrenset(self):
Augie Fackler
formatting: blacken the codebase...
r43346 m = matchmod.match(
Martin von Zweigbergk
match: make sure `root` argument is always an absolute path (API)...
r44401 util.localpath(b'/root/d'),
b'e/f',
[b'../a.txt', b'b.txt'],
auditor=noop_auditor,
Augie Fackler
formatting: blacken the codebase...
r43346 )
Martin von Zweigbergk
match: delete unused root and cwd arguments to constructors (API)...
r41824 pm = matchmod.prefixdirmatcher(b'd', m)
spectral
match: add visitchildrenset complement to visitdir...
r38990
# OPT: visitchildrenset could possibly return {'e'} and {'f'} for these
# next two, respectively; patternmatcher does not have this
# optimization.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(m.visitchildrenset(b''), b'this')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(m.visitchildrenset(b'e'), b'this')
self.assertEqual(m.visitchildrenset(b'e/f'), b'this')
self.assertEqual(m.visitchildrenset(b'e/f/g'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
# OPT: visitchildrenset could possibly return {'d'}, {'e'}, and {'f'}
# for these next three, respectively; patternmatcher does not have this
# optimization.
Martin von Zweigbergk
match: use '' instead of '.' for root directory (API)...
r42528 self.assertEqual(pm.visitchildrenset(b''), b'this')
Augie Fackler
tests: make all the string constants in test-match.py be bytes...
r38999 self.assertEqual(pm.visitchildrenset(b'd'), b'this')
self.assertEqual(pm.visitchildrenset(b'd/e'), b'this')
self.assertEqual(pm.visitchildrenset(b'd/e/f'), b'this')
self.assertEqual(pm.visitchildrenset(b'd/e/f/g'), set())
spectral
match: add visitchildrenset complement to visitdir...
r38990
Augie Fackler
formatting: blacken the codebase...
r43346
Martin von Zweigbergk
match: override visitdir() in nevermatcher to return False...
r33583 if __name__ == '__main__':
silenttestrunner.main(__name__)