annotate tests/test-match.py @ 50916:98b8836d0e82

hgweb: use sysstr to set attribute on diff option Attribute identifier should be `str` not `bytes`.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 01 Sep 2023 12:09:54 +0200
parents 1c31b343e514
children b32c3146ec34
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33582
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
1 import unittest
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
2
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
3 import silenttestrunner
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
4
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
5 from mercurial import (
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
6 match as matchmod,
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
7 util,
33582
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
8 )
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
9
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
10
43949
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
11 noop_auditor = lambda name: None
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
12
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
13
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
14 class BaseMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
15 def testVisitdir(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
16 m = matchmod.basematcher()
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
17 self.assertTrue(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
18 self.assertTrue(m.visitdir(b'dir'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
19
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
20 def testVisitchildrenset(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
21 m = matchmod.basematcher()
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
22 self.assertEqual(m.visitchildrenset(b''), b'this')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
23 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
24
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
25
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
26 class AlwaysMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
27 def testVisitdir(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
28 m = matchmod.alwaysmatcher()
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
29 self.assertEqual(m.visitdir(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
30 self.assertEqual(m.visitdir(b'dir'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
31
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
32 def testVisitchildrenset(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
33 m = matchmod.alwaysmatcher()
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
34 self.assertEqual(m.visitchildrenset(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
35 self.assertEqual(m.visitchildrenset(b'dir'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
36
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
37
33582
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
38 class NeverMatcherTests(unittest.TestCase):
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
39 def testVisitdir(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
40 m = matchmod.nevermatcher()
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
41 self.assertFalse(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
42 self.assertFalse(m.visitdir(b'dir'))
33582
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
43
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
44 def testVisitchildrenset(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
45 m = matchmod.nevermatcher()
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
46 self.assertEqual(m.visitchildrenset(b''), set())
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
47 self.assertEqual(m.visitchildrenset(b'dir'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
48
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
49
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
50 class PredicateMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
51 # predicatematcher does not currently define either of these methods, so
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
52 # this is equivalent to BaseMatcherTests.
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
53
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
54 def testVisitdir(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
55 m = matchmod.predicatematcher(lambda *a: False)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
56 self.assertTrue(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
57 self.assertTrue(m.visitdir(b'dir'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
58
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
59 def testVisitchildrenset(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
60 m = matchmod.predicatematcher(lambda *a: False)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
61 self.assertEqual(m.visitchildrenset(b''), b'this')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
62 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
63
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
64
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
65 class PatternMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
66 def testVisitdirPrefix(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
67 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
68 util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
69 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
70 assert isinstance(m, matchmod.patternmatcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
71 self.assertTrue(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
72 self.assertTrue(m.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
73 self.assertEqual(m.visitdir(b'dir/subdir'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
74 # OPT: This should probably be 'all' if its parent is?
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
75 self.assertTrue(m.visitdir(b'dir/subdir/x'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
76 self.assertFalse(m.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
77
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
78 def testVisitchildrensetPrefix(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
79 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
80 util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
81 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
82 assert isinstance(m, matchmod.patternmatcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
83 self.assertEqual(m.visitchildrenset(b''), b'this')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
84 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
85 self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
86 # OPT: This should probably be 'all' if its parent is?
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
87 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
88 self.assertEqual(m.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
89
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
90 def testVisitdirRootfilesin(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
91 m = matchmod.match(
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43964
diff changeset
92 util.localpath(b'/repo'),
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43964
diff changeset
93 b'',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43964
diff changeset
94 patterns=[b'rootfilesin:dir/subdir'],
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
95 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
96 assert isinstance(m, matchmod.patternmatcher)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
97 self.assertFalse(m.visitdir(b'dir/subdir/x'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
98 self.assertFalse(m.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
99 # FIXME: These should probably be True.
42346
38d85ec06552 match: drop unnecessary adding of '' to set of dirs
Martin von Zweigbergk <martinvonz@google.com>
parents: 42341
diff changeset
100 self.assertFalse(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
101 self.assertFalse(m.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
102 self.assertFalse(m.visitdir(b'dir/subdir'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
103
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
104 def testVisitchildrensetRootfilesin(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
105 m = matchmod.match(
45942
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43964
diff changeset
106 util.localpath(b'/repo'),
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43964
diff changeset
107 b'',
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 43964
diff changeset
108 patterns=[b'rootfilesin:dir/subdir'],
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
109 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
110 assert isinstance(m, matchmod.patternmatcher)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
111 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
112 self.assertEqual(m.visitchildrenset(b'folder'), set())
42346
38d85ec06552 match: drop unnecessary adding of '' to set of dirs
Martin von Zweigbergk <martinvonz@google.com>
parents: 42341
diff changeset
113 # FIXME: These should probably be {'dir'}, {'subdir'} and 'this',
38d85ec06552 match: drop unnecessary adding of '' to set of dirs
Martin von Zweigbergk <martinvonz@google.com>
parents: 42341
diff changeset
114 # respectively, or at least 'this' for all three.
38d85ec06552 match: drop unnecessary adding of '' to set of dirs
Martin von Zweigbergk <martinvonz@google.com>
parents: 42341
diff changeset
115 self.assertEqual(m.visitchildrenset(b''), set())
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
116 self.assertEqual(m.visitchildrenset(b'dir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
117 self.assertEqual(m.visitchildrenset(b'dir/subdir'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
118
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
119 def testVisitdirGlob(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
120 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
121 util.localpath(b'/repo'), b'', patterns=[b'glob:dir/z*']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
122 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
123 assert isinstance(m, matchmod.patternmatcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
124 self.assertTrue(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
125 self.assertTrue(m.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
126 self.assertFalse(m.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
127 # OPT: these should probably be False.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
128 self.assertTrue(m.visitdir(b'dir/subdir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
129 self.assertTrue(m.visitdir(b'dir/subdir/x'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
130
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
131 def testVisitchildrensetGlob(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
132 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
133 util.localpath(b'/repo'), b'', patterns=[b'glob:dir/z*']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
134 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
135 assert isinstance(m, matchmod.patternmatcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
136 self.assertEqual(m.visitchildrenset(b''), b'this')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
137 self.assertEqual(m.visitchildrenset(b'folder'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
138 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
139 # OPT: these should probably be set().
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
140 self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
141 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
142
50695
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
143 def testVisitdirFilepath(self):
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
144 m = matchmod.match(
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
145 util.localpath(b'/repo'), b'', patterns=[b'filepath:dir/z']
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
146 )
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
147 assert isinstance(m, matchmod.patternmatcher)
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
148 self.assertTrue(m.visitdir(b''))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
149 self.assertTrue(m.visitdir(b'dir'))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
150 self.assertFalse(m.visitdir(b'folder'))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
151 self.assertFalse(m.visitdir(b'dir/subdir'))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
152 self.assertFalse(m.visitdir(b'dir/subdir/x'))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
153
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
154 def testVisitchildrensetFilepath(self):
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
155 m = matchmod.match(
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
156 util.localpath(b'/repo'), b'', patterns=[b'filepath:dir/z']
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
157 )
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
158 assert isinstance(m, matchmod.patternmatcher)
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
159 self.assertEqual(m.visitchildrenset(b''), b'this')
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
160 self.assertEqual(m.visitchildrenset(b'folder'), set())
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
161 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
162 self.assertEqual(m.visitchildrenset(b'dir/subdir'), set())
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
163 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
164
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
165
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
166 class IncludeMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
167 def testVisitdirPrefix(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
168 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
169 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
170 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
171 assert isinstance(m, matchmod.includematcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
172 self.assertTrue(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
173 self.assertTrue(m.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
174 self.assertEqual(m.visitdir(b'dir/subdir'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
175 # OPT: This should probably be 'all' if its parent is?
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
176 self.assertTrue(m.visitdir(b'dir/subdir/x'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
177 self.assertFalse(m.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
178
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
179 def testVisitchildrensetPrefix(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
180 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
181 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
182 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
183 assert isinstance(m, matchmod.includematcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
184 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
185 self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
186 self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
187 # OPT: This should probably be 'all' if its parent is?
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
188 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
189 self.assertEqual(m.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
190
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
191 def testVisitdirRootfilesin(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
192 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
193 util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
194 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
195 assert isinstance(m, matchmod.includematcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
196 self.assertTrue(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
197 self.assertTrue(m.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
198 self.assertTrue(m.visitdir(b'dir/subdir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
199 self.assertFalse(m.visitdir(b'dir/subdir/x'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
200 self.assertFalse(m.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
201
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
202 def testVisitchildrensetRootfilesin(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
203 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
204 util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
205 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
206 assert isinstance(m, matchmod.includematcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
207 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
208 self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
209 self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
210 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
211 self.assertEqual(m.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
212
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
213 def testVisitdirGlob(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
214 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
215 util.localpath(b'/repo'), b'', include=[b'glob:dir/z*']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
216 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
217 assert isinstance(m, matchmod.includematcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
218 self.assertTrue(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
219 self.assertTrue(m.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
220 self.assertFalse(m.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
221 # OPT: these should probably be False.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
222 self.assertTrue(m.visitdir(b'dir/subdir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
223 self.assertTrue(m.visitdir(b'dir/subdir/x'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
224
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
225 def testVisitchildrensetGlob(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
226 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
227 util.localpath(b'/repo'), b'', include=[b'glob:dir/z*']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
228 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
229 assert isinstance(m, matchmod.includematcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
230 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
231 self.assertEqual(m.visitchildrenset(b'folder'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
232 self.assertEqual(m.visitchildrenset(b'dir'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
233 # OPT: these should probably be set().
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
234 self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
235 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
236
50695
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
237 def testVisitdirFilepath(self):
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
238 m = matchmod.match(
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
239 util.localpath(b'/repo'), b'', include=[b'filepath:dir/z']
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
240 )
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
241 assert isinstance(m, matchmod.includematcher)
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
242 self.assertTrue(m.visitdir(b''))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
243 self.assertTrue(m.visitdir(b'dir'))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
244 self.assertFalse(m.visitdir(b'folder'))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
245 self.assertFalse(m.visitdir(b'dir/subdir'))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
246 self.assertFalse(m.visitdir(b'dir/subdir/x'))
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
247
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
248 def testVisitchildrensetFilepath(self):
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
249 m = matchmod.match(
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
250 util.localpath(b'/repo'), b'', include=[b'filepath:dir/z']
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
251 )
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
252 assert isinstance(m, matchmod.includematcher)
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
253 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
254 self.assertEqual(m.visitchildrenset(b'folder'), set())
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
255 self.assertEqual(m.visitchildrenset(b'dir'), {b'z'})
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
256 self.assertEqual(m.visitchildrenset(b'dir/subdir'), set())
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
257 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
1c31b343e514 match: add `filepath:` pattern to match an exact filepath relative to the root
Raphaël Gomès <rgomes@octobus.net>
parents: 48875
diff changeset
258
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
259
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
260 class ExactMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
261 def testVisitdir(self):
41676
0531dff73d0b match: delete unused root and cwd arguments from {always,never,exact}() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41675
diff changeset
262 m = matchmod.exact(files=[b'dir/subdir/foo.txt'])
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
263 assert isinstance(m, matchmod.exactmatcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
264 self.assertTrue(m.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
265 self.assertTrue(m.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
266 self.assertTrue(m.visitdir(b'dir/subdir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
267 self.assertFalse(m.visitdir(b'dir/subdir/foo.txt'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
268 self.assertFalse(m.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
269 self.assertFalse(m.visitdir(b'dir/subdir/x'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
270 self.assertFalse(m.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
271
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
272 def testVisitchildrenset(self):
41676
0531dff73d0b match: delete unused root and cwd arguments from {always,never,exact}() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41675
diff changeset
273 m = matchmod.exact(files=[b'dir/subdir/foo.txt'])
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
274 assert isinstance(m, matchmod.exactmatcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
275 self.assertEqual(m.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
276 self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'})
39261
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
277 self.assertEqual(m.visitchildrenset(b'dir/subdir'), {b'foo.txt'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
278 self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
279 self.assertEqual(m.visitchildrenset(b'dir/subdir/foo.txt'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
280 self.assertEqual(m.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
281
39261
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
282 def testVisitchildrensetFilesAndDirs(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
283 m = matchmod.exact(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
284 files=[
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
285 b'rootfile.txt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
286 b'a/file1.txt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
287 b'a/b/file2.txt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
288 # no file in a/b/c
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
289 b'a/b/c/d/file4.txt',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
290 ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
291 )
39261
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
292 assert isinstance(m, matchmod.exactmatcher)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
293 self.assertEqual(m.visitchildrenset(b''), {b'a', b'rootfile.txt'})
39261
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
294 self.assertEqual(m.visitchildrenset(b'a'), {b'b', b'file1.txt'})
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
295 self.assertEqual(m.visitchildrenset(b'a/b'), {b'c', b'file2.txt'})
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
296 self.assertEqual(m.visitchildrenset(b'a/b/c'), {b'd'})
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
297 self.assertEqual(m.visitchildrenset(b'a/b/c/d'), {b'file4.txt'})
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
298 self.assertEqual(m.visitchildrenset(b'a/b/c/d/e'), set())
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
299 self.assertEqual(m.visitchildrenset(b'folder'), set())
c9a3f7f5c023 match: make exactmatcher.visitchildrenset return file children as well
Kyle Lippincott <spectral@google.com>
parents: 38963
diff changeset
300
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
301
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
302 class DifferenceMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
303 def testVisitdirM2always(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
304 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
305 m2 = matchmod.alwaysmatcher()
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
306 dm = matchmod.differencematcher(m1, m2)
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
307 # dm should be equivalent to a nevermatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
308 self.assertFalse(dm.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
309 self.assertFalse(dm.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
310 self.assertFalse(dm.visitdir(b'dir/subdir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
311 self.assertFalse(dm.visitdir(b'dir/subdir/z'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
312 self.assertFalse(dm.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
313 self.assertFalse(dm.visitdir(b'dir/subdir/x'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
314 self.assertFalse(dm.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
315
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
316 def testVisitchildrensetM2always(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
317 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
318 m2 = matchmod.alwaysmatcher()
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
319 dm = matchmod.differencematcher(m1, m2)
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
320 # dm should be equivalent to a nevermatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
321 self.assertEqual(dm.visitchildrenset(b''), set())
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
322 self.assertEqual(dm.visitchildrenset(b'dir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
323 self.assertEqual(dm.visitchildrenset(b'dir/subdir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
324 self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
325 self.assertEqual(dm.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
326 self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
327 self.assertEqual(dm.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
328
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
329 def testVisitdirM2never(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
330 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
331 m2 = matchmod.nevermatcher()
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
332 dm = matchmod.differencematcher(m1, m2)
41528
b7a0efb3c370 match: teach diffmatcher.visitdir() to return 'all' if possible
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 39261
diff changeset
333 # dm should be equivalent to a alwaysmatcher.
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
334 #
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
335 # We're testing Equal-to-True instead of just 'assertTrue' since
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
336 # assertTrue does NOT verify that it's a bool, just that it's truthy.
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
337 # While we may want to eventually make these return 'all', they should
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
338 # not currently do so.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
339 self.assertEqual(dm.visitdir(b''), b'all')
41530
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
340 self.assertEqual(dm.visitdir(b'dir'), b'all')
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
341 self.assertEqual(dm.visitdir(b'dir/subdir'), b'all')
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
342 self.assertEqual(dm.visitdir(b'dir/subdir/z'), b'all')
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
343 self.assertEqual(dm.visitdir(b'dir/foo'), b'all')
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
344 self.assertEqual(dm.visitdir(b'dir/subdir/x'), b'all')
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
345 self.assertEqual(dm.visitdir(b'folder'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
346
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
347 def testVisitchildrensetM2never(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
348 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
349 m2 = matchmod.nevermatcher()
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
350 dm = matchmod.differencematcher(m1, m2)
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
351 # dm should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
352 self.assertEqual(dm.visitchildrenset(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
353 self.assertEqual(dm.visitchildrenset(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
354 self.assertEqual(dm.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
355 self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
356 self.assertEqual(dm.visitchildrenset(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
357 self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
358 self.assertEqual(dm.visitchildrenset(b'folder'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
359
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
360 def testVisitdirM2SubdirPrefix(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
361 m1 = matchmod.alwaysmatcher()
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
362 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
363 util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
364 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
365 dm = matchmod.differencematcher(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
366 self.assertEqual(dm.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
367 self.assertEqual(dm.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
368 self.assertFalse(dm.visitdir(b'dir/subdir'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
369 # OPT: We should probably return False for these; we don't because
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
370 # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
371 # an 'all' pattern, just True.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
372 self.assertEqual(dm.visitdir(b'dir/subdir/z'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
373 self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
41530
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
374 self.assertEqual(dm.visitdir(b'dir/foo'), b'all')
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
375 self.assertEqual(dm.visitdir(b'folder'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
376
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
377 def testVisitchildrensetM2SubdirPrefix(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
378 m1 = matchmod.alwaysmatcher()
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
379 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
380 util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
381 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
382 dm = matchmod.differencematcher(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
383 self.assertEqual(dm.visitchildrenset(b''), b'this')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
384 self.assertEqual(dm.visitchildrenset(b'dir'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
385 self.assertEqual(dm.visitchildrenset(b'dir/subdir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
386 self.assertEqual(dm.visitchildrenset(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
387 self.assertEqual(dm.visitchildrenset(b'folder'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
388 # OPT: We should probably return set() for these; we don't because
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
389 # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
390 # an 'all' pattern, just 'this'.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
391 self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
392 self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
393
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
394 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
395 # better (giving narrower results) than patternmatcher.
43375
c2c3ee8794dd tests: fix typo "includfe"
Martin von Zweigbergk <martinvonz@google.com>
parents: 43076
diff changeset
396 def testVisitdirIncludeInclude(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
397 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
398 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
399 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
400 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
401 util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
402 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
403 dm = matchmod.differencematcher(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
404 self.assertEqual(dm.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
405 self.assertEqual(dm.visitdir(b'dir'), True)
41530
4dd07bf84608 tests: fix test-match.py on Python3
Augie Fackler <augie@google.com>
parents: 41528
diff changeset
406 self.assertEqual(dm.visitdir(b'dir/subdir'), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
407 self.assertFalse(dm.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
408 self.assertFalse(dm.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
409 # OPT: We should probably return False for these; we don't because
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
410 # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
411 # an 'all' pattern, just True.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
412 self.assertEqual(dm.visitdir(b'dir/subdir/z'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
413 self.assertEqual(dm.visitdir(b'dir/subdir/x'), True)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
414
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
415 def testVisitchildrensetIncludeInclude(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
416 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
417 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
418 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
419 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
420 util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
421 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
422 dm = matchmod.differencematcher(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
423 self.assertEqual(dm.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
424 self.assertEqual(dm.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
425 self.assertEqual(dm.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
426 self.assertEqual(dm.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
427 self.assertEqual(dm.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
428 # OPT: We should probably return set() for these; we don't because
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
429 # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
430 # an 'all' pattern, just 'this'.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
431 self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
432 self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
433
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
434
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
435 class IntersectionMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
436 def testVisitdirM2always(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
437 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
438 m2 = matchmod.alwaysmatcher()
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
439 im = matchmod.intersectmatchers(m1, m2)
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
440 # im should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
441 self.assertEqual(im.visitdir(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
442 self.assertEqual(im.visitdir(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
443 self.assertEqual(im.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
444 self.assertEqual(im.visitdir(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
445 self.assertEqual(im.visitdir(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
446 self.assertEqual(im.visitdir(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
447 self.assertEqual(im.visitdir(b'folder'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
448
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
449 def testVisitchildrensetM2always(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
450 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
451 m2 = matchmod.alwaysmatcher()
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
452 im = matchmod.intersectmatchers(m1, m2)
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
453 # im should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
454 self.assertEqual(im.visitchildrenset(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
455 self.assertEqual(im.visitchildrenset(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
456 self.assertEqual(im.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
457 self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
458 self.assertEqual(im.visitchildrenset(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
459 self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
460 self.assertEqual(im.visitchildrenset(b'folder'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
461
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
462 def testVisitdirM2never(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
463 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
464 m2 = matchmod.nevermatcher()
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
465 im = matchmod.intersectmatchers(m1, m2)
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
466 # im should be equivalent to a nevermatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
467 self.assertFalse(im.visitdir(b''))
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
468 self.assertFalse(im.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
469 self.assertFalse(im.visitdir(b'dir/subdir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
470 self.assertFalse(im.visitdir(b'dir/subdir/z'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
471 self.assertFalse(im.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
472 self.assertFalse(im.visitdir(b'dir/subdir/x'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
473 self.assertFalse(im.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
474
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
475 def testVisitchildrensetM2never(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
476 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
477 m2 = matchmod.nevermatcher()
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
478 im = matchmod.intersectmatchers(m1, m2)
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
479 # im should be equivalent to a nevermqtcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
480 self.assertEqual(im.visitchildrenset(b''), set())
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
481 self.assertEqual(im.visitchildrenset(b'dir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
482 self.assertEqual(im.visitchildrenset(b'dir/subdir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
483 self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
484 self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
485 self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
486 self.assertEqual(im.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
487
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
488 def testVisitdirM2SubdirPrefix(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
489 m1 = matchmod.alwaysmatcher()
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
490 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
491 util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
492 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
493 im = matchmod.intersectmatchers(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
494 self.assertEqual(im.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
495 self.assertEqual(im.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
496 self.assertEqual(im.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
497 self.assertFalse(im.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
498 self.assertFalse(im.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
499 # OPT: We should probably return 'all' for these; we don't because
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
500 # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
501 # an 'all' pattern, just True.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
502 self.assertEqual(im.visitdir(b'dir/subdir/z'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
503 self.assertEqual(im.visitdir(b'dir/subdir/x'), True)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
504
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
505 def testVisitchildrensetM2SubdirPrefix(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
506 m1 = matchmod.alwaysmatcher()
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
507 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
508 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
509 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
510 im = matchmod.intersectmatchers(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
511 self.assertEqual(im.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
512 self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
513 self.assertEqual(im.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
514 self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
515 self.assertEqual(im.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
516 # OPT: We should probably return 'all' for these
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
517 self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
518 self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
519
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
520 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
521 # better (giving narrower results) than patternmatcher.
43375
c2c3ee8794dd tests: fix typo "includfe"
Martin von Zweigbergk <martinvonz@google.com>
parents: 43076
diff changeset
522 def testVisitdirIncludeInclude(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
523 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
524 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
525 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
526 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
527 util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
528 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
529 im = matchmod.intersectmatchers(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
530 self.assertEqual(im.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
531 self.assertEqual(im.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
532 self.assertFalse(im.visitdir(b'dir/subdir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
533 self.assertFalse(im.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
534 self.assertFalse(im.visitdir(b'folder'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
535 self.assertFalse(im.visitdir(b'dir/subdir/z'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
536 self.assertFalse(im.visitdir(b'dir/subdir/x'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
537
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
538 def testVisitchildrensetIncludeInclude(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
539 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
540 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
541 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
542 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
543 util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
544 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
545 im = matchmod.intersectmatchers(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
546 self.assertEqual(im.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
547 self.assertEqual(im.visitchildrenset(b'dir'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
548 self.assertEqual(im.visitchildrenset(b'dir/subdir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
549 self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
550 self.assertEqual(im.visitchildrenset(b'folder'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
551 self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
552 self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
553
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
554 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
555 # better (giving narrower results) than patternmatcher.
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
556 def testVisitdirIncludeInclude2(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
557 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
558 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
559 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
560 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
561 util.localpath(b'/repo'), b'', include=[b'path:folder']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
562 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
563 im = matchmod.intersectmatchers(m1, m2)
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
564 # FIXME: is True correct here?
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
565 self.assertEqual(im.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
566 self.assertFalse(im.visitdir(b'dir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
567 self.assertFalse(im.visitdir(b'dir/subdir'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
568 self.assertFalse(im.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
569 self.assertFalse(im.visitdir(b'folder'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
570 self.assertFalse(im.visitdir(b'dir/subdir/z'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
571 self.assertFalse(im.visitdir(b'dir/subdir/x'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
572
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
573 def testVisitchildrensetIncludeInclude2(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
574 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
575 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
576 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
577 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
578 util.localpath(b'/repo'), b'', include=[b'path:folder']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
579 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
580 im = matchmod.intersectmatchers(m1, m2)
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
581 # FIXME: is set() correct here?
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
582 self.assertEqual(im.visitchildrenset(b''), set())
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
583 self.assertEqual(im.visitchildrenset(b'dir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
584 self.assertEqual(im.visitchildrenset(b'dir/subdir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
585 self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
586 self.assertEqual(im.visitchildrenset(b'folder'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
587 self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
588 self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
589
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
590 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
591 # better (giving narrower results) than patternmatcher.
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
592 def testVisitdirIncludeInclude3(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
593 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
594 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
595 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
596 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
597 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
598 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
599 im = matchmod.intersectmatchers(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
600 self.assertEqual(im.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
601 self.assertEqual(im.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
602 self.assertEqual(im.visitdir(b'dir/subdir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
603 self.assertFalse(im.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
604 self.assertFalse(im.visitdir(b'folder'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
605 self.assertFalse(im.visitdir(b'dir/subdir/z'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
606 # OPT: this should probably be 'all' not True.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
607 self.assertEqual(im.visitdir(b'dir/subdir/x'), True)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
608
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
609 def testVisitchildrensetIncludeInclude3(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
610 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
611 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
612 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
613 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
614 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
615 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
616 im = matchmod.intersectmatchers(m1, m2)
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
617 self.assertEqual(im.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
618 self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
619 self.assertEqual(im.visitchildrenset(b'dir/subdir'), {b'x'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
620 self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
621 self.assertEqual(im.visitchildrenset(b'folder'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
622 self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
623 # OPT: this should probably be 'all' not 'this'.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
624 self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
625
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
626 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
627 # better (giving narrower results) than patternmatcher.
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
628 def testVisitdirIncludeInclude4(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
629 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
630 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
631 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
632 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
633 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
634 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
635 im = matchmod.intersectmatchers(m1, m2)
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
636 # OPT: these next three could probably be False as well.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
637 self.assertEqual(im.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
638 self.assertEqual(im.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
639 self.assertEqual(im.visitdir(b'dir/subdir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
640 self.assertFalse(im.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
641 self.assertFalse(im.visitdir(b'folder'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
642 self.assertFalse(im.visitdir(b'dir/subdir/z'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
643 self.assertFalse(im.visitdir(b'dir/subdir/x'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
644
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
645 def testVisitchildrensetIncludeInclude4(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
646 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
647 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
648 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
649 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
650 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
651 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
652 im = matchmod.intersectmatchers(m1, m2)
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
653 # OPT: these next two could probably be set() as well.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
654 self.assertEqual(im.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
655 self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
656 self.assertEqual(im.visitchildrenset(b'dir/subdir'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
657 self.assertEqual(im.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
658 self.assertEqual(im.visitchildrenset(b'folder'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
659 self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
660 self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
661
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
662
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
663 class UnionMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
664 def testVisitdirM2always(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
665 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
666 m2 = matchmod.alwaysmatcher()
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
667 um = matchmod.unionmatcher([m1, m2])
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
668 # um should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
669 self.assertEqual(um.visitdir(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
670 self.assertEqual(um.visitdir(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
671 self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
672 self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
673 self.assertEqual(um.visitdir(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
674 self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
675 self.assertEqual(um.visitdir(b'folder'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
676
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
677 def testVisitchildrensetM2always(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
678 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
679 m2 = matchmod.alwaysmatcher()
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
680 um = matchmod.unionmatcher([m1, m2])
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
681 # um should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
682 self.assertEqual(um.visitchildrenset(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
683 self.assertEqual(um.visitchildrenset(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
684 self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
685 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
686 self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
687 self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
688 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
689
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
690 def testVisitdirM1never(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
691 m1 = matchmod.nevermatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
692 m2 = matchmod.alwaysmatcher()
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
693 um = matchmod.unionmatcher([m1, m2])
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
694 # um should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
695 self.assertEqual(um.visitdir(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
696 self.assertEqual(um.visitdir(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
697 self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
698 self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
699 self.assertEqual(um.visitdir(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
700 self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
701 self.assertEqual(um.visitdir(b'folder'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
702
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
703 def testVisitchildrensetM1never(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
704 m1 = matchmod.nevermatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
705 m2 = matchmod.alwaysmatcher()
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
706 um = matchmod.unionmatcher([m1, m2])
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
707 # um should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
708 self.assertEqual(um.visitchildrenset(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
709 self.assertEqual(um.visitchildrenset(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
710 self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
711 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
712 self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
713 self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
714 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
715
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
716 def testVisitdirM2never(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
717 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
718 m2 = matchmod.nevermatcher()
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
719 um = matchmod.unionmatcher([m1, m2])
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
720 # um should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
721 self.assertEqual(um.visitdir(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
722 self.assertEqual(um.visitdir(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
723 self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
724 self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
725 self.assertEqual(um.visitdir(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
726 self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
727 self.assertEqual(um.visitdir(b'folder'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
728
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
729 def testVisitchildrensetM2never(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
730 m1 = matchmod.alwaysmatcher()
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
731 m2 = matchmod.nevermatcher()
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
732 um = matchmod.unionmatcher([m1, m2])
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
733 # um should be equivalent to a alwaysmatcher.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
734 self.assertEqual(um.visitchildrenset(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
735 self.assertEqual(um.visitchildrenset(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
736 self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
737 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
738 self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
739 self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
740 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
741
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
742 def testVisitdirM2SubdirPrefix(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
743 m1 = matchmod.alwaysmatcher()
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
744 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
745 util.localpath(b'/repo'), b'', patterns=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
746 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
747 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
748 self.assertEqual(um.visitdir(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
749 self.assertEqual(um.visitdir(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
750 self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
751 self.assertEqual(um.visitdir(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
752 self.assertEqual(um.visitdir(b'folder'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
753 self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
754 self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
755
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
756 def testVisitchildrensetM2SubdirPrefix(self):
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
757 m1 = matchmod.alwaysmatcher()
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
758 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
759 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
760 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
761 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
762 self.assertEqual(um.visitchildrenset(b''), b'all')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
763 self.assertEqual(um.visitchildrenset(b'dir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
764 self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
765 self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
766 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
767 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
768 self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
769
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
770 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
771 # better (giving narrower results) than patternmatcher.
43375
c2c3ee8794dd tests: fix typo "includfe"
Martin von Zweigbergk <martinvonz@google.com>
parents: 43076
diff changeset
772 def testVisitdirIncludeInclude(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
773 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
774 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
775 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
776 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
777 util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
778 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
779 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
780 self.assertEqual(um.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
781 self.assertEqual(um.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
782 self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
783 self.assertFalse(um.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
784 self.assertFalse(um.visitdir(b'folder'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
785 # OPT: These two should probably be 'all' not True.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
786 self.assertEqual(um.visitdir(b'dir/subdir/z'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
787 self.assertEqual(um.visitdir(b'dir/subdir/x'), True)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
788
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
789 def testVisitchildrensetIncludeInclude(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
790 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
791 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
792 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
793 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
794 util.localpath(b'/repo'), b'', include=[b'rootfilesin:dir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
795 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
796 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
797 self.assertEqual(um.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
798 self.assertEqual(um.visitchildrenset(b'dir'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
799 self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
800 self.assertEqual(um.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
801 self.assertEqual(um.visitchildrenset(b'folder'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
802 # OPT: These next two could be 'all' instead of 'this'.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
803 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
804 self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
805
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
806 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
807 # better (giving narrower results) than patternmatcher.
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
808 def testVisitdirIncludeInclude2(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
809 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
810 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
811 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
812 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
813 util.localpath(b'/repo'), b'', include=[b'path:folder']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
814 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
815 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
816 self.assertEqual(um.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
817 self.assertEqual(um.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
818 self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
819 self.assertFalse(um.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
820 self.assertEqual(um.visitdir(b'folder'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
821 # OPT: These should probably be 'all' not True.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
822 self.assertEqual(um.visitdir(b'dir/subdir/z'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
823 self.assertEqual(um.visitdir(b'dir/subdir/x'), True)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
824
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
825 def testVisitchildrensetIncludeInclude2(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
826 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
827 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
828 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
829 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
830 util.localpath(b'/repo'), b'', include=[b'path:folder']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
831 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
832 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
833 self.assertEqual(um.visitchildrenset(b''), {b'folder', b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
834 self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
835 self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
836 self.assertEqual(um.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
837 self.assertEqual(um.visitchildrenset(b'folder'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
838 # OPT: These next two could be 'all' instead of 'this'.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
839 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
840 self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
841
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
842 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
843 # better (giving narrower results) than patternmatcher.
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
844 def testVisitdirIncludeInclude3(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
845 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
846 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
847 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
848 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
849 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
850 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
851 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
852 self.assertEqual(um.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
853 self.assertEqual(um.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
854 self.assertEqual(um.visitdir(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
855 self.assertFalse(um.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
856 self.assertFalse(um.visitdir(b'folder'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
857 self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
858 # OPT: this should probably be 'all' not True.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
859 self.assertEqual(um.visitdir(b'dir/subdir/z'), True)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
860
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
861 def testVisitchildrensetIncludeInclude3(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
862 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
863 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
864 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
865 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
866 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
867 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
868 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
869 self.assertEqual(um.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
870 self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
871 self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
872 self.assertEqual(um.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
873 self.assertEqual(um.visitchildrenset(b'folder'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
874 self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
875 # OPT: this should probably be 'all' not 'this'.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
876 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
877
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
878 # We're using includematcher instead of patterns because it behaves slightly
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
879 # better (giving narrower results) than patternmatcher.
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
880 def testVisitdirIncludeInclude4(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
881 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
882 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
883 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
884 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
885 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
886 )
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
887 um = matchmod.unionmatcher([m1, m2])
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
888 # OPT: these next three could probably be False as well.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
889 self.assertEqual(um.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
890 self.assertEqual(um.visitdir(b'dir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
891 self.assertEqual(um.visitdir(b'dir/subdir'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
892 self.assertFalse(um.visitdir(b'dir/foo'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
893 self.assertFalse(um.visitdir(b'folder'))
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
894 self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
895 self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
896
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
897 def testVisitchildrensetIncludeInclude4(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
898 m1 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
899 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/x']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
900 )
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
901 m2 = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
902 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir/z']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
903 )
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
904 um = matchmod.unionmatcher([m1, m2])
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
905 self.assertEqual(um.visitchildrenset(b''), {b'dir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
906 self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
907 self.assertEqual(um.visitchildrenset(b'dir/subdir'), {b'x', b'z'})
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
908 self.assertEqual(um.visitchildrenset(b'dir/foo'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
909 self.assertEqual(um.visitchildrenset(b'folder'), set())
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
910 self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
911 self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
912
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
913
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
914 class SubdirMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
915 def testVisitdir(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
916 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
917 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
918 )
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
919 sm = matchmod.subdirmatcher(b'dir', m)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
920
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
921 self.assertEqual(sm.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
922 self.assertEqual(sm.visitdir(b'subdir'), b'all')
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
923 # OPT: These next two should probably be 'all' not True.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
924 self.assertEqual(sm.visitdir(b'subdir/x'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
925 self.assertEqual(sm.visitdir(b'subdir/z'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
926 self.assertFalse(sm.visitdir(b'foo'))
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
927
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
928 def testVisitchildrenset(self):
43964
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
929 m = matchmod.match(
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
930 util.localpath(b'/repo'), b'', include=[b'path:dir/subdir']
8f67735344ae tests: convert the `root` arg of matchmod.match() to local path separators
Matt Harbison <matt_harbison@yahoo.com>
parents: 43949
diff changeset
931 )
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
932 sm = matchmod.subdirmatcher(b'dir', m)
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
933
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
934 self.assertEqual(sm.visitchildrenset(b''), {b'subdir'})
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
935 self.assertEqual(sm.visitchildrenset(b'subdir'), b'all')
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
936 # OPT: These next two should probably be 'all' not 'this'.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
937 self.assertEqual(sm.visitchildrenset(b'subdir/x'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
938 self.assertEqual(sm.visitchildrenset(b'subdir/z'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
939 self.assertEqual(sm.visitchildrenset(b'foo'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
940
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
941
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
942 class PrefixdirMatcherTests(unittest.TestCase):
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
943 def testVisitdir(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
944 m = matchmod.match(
43949
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
945 util.localpath(b'/root/d'),
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
946 b'e/f',
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
947 [b'../a.txt', b'b.txt'],
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
948 auditor=noop_auditor,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
949 )
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
950 pm = matchmod.prefixdirmatcher(b'd', m)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
951
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
952 # `m` elides 'd' because it's part of the root, and the rest of the
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
953 # patterns are relative.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
954 self.assertEqual(bool(m(b'a.txt')), False)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
955 self.assertEqual(bool(m(b'b.txt')), False)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
956 self.assertEqual(bool(m(b'e/a.txt')), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
957 self.assertEqual(bool(m(b'e/b.txt')), False)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
958 self.assertEqual(bool(m(b'e/f/b.txt')), True)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
959
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
960 # The prefix matcher re-adds 'd' to the paths, so they need to be
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
961 # specified when using the prefixdirmatcher.
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
962 self.assertEqual(bool(pm(b'a.txt')), False)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
963 self.assertEqual(bool(pm(b'b.txt')), False)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
964 self.assertEqual(bool(pm(b'd/e/a.txt')), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
965 self.assertEqual(bool(pm(b'd/e/b.txt')), False)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
966 self.assertEqual(bool(pm(b'd/e/f/b.txt')), True)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
967
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
968 self.assertEqual(m.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
969 self.assertEqual(m.visitdir(b'e'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
970 self.assertEqual(m.visitdir(b'e/f'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
971 self.assertEqual(m.visitdir(b'e/f/g'), False)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
972
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
973 self.assertEqual(pm.visitdir(b''), True)
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
974 self.assertEqual(pm.visitdir(b'd'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
975 self.assertEqual(pm.visitdir(b'd/e'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
976 self.assertEqual(pm.visitdir(b'd/e/f'), True)
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
977 self.assertEqual(pm.visitdir(b'd/e/f/g'), False)
38953
987d3a4b989f match: add tests for visitdir functionality
spectral <spectral@google.com>
parents: 33582
diff changeset
978
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
979 def testVisitchildrenset(self):
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
980 m = matchmod.match(
43949
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
981 util.localpath(b'/root/d'),
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
982 b'e/f',
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
983 [b'../a.txt', b'b.txt'],
8b1a9ba375e5 match: make sure `root` argument is always an absolute path (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 43375
diff changeset
984 auditor=noop_auditor,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
985 )
41675
ddbebce94665 match: delete unused root and cwd arguments to constructors (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41621
diff changeset
986 pm = matchmod.prefixdirmatcher(b'd', m)
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
987
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
988 # OPT: visitchildrenset could possibly return {'e'} and {'f'} for these
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
989 # next two, respectively; patternmatcher does not have this
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
990 # optimization.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
991 self.assertEqual(m.visitchildrenset(b''), b'this')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
992 self.assertEqual(m.visitchildrenset(b'e'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
993 self.assertEqual(m.visitchildrenset(b'e/f'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
994 self.assertEqual(m.visitchildrenset(b'e/f/g'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
995
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
996 # OPT: visitchildrenset could possibly return {'d'}, {'e'}, and {'f'}
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
997 # for these next three, respectively; patternmatcher does not have this
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
998 # optimization.
42341
27d6956d386b match: use '' instead of '.' for root directory (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 41676
diff changeset
999 self.assertEqual(pm.visitchildrenset(b''), b'this')
38963
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
1000 self.assertEqual(pm.visitchildrenset(b'd'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
1001 self.assertEqual(pm.visitchildrenset(b'd/e'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
1002 self.assertEqual(pm.visitchildrenset(b'd/e/f'), b'this')
467b5c1df72d tests: make all the string constants in test-match.py be bytes
Augie Fackler <augie@google.com>
parents: 38958
diff changeset
1003 self.assertEqual(pm.visitchildrenset(b'd/e/f/g'), set())
38955
081cc9a95b65 match: add visitchildrenset complement to visitdir
spectral <spectral@google.com>
parents: 38953
diff changeset
1004
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42346
diff changeset
1005
33582
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
1006 if __name__ == '__main__':
44bc181b9835 match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff changeset
1007 silenttestrunner.main(__name__)