Show More
This diff has been collapsed as it changes many lines, (1004 lines changed) Show them Hide them | |||
@@ -12,230 +12,232 b' from mercurial import (' | |||
|
12 | 12 | class BaseMatcherTests(unittest.TestCase): |
|
13 | 13 | |
|
14 | 14 | def testVisitdir(self): |
|
15 | m = matchmod.basematcher('', '') | |
|
16 | self.assertTrue(m.visitdir('.')) | |
|
17 | self.assertTrue(m.visitdir('dir')) | |
|
15 | m = matchmod.basematcher(b'', b'') | |
|
16 | self.assertTrue(m.visitdir(b'.')) | |
|
17 | self.assertTrue(m.visitdir(b'dir')) | |
|
18 | 18 | |
|
19 | 19 | def testVisitchildrenset(self): |
|
20 | m = matchmod.basematcher('', '') | |
|
21 | self.assertEqual(m.visitchildrenset('.'), 'this') | |
|
22 | self.assertEqual(m.visitchildrenset('dir'), 'this') | |
|
20 | m = matchmod.basematcher(b'', b'') | |
|
21 | self.assertEqual(m.visitchildrenset(b'.'), b'this') | |
|
22 | self.assertEqual(m.visitchildrenset(b'dir'), b'this') | |
|
23 | 23 | |
|
24 | 24 | class AlwaysMatcherTests(unittest.TestCase): |
|
25 | 25 | |
|
26 | 26 | def testVisitdir(self): |
|
27 | m = matchmod.alwaysmatcher('', '') | |
|
28 | self.assertEqual(m.visitdir('.'), 'all') | |
|
29 | self.assertEqual(m.visitdir('dir'), 'all') | |
|
27 | m = matchmod.alwaysmatcher(b'', b'') | |
|
28 | self.assertEqual(m.visitdir(b'.'), b'all') | |
|
29 | self.assertEqual(m.visitdir(b'dir'), b'all') | |
|
30 | 30 | |
|
31 | 31 | def testVisitchildrenset(self): |
|
32 | m = matchmod.alwaysmatcher('', '') | |
|
33 | self.assertEqual(m.visitchildrenset('.'), 'all') | |
|
34 | self.assertEqual(m.visitchildrenset('dir'), 'all') | |
|
32 | m = matchmod.alwaysmatcher(b'', b'') | |
|
33 | self.assertEqual(m.visitchildrenset(b'.'), b'all') | |
|
34 | self.assertEqual(m.visitchildrenset(b'dir'), b'all') | |
|
35 | 35 | |
|
36 | 36 | class NeverMatcherTests(unittest.TestCase): |
|
37 | 37 | |
|
38 | 38 | def testVisitdir(self): |
|
39 | m = matchmod.nevermatcher('', '') | |
|
40 | self.assertFalse(m.visitdir('.')) | |
|
41 | self.assertFalse(m.visitdir('dir')) | |
|
39 | m = matchmod.nevermatcher(b'', b'') | |
|
40 | self.assertFalse(m.visitdir(b'.')) | |
|
41 | self.assertFalse(m.visitdir(b'dir')) | |
|
42 | 42 | |
|
43 | 43 | def testVisitchildrenset(self): |
|
44 | m = matchmod.nevermatcher('', '') | |
|
45 | self.assertEqual(m.visitchildrenset('.'), set()) | |
|
46 | self.assertEqual(m.visitchildrenset('dir'), set()) | |
|
44 | m = matchmod.nevermatcher(b'', b'') | |
|
45 | self.assertEqual(m.visitchildrenset(b'.'), set()) | |
|
46 | self.assertEqual(m.visitchildrenset(b'dir'), set()) | |
|
47 | 47 | |
|
48 | 48 | class PredicateMatcherTests(unittest.TestCase): |
|
49 | 49 | # predicatematcher does not currently define either of these methods, so |
|
50 | 50 | # this is equivalent to BaseMatcherTests. |
|
51 | 51 | |
|
52 | 52 | def testVisitdir(self): |
|
53 | m = matchmod.predicatematcher('', '', lambda *a: False) | |
|
54 | self.assertTrue(m.visitdir('.')) | |
|
55 | self.assertTrue(m.visitdir('dir')) | |
|
53 | m = matchmod.predicatematcher(b'', b'', lambda *a: False) | |
|
54 | self.assertTrue(m.visitdir(b'.')) | |
|
55 | self.assertTrue(m.visitdir(b'dir')) | |
|
56 | 56 | |
|
57 | 57 | def testVisitchildrenset(self): |
|
58 | m = matchmod.predicatematcher('', '', lambda *a: False) | |
|
59 | self.assertEqual(m.visitchildrenset('.'), 'this') | |
|
60 | self.assertEqual(m.visitchildrenset('dir'), 'this') | |
|
58 | m = matchmod.predicatematcher(b'', b'', lambda *a: False) | |
|
59 | self.assertEqual(m.visitchildrenset(b'.'), b'this') | |
|
60 | self.assertEqual(m.visitchildrenset(b'dir'), b'this') | |
|
61 | 61 | |
|
62 | 62 | class PatternMatcherTests(unittest.TestCase): |
|
63 | 63 | |
|
64 | 64 | def testVisitdirPrefix(self): |
|
65 | m = matchmod.match('x', '', patterns=['path:dir/subdir']) | |
|
65 | m = matchmod.match(b'x', b'', patterns=[b'path:dir/subdir']) | |
|
66 | 66 | assert isinstance(m, matchmod.patternmatcher) |
|
67 | self.assertTrue(m.visitdir('.')) | |
|
68 | self.assertTrue(m.visitdir('dir')) | |
|
69 | self.assertEqual(m.visitdir('dir/subdir'), 'all') | |
|
67 | self.assertTrue(m.visitdir(b'.')) | |
|
68 | self.assertTrue(m.visitdir(b'dir')) | |
|
69 | self.assertEqual(m.visitdir(b'dir/subdir'), b'all') | |
|
70 | 70 | # OPT: This should probably be 'all' if its parent is? |
|
71 | self.assertTrue(m.visitdir('dir/subdir/x')) | |
|
72 | self.assertFalse(m.visitdir('folder')) | |
|
71 | self.assertTrue(m.visitdir(b'dir/subdir/x')) | |
|
72 | self.assertFalse(m.visitdir(b'folder')) | |
|
73 | 73 | |
|
74 | 74 | def testVisitchildrensetPrefix(self): |
|
75 | m = matchmod.match('x', '', patterns=['path:dir/subdir']) | |
|
75 | m = matchmod.match(b'x', b'', patterns=[b'path:dir/subdir']) | |
|
76 | 76 | assert isinstance(m, matchmod.patternmatcher) |
|
77 | self.assertEqual(m.visitchildrenset('.'), 'this') | |
|
78 | self.assertEqual(m.visitchildrenset('dir'), 'this') | |
|
79 | self.assertEqual(m.visitchildrenset('dir/subdir'), 'all') | |
|
77 | self.assertEqual(m.visitchildrenset(b'.'), b'this') | |
|
78 | self.assertEqual(m.visitchildrenset(b'dir'), b'this') | |
|
79 | self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'all') | |
|
80 | 80 | # OPT: This should probably be 'all' if its parent is? |
|
81 | self.assertEqual(m.visitchildrenset('dir/subdir/x'), 'this') | |
|
82 | self.assertEqual(m.visitchildrenset('folder'), set()) | |
|
81 | self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
82 | self.assertEqual(m.visitchildrenset(b'folder'), set()) | |
|
83 | 83 | |
|
84 | 84 | def testVisitdirRootfilesin(self): |
|
85 | m = matchmod.match('x', '', patterns=['rootfilesin:dir/subdir']) | |
|
85 | m = matchmod.match(b'x', b'', patterns=[b'rootfilesin:dir/subdir']) | |
|
86 | 86 | assert isinstance(m, matchmod.patternmatcher) |
|
87 | self.assertTrue(m.visitdir('.')) | |
|
88 | self.assertFalse(m.visitdir('dir/subdir/x')) | |
|
89 | self.assertFalse(m.visitdir('folder')) | |
|
87 | self.assertTrue(m.visitdir(b'.')) | |
|
88 | self.assertFalse(m.visitdir(b'dir/subdir/x')) | |
|
89 | self.assertFalse(m.visitdir(b'folder')) | |
|
90 | 90 | # FIXME: These should probably be True. |
|
91 | self.assertFalse(m.visitdir('dir')) | |
|
92 | self.assertFalse(m.visitdir('dir/subdir')) | |
|
91 | self.assertFalse(m.visitdir(b'dir')) | |
|
92 | self.assertFalse(m.visitdir(b'dir/subdir')) | |
|
93 | 93 | |
|
94 | 94 | def testVisitchildrensetRootfilesin(self): |
|
95 | m = matchmod.match('x', '', patterns=['rootfilesin:dir/subdir']) | |
|
95 | m = matchmod.match(b'x', b'', patterns=[b'rootfilesin:dir/subdir']) | |
|
96 | 96 | assert isinstance(m, matchmod.patternmatcher) |
|
97 | self.assertEqual(m.visitchildrenset('.'), 'this') | |
|
98 | self.assertEqual(m.visitchildrenset('dir/subdir/x'), set()) | |
|
99 | self.assertEqual(m.visitchildrenset('folder'), set()) | |
|
97 | self.assertEqual(m.visitchildrenset(b'.'), b'this') | |
|
98 | self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set()) | |
|
99 | self.assertEqual(m.visitchildrenset(b'folder'), set()) | |
|
100 | 100 | # FIXME: These should probably be {'subdir'} and 'this', respectively, |
|
101 | 101 | # or at least 'this' and 'this'. |
|
102 | self.assertEqual(m.visitchildrenset('dir'), set()) | |
|
103 | self.assertEqual(m.visitchildrenset('dir/subdir'), set()) | |
|
102 | self.assertEqual(m.visitchildrenset(b'dir'), set()) | |
|
103 | self.assertEqual(m.visitchildrenset(b'dir/subdir'), set()) | |
|
104 | 104 | |
|
105 | 105 | def testVisitdirGlob(self): |
|
106 | m = matchmod.match('x', '', patterns=['glob:dir/z*']) | |
|
106 | m = matchmod.match(b'x', b'', patterns=[b'glob:dir/z*']) | |
|
107 | 107 | assert isinstance(m, matchmod.patternmatcher) |
|
108 | self.assertTrue(m.visitdir('.')) | |
|
109 | self.assertTrue(m.visitdir('dir')) | |
|
110 | self.assertFalse(m.visitdir('folder')) | |
|
108 | self.assertTrue(m.visitdir(b'.')) | |
|
109 | self.assertTrue(m.visitdir(b'dir')) | |
|
110 | self.assertFalse(m.visitdir(b'folder')) | |
|
111 | 111 | # OPT: these should probably be False. |
|
112 | self.assertTrue(m.visitdir('dir/subdir')) | |
|
113 | self.assertTrue(m.visitdir('dir/subdir/x')) | |
|
112 | self.assertTrue(m.visitdir(b'dir/subdir')) | |
|
113 | self.assertTrue(m.visitdir(b'dir/subdir/x')) | |
|
114 | 114 | |
|
115 | 115 | def testVisitchildrensetGlob(self): |
|
116 | m = matchmod.match('x', '', patterns=['glob:dir/z*']) | |
|
116 | m = matchmod.match(b'x', b'', patterns=[b'glob:dir/z*']) | |
|
117 | 117 | assert isinstance(m, matchmod.patternmatcher) |
|
118 | self.assertEqual(m.visitchildrenset('.'), 'this') | |
|
119 | self.assertEqual(m.visitchildrenset('folder'), set()) | |
|
120 | self.assertEqual(m.visitchildrenset('dir'), 'this') | |
|
118 | self.assertEqual(m.visitchildrenset(b'.'), b'this') | |
|
119 | self.assertEqual(m.visitchildrenset(b'folder'), set()) | |
|
120 | self.assertEqual(m.visitchildrenset(b'dir'), b'this') | |
|
121 | 121 | # OPT: these should probably be set(). |
|
122 | self.assertEqual(m.visitchildrenset('dir/subdir'), 'this') | |
|
123 | self.assertEqual(m.visitchildrenset('dir/subdir/x'), 'this') | |
|
122 | self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this') | |
|
123 | self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
124 | 124 | |
|
125 | 125 | class IncludeMatcherTests(unittest.TestCase): |
|
126 | 126 | |
|
127 | 127 | def testVisitdirPrefix(self): |
|
128 | m = matchmod.match('x', '', include=['path:dir/subdir']) | |
|
128 | m = matchmod.match(b'x', b'', include=[b'path:dir/subdir']) | |
|
129 | 129 | assert isinstance(m, matchmod.includematcher) |
|
130 | self.assertTrue(m.visitdir('.')) | |
|
131 | self.assertTrue(m.visitdir('dir')) | |
|
132 | self.assertEqual(m.visitdir('dir/subdir'), 'all') | |
|
130 | self.assertTrue(m.visitdir(b'.')) | |
|
131 | self.assertTrue(m.visitdir(b'dir')) | |
|
132 | self.assertEqual(m.visitdir(b'dir/subdir'), b'all') | |
|
133 | 133 | # OPT: This should probably be 'all' if its parent is? |
|
134 | self.assertTrue(m.visitdir('dir/subdir/x')) | |
|
135 | self.assertFalse(m.visitdir('folder')) | |
|
134 | self.assertTrue(m.visitdir(b'dir/subdir/x')) | |
|
135 | self.assertFalse(m.visitdir(b'folder')) | |
|
136 | 136 | |
|
137 | 137 | def testVisitchildrensetPrefix(self): |
|
138 | m = matchmod.match('x', '', include=['path:dir/subdir']) | |
|
138 | m = matchmod.match(b'x', b'', include=[b'path:dir/subdir']) | |
|
139 | 139 | assert isinstance(m, matchmod.includematcher) |
|
140 | self.assertEqual(m.visitchildrenset('.'), {'dir'}) | |
|
141 | self.assertEqual(m.visitchildrenset('dir'), {'subdir'}) | |
|
142 | self.assertEqual(m.visitchildrenset('dir/subdir'), 'all') | |
|
140 | self.assertEqual(m.visitchildrenset(b'.'), {b'dir'}) | |
|
141 | self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'}) | |
|
142 | self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'all') | |
|
143 | 143 | # OPT: This should probably be 'all' if its parent is? |
|
144 | self.assertEqual(m.visitchildrenset('dir/subdir/x'), 'this') | |
|
145 | self.assertEqual(m.visitchildrenset('folder'), set()) | |
|
144 | self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
145 | self.assertEqual(m.visitchildrenset(b'folder'), set()) | |
|
146 | 146 | |
|
147 | 147 | def testVisitdirRootfilesin(self): |
|
148 | m = matchmod.match('x', '', include=['rootfilesin:dir/subdir']) | |
|
148 | m = matchmod.match(b'x', b'', include=[b'rootfilesin:dir/subdir']) | |
|
149 | 149 | assert isinstance(m, matchmod.includematcher) |
|
150 | self.assertTrue(m.visitdir('.')) | |
|
151 | self.assertTrue(m.visitdir('dir')) | |
|
152 | self.assertTrue(m.visitdir('dir/subdir')) | |
|
153 | self.assertFalse(m.visitdir('dir/subdir/x')) | |
|
154 | self.assertFalse(m.visitdir('folder')) | |
|
150 | self.assertTrue(m.visitdir(b'.')) | |
|
151 | self.assertTrue(m.visitdir(b'dir')) | |
|
152 | self.assertTrue(m.visitdir(b'dir/subdir')) | |
|
153 | self.assertFalse(m.visitdir(b'dir/subdir/x')) | |
|
154 | self.assertFalse(m.visitdir(b'folder')) | |
|
155 | 155 | |
|
156 | 156 | def testVisitchildrensetRootfilesin(self): |
|
157 | m = matchmod.match('x', '', include=['rootfilesin:dir/subdir']) | |
|
157 | m = matchmod.match(b'x', b'', include=[b'rootfilesin:dir/subdir']) | |
|
158 | 158 | assert isinstance(m, matchmod.includematcher) |
|
159 | self.assertEqual(m.visitchildrenset('.'), {'dir'}) | |
|
160 | self.assertEqual(m.visitchildrenset('dir'), {'subdir'}) | |
|
161 | self.assertEqual(m.visitchildrenset('dir/subdir'), 'this') | |
|
162 | self.assertEqual(m.visitchildrenset('dir/subdir/x'), set()) | |
|
163 | self.assertEqual(m.visitchildrenset('folder'), set()) | |
|
159 | self.assertEqual(m.visitchildrenset(b'.'), {b'dir'}) | |
|
160 | self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'}) | |
|
161 | self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this') | |
|
162 | self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set()) | |
|
163 | self.assertEqual(m.visitchildrenset(b'folder'), set()) | |
|
164 | 164 | |
|
165 | 165 | def testVisitdirGlob(self): |
|
166 | m = matchmod.match('x', '', include=['glob:dir/z*']) | |
|
166 | m = matchmod.match(b'x', b'', include=[b'glob:dir/z*']) | |
|
167 | 167 | assert isinstance(m, matchmod.includematcher) |
|
168 | self.assertTrue(m.visitdir('.')) | |
|
169 | self.assertTrue(m.visitdir('dir')) | |
|
170 | self.assertFalse(m.visitdir('folder')) | |
|
168 | self.assertTrue(m.visitdir(b'.')) | |
|
169 | self.assertTrue(m.visitdir(b'dir')) | |
|
170 | self.assertFalse(m.visitdir(b'folder')) | |
|
171 | 171 | # OPT: these should probably be False. |
|
172 | self.assertTrue(m.visitdir('dir/subdir')) | |
|
173 | self.assertTrue(m.visitdir('dir/subdir/x')) | |
|
172 | self.assertTrue(m.visitdir(b'dir/subdir')) | |
|
173 | self.assertTrue(m.visitdir(b'dir/subdir/x')) | |
|
174 | 174 | |
|
175 | 175 | def testVisitchildrensetGlob(self): |
|
176 | m = matchmod.match('x', '', include=['glob:dir/z*']) | |
|
176 | m = matchmod.match(b'x', b'', include=[b'glob:dir/z*']) | |
|
177 | 177 | assert isinstance(m, matchmod.includematcher) |
|
178 | self.assertEqual(m.visitchildrenset('.'), {'dir'}) | |
|
179 | self.assertEqual(m.visitchildrenset('folder'), set()) | |
|
180 | self.assertEqual(m.visitchildrenset('dir'), 'this') | |
|
178 | self.assertEqual(m.visitchildrenset(b'.'), {b'dir'}) | |
|
179 | self.assertEqual(m.visitchildrenset(b'folder'), set()) | |
|
180 | self.assertEqual(m.visitchildrenset(b'dir'), b'this') | |
|
181 | 181 | # OPT: these should probably be set(). |
|
182 | self.assertEqual(m.visitchildrenset('dir/subdir'), 'this') | |
|
183 | self.assertEqual(m.visitchildrenset('dir/subdir/x'), 'this') | |
|
182 | self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this') | |
|
183 | self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
184 | 184 | |
|
185 | 185 | class ExactMatcherTests(unittest.TestCase): |
|
186 | 186 | |
|
187 | 187 | def testVisitdir(self): |
|
188 |
m = matchmod.match('x', '', patterns=['dir/subdir/foo.txt'], |
|
|
188 | m = matchmod.match(b'x', b'', patterns=[b'dir/subdir/foo.txt'], | |
|
189 | exact=True) | |
|
189 | 190 | assert isinstance(m, matchmod.exactmatcher) |
|
190 | self.assertTrue(m.visitdir('.')) | |
|
191 | self.assertTrue(m.visitdir('dir')) | |
|
192 | self.assertTrue(m.visitdir('dir/subdir')) | |
|
193 | self.assertFalse(m.visitdir('dir/subdir/foo.txt')) | |
|
194 | self.assertFalse(m.visitdir('dir/foo')) | |
|
195 | self.assertFalse(m.visitdir('dir/subdir/x')) | |
|
196 | self.assertFalse(m.visitdir('folder')) | |
|
191 | self.assertTrue(m.visitdir(b'.')) | |
|
192 | self.assertTrue(m.visitdir(b'dir')) | |
|
193 | self.assertTrue(m.visitdir(b'dir/subdir')) | |
|
194 | self.assertFalse(m.visitdir(b'dir/subdir/foo.txt')) | |
|
195 | self.assertFalse(m.visitdir(b'dir/foo')) | |
|
196 | self.assertFalse(m.visitdir(b'dir/subdir/x')) | |
|
197 | self.assertFalse(m.visitdir(b'folder')) | |
|
197 | 198 | |
|
198 | 199 | def testVisitchildrenset(self): |
|
199 |
m = matchmod.match('x', '', patterns=['dir/subdir/foo.txt'], |
|
|
200 | m = matchmod.match(b'x', b'', patterns=[b'dir/subdir/foo.txt'], | |
|
201 | exact=True) | |
|
200 | 202 | assert isinstance(m, matchmod.exactmatcher) |
|
201 | self.assertEqual(m.visitchildrenset('.'), {'dir'}) | |
|
202 | self.assertEqual(m.visitchildrenset('dir'), {'subdir'}) | |
|
203 | self.assertEqual(m.visitchildrenset('dir/subdir'), 'this') | |
|
204 | self.assertEqual(m.visitchildrenset('dir/subdir/x'), set()) | |
|
205 | self.assertEqual(m.visitchildrenset('dir/subdir/foo.txt'), set()) | |
|
206 | self.assertEqual(m.visitchildrenset('folder'), set()) | |
|
203 | self.assertEqual(m.visitchildrenset(b'.'), {b'dir'}) | |
|
204 | self.assertEqual(m.visitchildrenset(b'dir'), {b'subdir'}) | |
|
205 | self.assertEqual(m.visitchildrenset(b'dir/subdir'), b'this') | |
|
206 | self.assertEqual(m.visitchildrenset(b'dir/subdir/x'), set()) | |
|
207 | self.assertEqual(m.visitchildrenset(b'dir/subdir/foo.txt'), set()) | |
|
208 | self.assertEqual(m.visitchildrenset(b'folder'), set()) | |
|
207 | 209 | |
|
208 | 210 | class DifferenceMatcherTests(unittest.TestCase): |
|
209 | 211 | |
|
210 | 212 | def testVisitdirM2always(self): |
|
211 | m1 = matchmod.alwaysmatcher('', '') | |
|
212 | m2 = matchmod.alwaysmatcher('', '') | |
|
213 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
214 | m2 = matchmod.alwaysmatcher(b'', b'') | |
|
213 | 215 | dm = matchmod.differencematcher(m1, m2) |
|
214 | 216 | # dm should be equivalent to a nevermatcher. |
|
215 | self.assertFalse(dm.visitdir('.')) | |
|
216 | self.assertFalse(dm.visitdir('dir')) | |
|
217 | self.assertFalse(dm.visitdir('dir/subdir')) | |
|
218 | self.assertFalse(dm.visitdir('dir/subdir/z')) | |
|
219 | self.assertFalse(dm.visitdir('dir/foo')) | |
|
220 | self.assertFalse(dm.visitdir('dir/subdir/x')) | |
|
221 | self.assertFalse(dm.visitdir('folder')) | |
|
217 | self.assertFalse(dm.visitdir(b'.')) | |
|
218 | self.assertFalse(dm.visitdir(b'dir')) | |
|
219 | self.assertFalse(dm.visitdir(b'dir/subdir')) | |
|
220 | self.assertFalse(dm.visitdir(b'dir/subdir/z')) | |
|
221 | self.assertFalse(dm.visitdir(b'dir/foo')) | |
|
222 | self.assertFalse(dm.visitdir(b'dir/subdir/x')) | |
|
223 | self.assertFalse(dm.visitdir(b'folder')) | |
|
222 | 224 | |
|
223 | 225 | def testVisitchildrensetM2always(self): |
|
224 | m1 = matchmod.alwaysmatcher('', '') | |
|
225 | m2 = matchmod.alwaysmatcher('', '') | |
|
226 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
227 | m2 = matchmod.alwaysmatcher(b'', b'') | |
|
226 | 228 | dm = matchmod.differencematcher(m1, m2) |
|
227 | 229 | # dm should be equivalent to a nevermatcher. |
|
228 | self.assertEqual(dm.visitchildrenset('.'), set()) | |
|
229 | self.assertEqual(dm.visitchildrenset('dir'), set()) | |
|
230 | self.assertEqual(dm.visitchildrenset('dir/subdir'), set()) | |
|
231 | self.assertEqual(dm.visitchildrenset('dir/subdir/z'), set()) | |
|
232 | self.assertEqual(dm.visitchildrenset('dir/foo'), set()) | |
|
233 | self.assertEqual(dm.visitchildrenset('dir/subdir/x'), set()) | |
|
234 | self.assertEqual(dm.visitchildrenset('folder'), set()) | |
|
230 | self.assertEqual(dm.visitchildrenset(b'.'), set()) | |
|
231 | self.assertEqual(dm.visitchildrenset(b'dir'), set()) | |
|
232 | self.assertEqual(dm.visitchildrenset(b'dir/subdir'), set()) | |
|
233 | self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), set()) | |
|
234 | self.assertEqual(dm.visitchildrenset(b'dir/foo'), set()) | |
|
235 | self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), set()) | |
|
236 | self.assertEqual(dm.visitchildrenset(b'folder'), set()) | |
|
235 | 237 | |
|
236 | 238 | def testVisitdirM2never(self): |
|
237 | m1 = matchmod.alwaysmatcher('', '') | |
|
238 | m2 = matchmod.nevermatcher('', '') | |
|
239 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
240 | m2 = matchmod.nevermatcher(b'', b'') | |
|
239 | 241 | dm = matchmod.differencematcher(m1, m2) |
|
240 | 242 | # dm should be equivalent to a alwaysmatcher. OPT: if m2 is a |
|
241 | 243 | # nevermatcher, we could return 'all' for these. |
@@ -244,576 +246,576 b' class DifferenceMatcherTests(unittest.Te' | |||
|
244 | 246 | # assertTrue does NOT verify that it's a bool, just that it's truthy. |
|
245 | 247 | # While we may want to eventually make these return 'all', they should |
|
246 | 248 | # not currently do so. |
|
247 | self.assertEqual(dm.visitdir('.'), True) | |
|
248 | self.assertEqual(dm.visitdir('dir'), True) | |
|
249 | self.assertEqual(dm.visitdir('dir/subdir'), True) | |
|
250 | self.assertEqual(dm.visitdir('dir/subdir/z'), True) | |
|
251 | self.assertEqual(dm.visitdir('dir/foo'), True) | |
|
252 | self.assertEqual(dm.visitdir('dir/subdir/x'), True) | |
|
253 | self.assertEqual(dm.visitdir('folder'), True) | |
|
249 | self.assertEqual(dm.visitdir(b'.'), True) | |
|
250 | self.assertEqual(dm.visitdir(b'dir'), True) | |
|
251 | self.assertEqual(dm.visitdir(b'dir/subdir'), True) | |
|
252 | self.assertEqual(dm.visitdir(b'dir/subdir/z'), True) | |
|
253 | self.assertEqual(dm.visitdir(b'dir/foo'), True) | |
|
254 | self.assertEqual(dm.visitdir(b'dir/subdir/x'), True) | |
|
255 | self.assertEqual(dm.visitdir(b'folder'), True) | |
|
254 | 256 | |
|
255 | 257 | def testVisitchildrensetM2never(self): |
|
256 | m1 = matchmod.alwaysmatcher('', '') | |
|
257 | m2 = matchmod.nevermatcher('', '') | |
|
258 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
259 | m2 = matchmod.nevermatcher(b'', b'') | |
|
258 | 260 | dm = matchmod.differencematcher(m1, m2) |
|
259 | 261 | # dm should be equivalent to a alwaysmatcher. |
|
260 | self.assertEqual(dm.visitchildrenset('.'), 'all') | |
|
261 | self.assertEqual(dm.visitchildrenset('dir'), 'all') | |
|
262 | self.assertEqual(dm.visitchildrenset('dir/subdir'), 'all') | |
|
263 | self.assertEqual(dm.visitchildrenset('dir/subdir/z'), 'all') | |
|
264 | self.assertEqual(dm.visitchildrenset('dir/foo'), 'all') | |
|
265 | self.assertEqual(dm.visitchildrenset('dir/subdir/x'), 'all') | |
|
266 | self.assertEqual(dm.visitchildrenset('folder'), 'all') | |
|
262 | self.assertEqual(dm.visitchildrenset(b'.'), b'all') | |
|
263 | self.assertEqual(dm.visitchildrenset(b'dir'), b'all') | |
|
264 | self.assertEqual(dm.visitchildrenset(b'dir/subdir'), b'all') | |
|
265 | self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'all') | |
|
266 | self.assertEqual(dm.visitchildrenset(b'dir/foo'), b'all') | |
|
267 | self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'all') | |
|
268 | self.assertEqual(dm.visitchildrenset(b'folder'), b'all') | |
|
267 | 269 | |
|
268 | 270 | def testVisitdirM2SubdirPrefix(self): |
|
269 | m1 = matchmod.alwaysmatcher('', '') | |
|
270 | m2 = matchmod.match('', '', patterns=['path:dir/subdir']) | |
|
271 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
272 | m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) | |
|
271 | 273 | dm = matchmod.differencematcher(m1, m2) |
|
272 | self.assertEqual(dm.visitdir('.'), True) | |
|
273 | self.assertEqual(dm.visitdir('dir'), True) | |
|
274 | self.assertFalse(dm.visitdir('dir/subdir')) | |
|
274 | self.assertEqual(dm.visitdir(b'.'), True) | |
|
275 | self.assertEqual(dm.visitdir(b'dir'), True) | |
|
276 | self.assertFalse(dm.visitdir(b'dir/subdir')) | |
|
275 | 277 | # OPT: We should probably return False for these; we don't because |
|
276 | 278 | # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of |
|
277 | 279 | # an 'all' pattern, just True. |
|
278 | self.assertEqual(dm.visitdir('dir/subdir/z'), True) | |
|
279 | self.assertEqual(dm.visitdir('dir/subdir/x'), True) | |
|
280 | self.assertEqual(dm.visitdir(b'dir/subdir/z'), True) | |
|
281 | self.assertEqual(dm.visitdir(b'dir/subdir/x'), True) | |
|
280 | 282 | # OPT: We could return 'all' for these. |
|
281 | self.assertEqual(dm.visitdir('dir/foo'), True) | |
|
282 | self.assertEqual(dm.visitdir('folder'), True) | |
|
283 | self.assertEqual(dm.visitdir(b'dir/foo'), True) | |
|
284 | self.assertEqual(dm.visitdir(b'folder'), True) | |
|
283 | 285 | |
|
284 | 286 | def testVisitchildrensetM2SubdirPrefix(self): |
|
285 | m1 = matchmod.alwaysmatcher('', '') | |
|
286 | m2 = matchmod.match('', '', patterns=['path:dir/subdir']) | |
|
287 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
288 | m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) | |
|
287 | 289 | dm = matchmod.differencematcher(m1, m2) |
|
288 | self.assertEqual(dm.visitchildrenset('.'), 'this') | |
|
289 | self.assertEqual(dm.visitchildrenset('dir'), 'this') | |
|
290 | self.assertEqual(dm.visitchildrenset('dir/subdir'), set()) | |
|
291 | self.assertEqual(dm.visitchildrenset('dir/foo'), 'all') | |
|
292 | self.assertEqual(dm.visitchildrenset('folder'), 'all') | |
|
290 | self.assertEqual(dm.visitchildrenset(b'.'), b'this') | |
|
291 | self.assertEqual(dm.visitchildrenset(b'dir'), b'this') | |
|
292 | self.assertEqual(dm.visitchildrenset(b'dir/subdir'), set()) | |
|
293 | self.assertEqual(dm.visitchildrenset(b'dir/foo'), b'all') | |
|
294 | self.assertEqual(dm.visitchildrenset(b'folder'), b'all') | |
|
293 | 295 | # OPT: We should probably return set() for these; we don't because |
|
294 | 296 | # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of |
|
295 | 297 | # an 'all' pattern, just 'this'. |
|
296 | self.assertEqual(dm.visitchildrenset('dir/subdir/z'), 'this') | |
|
297 | self.assertEqual(dm.visitchildrenset('dir/subdir/x'), 'this') | |
|
298 | self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this') | |
|
299 | self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
298 | 300 | |
|
299 | 301 | # We're using includematcher instead of patterns because it behaves slightly |
|
300 | 302 | # better (giving narrower results) than patternmatcher. |
|
301 | 303 | def testVisitdirIncludeIncludfe(self): |
|
302 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
303 | m2 = matchmod.match('', '', include=['rootfilesin:dir']) | |
|
304 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
305 | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | |
|
304 | 306 | dm = matchmod.differencematcher(m1, m2) |
|
305 | self.assertEqual(dm.visitdir('.'), True) | |
|
306 | self.assertEqual(dm.visitdir('dir'), True) | |
|
307 | self.assertEqual(dm.visitdir('dir/subdir'), True) | |
|
308 | self.assertFalse(dm.visitdir('dir/foo')) | |
|
309 | self.assertFalse(dm.visitdir('folder')) | |
|
307 | self.assertEqual(dm.visitdir(b'.'), True) | |
|
308 | self.assertEqual(dm.visitdir(b'dir'), True) | |
|
309 | self.assertEqual(dm.visitdir(b'dir/subdir'), True) | |
|
310 | self.assertFalse(dm.visitdir(b'dir/foo')) | |
|
311 | self.assertFalse(dm.visitdir(b'folder')) | |
|
310 | 312 | # OPT: We should probably return False for these; we don't because |
|
311 | 313 | # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of |
|
312 | 314 | # an 'all' pattern, just True. |
|
313 | self.assertEqual(dm.visitdir('dir/subdir/z'), True) | |
|
314 | self.assertEqual(dm.visitdir('dir/subdir/x'), True) | |
|
315 | self.assertEqual(dm.visitdir(b'dir/subdir/z'), True) | |
|
316 | self.assertEqual(dm.visitdir(b'dir/subdir/x'), True) | |
|
315 | 317 | |
|
316 | 318 | def testVisitchildrensetIncludeInclude(self): |
|
317 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
318 | m2 = matchmod.match('', '', include=['rootfilesin:dir']) | |
|
319 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
320 | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | |
|
319 | 321 | dm = matchmod.differencematcher(m1, m2) |
|
320 | self.assertEqual(dm.visitchildrenset('.'), {'dir'}) | |
|
321 | self.assertEqual(dm.visitchildrenset('dir'), {'subdir'}) | |
|
322 | self.assertEqual(dm.visitchildrenset('dir/subdir'), 'all') | |
|
323 | self.assertEqual(dm.visitchildrenset('dir/foo'), set()) | |
|
324 | self.assertEqual(dm.visitchildrenset('folder'), set()) | |
|
322 | self.assertEqual(dm.visitchildrenset(b'.'), {b'dir'}) | |
|
323 | self.assertEqual(dm.visitchildrenset(b'dir'), {b'subdir'}) | |
|
324 | self.assertEqual(dm.visitchildrenset(b'dir/subdir'), b'all') | |
|
325 | self.assertEqual(dm.visitchildrenset(b'dir/foo'), set()) | |
|
326 | self.assertEqual(dm.visitchildrenset(b'folder'), set()) | |
|
325 | 327 | # OPT: We should probably return set() for these; we don't because |
|
326 | 328 | # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of |
|
327 | 329 | # an 'all' pattern, just 'this'. |
|
328 | self.assertEqual(dm.visitchildrenset('dir/subdir/z'), 'this') | |
|
329 | self.assertEqual(dm.visitchildrenset('dir/subdir/x'), 'this') | |
|
330 | self.assertEqual(dm.visitchildrenset(b'dir/subdir/z'), b'this') | |
|
331 | self.assertEqual(dm.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
330 | 332 | |
|
331 | 333 | class IntersectionMatcherTests(unittest.TestCase): |
|
332 | 334 | |
|
333 | 335 | def testVisitdirM2always(self): |
|
334 | m1 = matchmod.alwaysmatcher('', '') | |
|
335 | m2 = matchmod.alwaysmatcher('', '') | |
|
336 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
337 | m2 = matchmod.alwaysmatcher(b'', b'') | |
|
336 | 338 | im = matchmod.intersectmatchers(m1, m2) |
|
337 | 339 | # im should be equivalent to a alwaysmatcher. |
|
338 | self.assertEqual(im.visitdir('.'), 'all') | |
|
339 | self.assertEqual(im.visitdir('dir'), 'all') | |
|
340 | self.assertEqual(im.visitdir('dir/subdir'), 'all') | |
|
341 | self.assertEqual(im.visitdir('dir/subdir/z'), 'all') | |
|
342 | self.assertEqual(im.visitdir('dir/foo'), 'all') | |
|
343 | self.assertEqual(im.visitdir('dir/subdir/x'), 'all') | |
|
344 | self.assertEqual(im.visitdir('folder'), 'all') | |
|
340 | self.assertEqual(im.visitdir(b'.'), b'all') | |
|
341 | self.assertEqual(im.visitdir(b'dir'), b'all') | |
|
342 | self.assertEqual(im.visitdir(b'dir/subdir'), b'all') | |
|
343 | self.assertEqual(im.visitdir(b'dir/subdir/z'), b'all') | |
|
344 | self.assertEqual(im.visitdir(b'dir/foo'), b'all') | |
|
345 | self.assertEqual(im.visitdir(b'dir/subdir/x'), b'all') | |
|
346 | self.assertEqual(im.visitdir(b'folder'), b'all') | |
|
345 | 347 | |
|
346 | 348 | def testVisitchildrensetM2always(self): |
|
347 | m1 = matchmod.alwaysmatcher('', '') | |
|
348 | m2 = matchmod.alwaysmatcher('', '') | |
|
349 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
350 | m2 = matchmod.alwaysmatcher(b'', b'') | |
|
349 | 351 | im = matchmod.intersectmatchers(m1, m2) |
|
350 | 352 | # im should be equivalent to a alwaysmatcher. |
|
351 | self.assertEqual(im.visitchildrenset('.'), 'all') | |
|
352 | self.assertEqual(im.visitchildrenset('dir'), 'all') | |
|
353 | self.assertEqual(im.visitchildrenset('dir/subdir'), 'all') | |
|
354 | self.assertEqual(im.visitchildrenset('dir/subdir/z'), 'all') | |
|
355 | self.assertEqual(im.visitchildrenset('dir/foo'), 'all') | |
|
356 | self.assertEqual(im.visitchildrenset('dir/subdir/x'), 'all') | |
|
357 | self.assertEqual(im.visitchildrenset('folder'), 'all') | |
|
353 | self.assertEqual(im.visitchildrenset(b'.'), b'all') | |
|
354 | self.assertEqual(im.visitchildrenset(b'dir'), b'all') | |
|
355 | self.assertEqual(im.visitchildrenset(b'dir/subdir'), b'all') | |
|
356 | self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), b'all') | |
|
357 | self.assertEqual(im.visitchildrenset(b'dir/foo'), b'all') | |
|
358 | self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'all') | |
|
359 | self.assertEqual(im.visitchildrenset(b'folder'), b'all') | |
|
358 | 360 | |
|
359 | 361 | def testVisitdirM2never(self): |
|
360 | m1 = matchmod.alwaysmatcher('', '') | |
|
361 | m2 = matchmod.nevermatcher('', '') | |
|
362 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
363 | m2 = matchmod.nevermatcher(b'', b'') | |
|
362 | 364 | im = matchmod.intersectmatchers(m1, m2) |
|
363 | 365 | # im should be equivalent to a nevermatcher. |
|
364 | self.assertFalse(im.visitdir('.')) | |
|
365 | self.assertFalse(im.visitdir('dir')) | |
|
366 | self.assertFalse(im.visitdir('dir/subdir')) | |
|
367 | self.assertFalse(im.visitdir('dir/subdir/z')) | |
|
368 | self.assertFalse(im.visitdir('dir/foo')) | |
|
369 | self.assertFalse(im.visitdir('dir/subdir/x')) | |
|
370 | self.assertFalse(im.visitdir('folder')) | |
|
366 | self.assertFalse(im.visitdir(b'.')) | |
|
367 | self.assertFalse(im.visitdir(b'dir')) | |
|
368 | self.assertFalse(im.visitdir(b'dir/subdir')) | |
|
369 | self.assertFalse(im.visitdir(b'dir/subdir/z')) | |
|
370 | self.assertFalse(im.visitdir(b'dir/foo')) | |
|
371 | self.assertFalse(im.visitdir(b'dir/subdir/x')) | |
|
372 | self.assertFalse(im.visitdir(b'folder')) | |
|
371 | 373 | |
|
372 | 374 | def testVisitchildrensetM2never(self): |
|
373 | m1 = matchmod.alwaysmatcher('', '') | |
|
374 | m2 = matchmod.nevermatcher('', '') | |
|
375 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
376 | m2 = matchmod.nevermatcher(b'', b'') | |
|
375 | 377 | im = matchmod.intersectmatchers(m1, m2) |
|
376 | 378 | # im should be equivalent to a nevermqtcher. |
|
377 | self.assertEqual(im.visitchildrenset('.'), set()) | |
|
378 | self.assertEqual(im.visitchildrenset('dir'), set()) | |
|
379 | self.assertEqual(im.visitchildrenset('dir/subdir'), set()) | |
|
380 | self.assertEqual(im.visitchildrenset('dir/subdir/z'), set()) | |
|
381 | self.assertEqual(im.visitchildrenset('dir/foo'), set()) | |
|
382 | self.assertEqual(im.visitchildrenset('dir/subdir/x'), set()) | |
|
383 | self.assertEqual(im.visitchildrenset('folder'), set()) | |
|
379 | self.assertEqual(im.visitchildrenset(b'.'), set()) | |
|
380 | self.assertEqual(im.visitchildrenset(b'dir'), set()) | |
|
381 | self.assertEqual(im.visitchildrenset(b'dir/subdir'), set()) | |
|
382 | self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set()) | |
|
383 | self.assertEqual(im.visitchildrenset(b'dir/foo'), set()) | |
|
384 | self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set()) | |
|
385 | self.assertEqual(im.visitchildrenset(b'folder'), set()) | |
|
384 | 386 | |
|
385 | 387 | def testVisitdirM2SubdirPrefix(self): |
|
386 | m1 = matchmod.alwaysmatcher('', '') | |
|
387 | m2 = matchmod.match('', '', patterns=['path:dir/subdir']) | |
|
388 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
389 | m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) | |
|
388 | 390 | im = matchmod.intersectmatchers(m1, m2) |
|
389 | self.assertEqual(im.visitdir('.'), True) | |
|
390 | self.assertEqual(im.visitdir('dir'), True) | |
|
391 | self.assertEqual(im.visitdir('dir/subdir'), 'all') | |
|
392 | self.assertFalse(im.visitdir('dir/foo')) | |
|
393 | self.assertFalse(im.visitdir('folder')) | |
|
391 | self.assertEqual(im.visitdir(b'.'), True) | |
|
392 | self.assertEqual(im.visitdir(b'dir'), True) | |
|
393 | self.assertEqual(im.visitdir(b'dir/subdir'), b'all') | |
|
394 | self.assertFalse(im.visitdir(b'dir/foo')) | |
|
395 | self.assertFalse(im.visitdir(b'folder')) | |
|
394 | 396 | # OPT: We should probably return 'all' for these; we don't because |
|
395 | 397 | # patternmatcher.visitdir() (our m2) doesn't return 'all' for subdirs of |
|
396 | 398 | # an 'all' pattern, just True. |
|
397 | self.assertEqual(im.visitdir('dir/subdir/z'), True) | |
|
398 | self.assertEqual(im.visitdir('dir/subdir/x'), True) | |
|
399 | self.assertEqual(im.visitdir(b'dir/subdir/z'), True) | |
|
400 | self.assertEqual(im.visitdir(b'dir/subdir/x'), True) | |
|
399 | 401 | |
|
400 | 402 | def testVisitchildrensetM2SubdirPrefix(self): |
|
401 | m1 = matchmod.alwaysmatcher('', '') | |
|
402 | m2 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
403 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
404 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
403 | 405 | im = matchmod.intersectmatchers(m1, m2) |
|
404 | self.assertEqual(im.visitchildrenset('.'), {'dir'}) | |
|
405 | self.assertEqual(im.visitchildrenset('dir'), {'subdir'}) | |
|
406 | self.assertEqual(im.visitchildrenset('dir/subdir'), 'all') | |
|
407 | self.assertEqual(im.visitchildrenset('dir/foo'), set()) | |
|
408 | self.assertEqual(im.visitchildrenset('folder'), set()) | |
|
406 | self.assertEqual(im.visitchildrenset(b'.'), {b'dir'}) | |
|
407 | self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'}) | |
|
408 | self.assertEqual(im.visitchildrenset(b'dir/subdir'), b'all') | |
|
409 | self.assertEqual(im.visitchildrenset(b'dir/foo'), set()) | |
|
410 | self.assertEqual(im.visitchildrenset(b'folder'), set()) | |
|
409 | 411 | # OPT: We should probably return 'all' for these |
|
410 | self.assertEqual(im.visitchildrenset('dir/subdir/z'), 'this') | |
|
411 | self.assertEqual(im.visitchildrenset('dir/subdir/x'), 'this') | |
|
412 | self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), b'this') | |
|
413 | self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
412 | 414 | |
|
413 | 415 | # We're using includematcher instead of patterns because it behaves slightly |
|
414 | 416 | # better (giving narrower results) than patternmatcher. |
|
415 | 417 | def testVisitdirIncludeIncludfe(self): |
|
416 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
417 | m2 = matchmod.match('', '', include=['rootfilesin:dir']) | |
|
418 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
419 | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | |
|
418 | 420 | im = matchmod.intersectmatchers(m1, m2) |
|
419 | self.assertEqual(im.visitdir('.'), True) | |
|
420 | self.assertEqual(im.visitdir('dir'), True) | |
|
421 | self.assertFalse(im.visitdir('dir/subdir')) | |
|
422 | self.assertFalse(im.visitdir('dir/foo')) | |
|
423 | self.assertFalse(im.visitdir('folder')) | |
|
424 | self.assertFalse(im.visitdir('dir/subdir/z')) | |
|
425 | self.assertFalse(im.visitdir('dir/subdir/x')) | |
|
421 | self.assertEqual(im.visitdir(b'.'), True) | |
|
422 | self.assertEqual(im.visitdir(b'dir'), True) | |
|
423 | self.assertFalse(im.visitdir(b'dir/subdir')) | |
|
424 | self.assertFalse(im.visitdir(b'dir/foo')) | |
|
425 | self.assertFalse(im.visitdir(b'folder')) | |
|
426 | self.assertFalse(im.visitdir(b'dir/subdir/z')) | |
|
427 | self.assertFalse(im.visitdir(b'dir/subdir/x')) | |
|
426 | 428 | |
|
427 | 429 | def testVisitchildrensetIncludeInclude(self): |
|
428 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
429 | m2 = matchmod.match('', '', include=['rootfilesin:dir']) | |
|
430 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
431 | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | |
|
430 | 432 | im = matchmod.intersectmatchers(m1, m2) |
|
431 | self.assertEqual(im.visitchildrenset('.'), {'dir'}) | |
|
432 | self.assertEqual(im.visitchildrenset('dir'), 'this') | |
|
433 | self.assertEqual(im.visitchildrenset('dir/subdir'), set()) | |
|
434 | self.assertEqual(im.visitchildrenset('dir/foo'), set()) | |
|
435 | self.assertEqual(im.visitchildrenset('folder'), set()) | |
|
436 | self.assertEqual(im.visitchildrenset('dir/subdir/z'), set()) | |
|
437 | self.assertEqual(im.visitchildrenset('dir/subdir/x'), set()) | |
|
433 | self.assertEqual(im.visitchildrenset(b'.'), {b'dir'}) | |
|
434 | self.assertEqual(im.visitchildrenset(b'dir'), b'this') | |
|
435 | self.assertEqual(im.visitchildrenset(b'dir/subdir'), set()) | |
|
436 | self.assertEqual(im.visitchildrenset(b'dir/foo'), set()) | |
|
437 | self.assertEqual(im.visitchildrenset(b'folder'), set()) | |
|
438 | self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set()) | |
|
439 | self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set()) | |
|
438 | 440 | |
|
439 | 441 | # We're using includematcher instead of patterns because it behaves slightly |
|
440 | 442 | # better (giving narrower results) than patternmatcher. |
|
441 | 443 | def testVisitdirIncludeInclude2(self): |
|
442 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
443 | m2 = matchmod.match('', '', include=['path:folder']) | |
|
444 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
445 | m2 = matchmod.match(b'', b'', include=[b'path:folder']) | |
|
444 | 446 | im = matchmod.intersectmatchers(m1, m2) |
|
445 | 447 | # FIXME: is True correct here? |
|
446 | self.assertEqual(im.visitdir('.'), True) | |
|
447 | self.assertFalse(im.visitdir('dir')) | |
|
448 | self.assertFalse(im.visitdir('dir/subdir')) | |
|
449 | self.assertFalse(im.visitdir('dir/foo')) | |
|
450 | self.assertFalse(im.visitdir('folder')) | |
|
451 | self.assertFalse(im.visitdir('dir/subdir/z')) | |
|
452 | self.assertFalse(im.visitdir('dir/subdir/x')) | |
|
448 | self.assertEqual(im.visitdir(b'.'), True) | |
|
449 | self.assertFalse(im.visitdir(b'dir')) | |
|
450 | self.assertFalse(im.visitdir(b'dir/subdir')) | |
|
451 | self.assertFalse(im.visitdir(b'dir/foo')) | |
|
452 | self.assertFalse(im.visitdir(b'folder')) | |
|
453 | self.assertFalse(im.visitdir(b'dir/subdir/z')) | |
|
454 | self.assertFalse(im.visitdir(b'dir/subdir/x')) | |
|
453 | 455 | |
|
454 | 456 | def testVisitchildrensetIncludeInclude2(self): |
|
455 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
456 | m2 = matchmod.match('', '', include=['path:folder']) | |
|
457 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
458 | m2 = matchmod.match(b'', b'', include=[b'path:folder']) | |
|
457 | 459 | im = matchmod.intersectmatchers(m1, m2) |
|
458 | 460 | # FIXME: is set() correct here? |
|
459 | self.assertEqual(im.visitchildrenset('.'), set()) | |
|
460 | self.assertEqual(im.visitchildrenset('dir'), set()) | |
|
461 | self.assertEqual(im.visitchildrenset('dir/subdir'), set()) | |
|
462 | self.assertEqual(im.visitchildrenset('dir/foo'), set()) | |
|
463 | self.assertEqual(im.visitchildrenset('folder'), set()) | |
|
464 | self.assertEqual(im.visitchildrenset('dir/subdir/z'), set()) | |
|
465 | self.assertEqual(im.visitchildrenset('dir/subdir/x'), set()) | |
|
461 | self.assertEqual(im.visitchildrenset(b'.'), set()) | |
|
462 | self.assertEqual(im.visitchildrenset(b'dir'), set()) | |
|
463 | self.assertEqual(im.visitchildrenset(b'dir/subdir'), set()) | |
|
464 | self.assertEqual(im.visitchildrenset(b'dir/foo'), set()) | |
|
465 | self.assertEqual(im.visitchildrenset(b'folder'), set()) | |
|
466 | self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set()) | |
|
467 | self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set()) | |
|
466 | 468 | |
|
467 | 469 | # We're using includematcher instead of patterns because it behaves slightly |
|
468 | 470 | # better (giving narrower results) than patternmatcher. |
|
469 | 471 | def testVisitdirIncludeInclude3(self): |
|
470 | m1 = matchmod.match('', '', include=['path:dir/subdir/x']) | |
|
471 | m2 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
472 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir/x']) | |
|
473 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
472 | 474 | im = matchmod.intersectmatchers(m1, m2) |
|
473 | self.assertEqual(im.visitdir('.'), True) | |
|
474 | self.assertEqual(im.visitdir('dir'), True) | |
|
475 | self.assertEqual(im.visitdir('dir/subdir'), True) | |
|
476 | self.assertFalse(im.visitdir('dir/foo')) | |
|
477 | self.assertFalse(im.visitdir('folder')) | |
|
478 | self.assertFalse(im.visitdir('dir/subdir/z')) | |
|
475 | self.assertEqual(im.visitdir(b'.'), True) | |
|
476 | self.assertEqual(im.visitdir(b'dir'), True) | |
|
477 | self.assertEqual(im.visitdir(b'dir/subdir'), True) | |
|
478 | self.assertFalse(im.visitdir(b'dir/foo')) | |
|
479 | self.assertFalse(im.visitdir(b'folder')) | |
|
480 | self.assertFalse(im.visitdir(b'dir/subdir/z')) | |
|
479 | 481 | # OPT: this should probably be 'all' not True. |
|
480 | self.assertEqual(im.visitdir('dir/subdir/x'), True) | |
|
482 | self.assertEqual(im.visitdir(b'dir/subdir/x'), True) | |
|
481 | 483 | |
|
482 | 484 | def testVisitchildrensetIncludeInclude3(self): |
|
483 | m1 = matchmod.match('', '', include=['path:dir/subdir/x']) | |
|
484 | m2 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
485 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir/x']) | |
|
486 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
485 | 487 | im = matchmod.intersectmatchers(m1, m2) |
|
486 | self.assertEqual(im.visitchildrenset('.'), {'dir'}) | |
|
487 | self.assertEqual(im.visitchildrenset('dir'), {'subdir'}) | |
|
488 | self.assertEqual(im.visitchildrenset('dir/subdir'), {'x'}) | |
|
489 | self.assertEqual(im.visitchildrenset('dir/foo'), set()) | |
|
490 | self.assertEqual(im.visitchildrenset('folder'), set()) | |
|
491 | self.assertEqual(im.visitchildrenset('dir/subdir/z'), set()) | |
|
488 | self.assertEqual(im.visitchildrenset(b'.'), {b'dir'}) | |
|
489 | self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'}) | |
|
490 | self.assertEqual(im.visitchildrenset(b'dir/subdir'), {b'x'}) | |
|
491 | self.assertEqual(im.visitchildrenset(b'dir/foo'), set()) | |
|
492 | self.assertEqual(im.visitchildrenset(b'folder'), set()) | |
|
493 | self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set()) | |
|
492 | 494 | # OPT: this should probably be 'all' not 'this'. |
|
493 | self.assertEqual(im.visitchildrenset('dir/subdir/x'), 'this') | |
|
495 | self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
494 | 496 | |
|
495 | 497 | # We're using includematcher instead of patterns because it behaves slightly |
|
496 | 498 | # better (giving narrower results) than patternmatcher. |
|
497 | 499 | def testVisitdirIncludeInclude4(self): |
|
498 | m1 = matchmod.match('', '', include=['path:dir/subdir/x']) | |
|
499 | m2 = matchmod.match('', '', include=['path:dir/subdir/z']) | |
|
500 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir/x']) | |
|
501 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir/z']) | |
|
500 | 502 | im = matchmod.intersectmatchers(m1, m2) |
|
501 | 503 | # OPT: these next three could probably be False as well. |
|
502 | self.assertEqual(im.visitdir('.'), True) | |
|
503 | self.assertEqual(im.visitdir('dir'), True) | |
|
504 | self.assertEqual(im.visitdir('dir/subdir'), True) | |
|
505 | self.assertFalse(im.visitdir('dir/foo')) | |
|
506 | self.assertFalse(im.visitdir('folder')) | |
|
507 | self.assertFalse(im.visitdir('dir/subdir/z')) | |
|
508 | self.assertFalse(im.visitdir('dir/subdir/x')) | |
|
504 | self.assertEqual(im.visitdir(b'.'), True) | |
|
505 | self.assertEqual(im.visitdir(b'dir'), True) | |
|
506 | self.assertEqual(im.visitdir(b'dir/subdir'), True) | |
|
507 | self.assertFalse(im.visitdir(b'dir/foo')) | |
|
508 | self.assertFalse(im.visitdir(b'folder')) | |
|
509 | self.assertFalse(im.visitdir(b'dir/subdir/z')) | |
|
510 | self.assertFalse(im.visitdir(b'dir/subdir/x')) | |
|
509 | 511 | |
|
510 | 512 | def testVisitchildrensetIncludeInclude4(self): |
|
511 | m1 = matchmod.match('', '', include=['path:dir/subdir/x']) | |
|
512 | m2 = matchmod.match('', '', include=['path:dir/subdir/z']) | |
|
513 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir/x']) | |
|
514 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir/z']) | |
|
513 | 515 | im = matchmod.intersectmatchers(m1, m2) |
|
514 | 516 | # OPT: these next two could probably be set() as well. |
|
515 | self.assertEqual(im.visitchildrenset('.'), {'dir'}) | |
|
516 | self.assertEqual(im.visitchildrenset('dir'), {'subdir'}) | |
|
517 | self.assertEqual(im.visitchildrenset('dir/subdir'), set()) | |
|
518 | self.assertEqual(im.visitchildrenset('dir/foo'), set()) | |
|
519 | self.assertEqual(im.visitchildrenset('folder'), set()) | |
|
520 | self.assertEqual(im.visitchildrenset('dir/subdir/z'), set()) | |
|
521 | self.assertEqual(im.visitchildrenset('dir/subdir/x'), set()) | |
|
517 | self.assertEqual(im.visitchildrenset(b'.'), {b'dir'}) | |
|
518 | self.assertEqual(im.visitchildrenset(b'dir'), {b'subdir'}) | |
|
519 | self.assertEqual(im.visitchildrenset(b'dir/subdir'), set()) | |
|
520 | self.assertEqual(im.visitchildrenset(b'dir/foo'), set()) | |
|
521 | self.assertEqual(im.visitchildrenset(b'folder'), set()) | |
|
522 | self.assertEqual(im.visitchildrenset(b'dir/subdir/z'), set()) | |
|
523 | self.assertEqual(im.visitchildrenset(b'dir/subdir/x'), set()) | |
|
522 | 524 | |
|
523 | 525 | class UnionMatcherTests(unittest.TestCase): |
|
524 | 526 | |
|
525 | 527 | def testVisitdirM2always(self): |
|
526 | m1 = matchmod.alwaysmatcher('', '') | |
|
527 | m2 = matchmod.alwaysmatcher('', '') | |
|
528 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
529 | m2 = matchmod.alwaysmatcher(b'', b'') | |
|
528 | 530 | um = matchmod.unionmatcher([m1, m2]) |
|
529 | 531 | # um should be equivalent to a alwaysmatcher. |
|
530 | self.assertEqual(um.visitdir('.'), 'all') | |
|
531 | self.assertEqual(um.visitdir('dir'), 'all') | |
|
532 | self.assertEqual(um.visitdir('dir/subdir'), 'all') | |
|
533 | self.assertEqual(um.visitdir('dir/subdir/z'), 'all') | |
|
534 | self.assertEqual(um.visitdir('dir/foo'), 'all') | |
|
535 | self.assertEqual(um.visitdir('dir/subdir/x'), 'all') | |
|
536 | self.assertEqual(um.visitdir('folder'), 'all') | |
|
532 | self.assertEqual(um.visitdir(b'.'), b'all') | |
|
533 | self.assertEqual(um.visitdir(b'dir'), b'all') | |
|
534 | self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | |
|
535 | self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all') | |
|
536 | self.assertEqual(um.visitdir(b'dir/foo'), b'all') | |
|
537 | self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all') | |
|
538 | self.assertEqual(um.visitdir(b'folder'), b'all') | |
|
537 | 539 | |
|
538 | 540 | def testVisitchildrensetM2always(self): |
|
539 | m1 = matchmod.alwaysmatcher('', '') | |
|
540 | m2 = matchmod.alwaysmatcher('', '') | |
|
541 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
542 | m2 = matchmod.alwaysmatcher(b'', b'') | |
|
541 | 543 | um = matchmod.unionmatcher([m1, m2]) |
|
542 | 544 | # um should be equivalent to a alwaysmatcher. |
|
543 | self.assertEqual(um.visitchildrenset('.'), 'all') | |
|
544 | self.assertEqual(um.visitchildrenset('dir'), 'all') | |
|
545 | self.assertEqual(um.visitchildrenset('dir/subdir'), 'all') | |
|
546 | self.assertEqual(um.visitchildrenset('dir/subdir/z'), 'all') | |
|
547 | self.assertEqual(um.visitchildrenset('dir/foo'), 'all') | |
|
548 | self.assertEqual(um.visitchildrenset('dir/subdir/x'), 'all') | |
|
549 | self.assertEqual(um.visitchildrenset('folder'), 'all') | |
|
545 | self.assertEqual(um.visitchildrenset(b'.'), b'all') | |
|
546 | self.assertEqual(um.visitchildrenset(b'dir'), b'all') | |
|
547 | self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | |
|
548 | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all') | |
|
549 | self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all') | |
|
550 | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all') | |
|
551 | self.assertEqual(um.visitchildrenset(b'folder'), b'all') | |
|
550 | 552 | |
|
551 | 553 | def testVisitdirM1never(self): |
|
552 | m1 = matchmod.nevermatcher('', '') | |
|
553 | m2 = matchmod.alwaysmatcher('', '') | |
|
554 | m1 = matchmod.nevermatcher(b'', b'') | |
|
555 | m2 = matchmod.alwaysmatcher(b'', b'') | |
|
554 | 556 | um = matchmod.unionmatcher([m1, m2]) |
|
555 | 557 | # um should be equivalent to a alwaysmatcher. |
|
556 | self.assertEqual(um.visitdir('.'), 'all') | |
|
557 | self.assertEqual(um.visitdir('dir'), 'all') | |
|
558 | self.assertEqual(um.visitdir('dir/subdir'), 'all') | |
|
559 | self.assertEqual(um.visitdir('dir/subdir/z'), 'all') | |
|
560 | self.assertEqual(um.visitdir('dir/foo'), 'all') | |
|
561 | self.assertEqual(um.visitdir('dir/subdir/x'), 'all') | |
|
562 | self.assertEqual(um.visitdir('folder'), 'all') | |
|
558 | self.assertEqual(um.visitdir(b'.'), b'all') | |
|
559 | self.assertEqual(um.visitdir(b'dir'), b'all') | |
|
560 | self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | |
|
561 | self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all') | |
|
562 | self.assertEqual(um.visitdir(b'dir/foo'), b'all') | |
|
563 | self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all') | |
|
564 | self.assertEqual(um.visitdir(b'folder'), b'all') | |
|
563 | 565 | |
|
564 | 566 | def testVisitchildrensetM1never(self): |
|
565 | m1 = matchmod.nevermatcher('', '') | |
|
566 | m2 = matchmod.alwaysmatcher('', '') | |
|
567 | m1 = matchmod.nevermatcher(b'', b'') | |
|
568 | m2 = matchmod.alwaysmatcher(b'', b'') | |
|
567 | 569 | um = matchmod.unionmatcher([m1, m2]) |
|
568 | 570 | # um should be equivalent to a alwaysmatcher. |
|
569 | self.assertEqual(um.visitchildrenset('.'), 'all') | |
|
570 | self.assertEqual(um.visitchildrenset('dir'), 'all') | |
|
571 | self.assertEqual(um.visitchildrenset('dir/subdir'), 'all') | |
|
572 | self.assertEqual(um.visitchildrenset('dir/subdir/z'), 'all') | |
|
573 | self.assertEqual(um.visitchildrenset('dir/foo'), 'all') | |
|
574 | self.assertEqual(um.visitchildrenset('dir/subdir/x'), 'all') | |
|
575 | self.assertEqual(um.visitchildrenset('folder'), 'all') | |
|
571 | self.assertEqual(um.visitchildrenset(b'.'), b'all') | |
|
572 | self.assertEqual(um.visitchildrenset(b'dir'), b'all') | |
|
573 | self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | |
|
574 | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all') | |
|
575 | self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all') | |
|
576 | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all') | |
|
577 | self.assertEqual(um.visitchildrenset(b'folder'), b'all') | |
|
576 | 578 | |
|
577 | 579 | def testVisitdirM2never(self): |
|
578 | m1 = matchmod.alwaysmatcher('', '') | |
|
579 | m2 = matchmod.nevermatcher('', '') | |
|
580 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
581 | m2 = matchmod.nevermatcher(b'', b'') | |
|
580 | 582 | um = matchmod.unionmatcher([m1, m2]) |
|
581 | 583 | # um should be equivalent to a alwaysmatcher. |
|
582 | self.assertEqual(um.visitdir('.'), 'all') | |
|
583 | self.assertEqual(um.visitdir('dir'), 'all') | |
|
584 | self.assertEqual(um.visitdir('dir/subdir'), 'all') | |
|
585 | self.assertEqual(um.visitdir('dir/subdir/z'), 'all') | |
|
586 | self.assertEqual(um.visitdir('dir/foo'), 'all') | |
|
587 | self.assertEqual(um.visitdir('dir/subdir/x'), 'all') | |
|
588 | self.assertEqual(um.visitdir('folder'), 'all') | |
|
584 | self.assertEqual(um.visitdir(b'.'), b'all') | |
|
585 | self.assertEqual(um.visitdir(b'dir'), b'all') | |
|
586 | self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | |
|
587 | self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all') | |
|
588 | self.assertEqual(um.visitdir(b'dir/foo'), b'all') | |
|
589 | self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all') | |
|
590 | self.assertEqual(um.visitdir(b'folder'), b'all') | |
|
589 | 591 | |
|
590 | 592 | def testVisitchildrensetM2never(self): |
|
591 | m1 = matchmod.alwaysmatcher('', '') | |
|
592 | m2 = matchmod.nevermatcher('', '') | |
|
593 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
594 | m2 = matchmod.nevermatcher(b'', b'') | |
|
593 | 595 | um = matchmod.unionmatcher([m1, m2]) |
|
594 | 596 | # um should be equivalent to a alwaysmatcher. |
|
595 | self.assertEqual(um.visitchildrenset('.'), 'all') | |
|
596 | self.assertEqual(um.visitchildrenset('dir'), 'all') | |
|
597 | self.assertEqual(um.visitchildrenset('dir/subdir'), 'all') | |
|
598 | self.assertEqual(um.visitchildrenset('dir/subdir/z'), 'all') | |
|
599 | self.assertEqual(um.visitchildrenset('dir/foo'), 'all') | |
|
600 | self.assertEqual(um.visitchildrenset('dir/subdir/x'), 'all') | |
|
601 | self.assertEqual(um.visitchildrenset('folder'), 'all') | |
|
597 | self.assertEqual(um.visitchildrenset(b'.'), b'all') | |
|
598 | self.assertEqual(um.visitchildrenset(b'dir'), b'all') | |
|
599 | self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | |
|
600 | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all') | |
|
601 | self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all') | |
|
602 | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all') | |
|
603 | self.assertEqual(um.visitchildrenset(b'folder'), b'all') | |
|
602 | 604 | |
|
603 | 605 | def testVisitdirM2SubdirPrefix(self): |
|
604 | m1 = matchmod.alwaysmatcher('', '') | |
|
605 | m2 = matchmod.match('', '', patterns=['path:dir/subdir']) | |
|
606 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
607 | m2 = matchmod.match(b'', b'', patterns=[b'path:dir/subdir']) | |
|
606 | 608 | um = matchmod.unionmatcher([m1, m2]) |
|
607 | self.assertEqual(um.visitdir('.'), 'all') | |
|
608 | self.assertEqual(um.visitdir('dir'), 'all') | |
|
609 | self.assertEqual(um.visitdir('dir/subdir'), 'all') | |
|
610 | self.assertEqual(um.visitdir('dir/foo'), 'all') | |
|
611 | self.assertEqual(um.visitdir('folder'), 'all') | |
|
612 | self.assertEqual(um.visitdir('dir/subdir/z'), 'all') | |
|
613 | self.assertEqual(um.visitdir('dir/subdir/x'), 'all') | |
|
609 | self.assertEqual(um.visitdir(b'.'), b'all') | |
|
610 | self.assertEqual(um.visitdir(b'dir'), b'all') | |
|
611 | self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | |
|
612 | self.assertEqual(um.visitdir(b'dir/foo'), b'all') | |
|
613 | self.assertEqual(um.visitdir(b'folder'), b'all') | |
|
614 | self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all') | |
|
615 | self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all') | |
|
614 | 616 | |
|
615 | 617 | def testVisitchildrensetM2SubdirPrefix(self): |
|
616 | m1 = matchmod.alwaysmatcher('', '') | |
|
617 | m2 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
618 | m1 = matchmod.alwaysmatcher(b'', b'') | |
|
619 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
618 | 620 | um = matchmod.unionmatcher([m1, m2]) |
|
619 | self.assertEqual(um.visitchildrenset('.'), 'all') | |
|
620 | self.assertEqual(um.visitchildrenset('dir'), 'all') | |
|
621 | self.assertEqual(um.visitchildrenset('dir/subdir'), 'all') | |
|
622 | self.assertEqual(um.visitchildrenset('dir/foo'), 'all') | |
|
623 | self.assertEqual(um.visitchildrenset('folder'), 'all') | |
|
624 | self.assertEqual(um.visitchildrenset('dir/subdir/z'), 'all') | |
|
625 | self.assertEqual(um.visitchildrenset('dir/subdir/x'), 'all') | |
|
621 | self.assertEqual(um.visitchildrenset(b'.'), b'all') | |
|
622 | self.assertEqual(um.visitchildrenset(b'dir'), b'all') | |
|
623 | self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | |
|
624 | self.assertEqual(um.visitchildrenset(b'dir/foo'), b'all') | |
|
625 | self.assertEqual(um.visitchildrenset(b'folder'), b'all') | |
|
626 | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all') | |
|
627 | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all') | |
|
626 | 628 | |
|
627 | 629 | # We're using includematcher instead of patterns because it behaves slightly |
|
628 | 630 | # better (giving narrower results) than patternmatcher. |
|
629 | 631 | def testVisitdirIncludeIncludfe(self): |
|
630 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
631 | m2 = matchmod.match('', '', include=['rootfilesin:dir']) | |
|
632 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
633 | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | |
|
632 | 634 | um = matchmod.unionmatcher([m1, m2]) |
|
633 | self.assertEqual(um.visitdir('.'), True) | |
|
634 | self.assertEqual(um.visitdir('dir'), True) | |
|
635 | self.assertEqual(um.visitdir('dir/subdir'), 'all') | |
|
636 | self.assertFalse(um.visitdir('dir/foo')) | |
|
637 | self.assertFalse(um.visitdir('folder')) | |
|
635 | self.assertEqual(um.visitdir(b'.'), True) | |
|
636 | self.assertEqual(um.visitdir(b'dir'), True) | |
|
637 | self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | |
|
638 | self.assertFalse(um.visitdir(b'dir/foo')) | |
|
639 | self.assertFalse(um.visitdir(b'folder')) | |
|
638 | 640 | # OPT: These two should probably be 'all' not True. |
|
639 | self.assertEqual(um.visitdir('dir/subdir/z'), True) | |
|
640 | self.assertEqual(um.visitdir('dir/subdir/x'), True) | |
|
641 | self.assertEqual(um.visitdir(b'dir/subdir/z'), True) | |
|
642 | self.assertEqual(um.visitdir(b'dir/subdir/x'), True) | |
|
641 | 643 | |
|
642 | 644 | def testVisitchildrensetIncludeInclude(self): |
|
643 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
644 | m2 = matchmod.match('', '', include=['rootfilesin:dir']) | |
|
645 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
646 | m2 = matchmod.match(b'', b'', include=[b'rootfilesin:dir']) | |
|
645 | 647 | um = matchmod.unionmatcher([m1, m2]) |
|
646 | self.assertEqual(um.visitchildrenset('.'), {'dir'}) | |
|
647 | self.assertEqual(um.visitchildrenset('dir'), 'this') | |
|
648 | self.assertEqual(um.visitchildrenset('dir/subdir'), 'all') | |
|
649 | self.assertEqual(um.visitchildrenset('dir/foo'), set()) | |
|
650 | self.assertEqual(um.visitchildrenset('folder'), set()) | |
|
648 | self.assertEqual(um.visitchildrenset(b'.'), {b'dir'}) | |
|
649 | self.assertEqual(um.visitchildrenset(b'dir'), b'this') | |
|
650 | self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | |
|
651 | self.assertEqual(um.visitchildrenset(b'dir/foo'), set()) | |
|
652 | self.assertEqual(um.visitchildrenset(b'folder'), set()) | |
|
651 | 653 | # OPT: These next two could be 'all' instead of 'this'. |
|
652 | self.assertEqual(um.visitchildrenset('dir/subdir/z'), 'this') | |
|
653 | self.assertEqual(um.visitchildrenset('dir/subdir/x'), 'this') | |
|
654 | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this') | |
|
655 | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
654 | 656 | |
|
655 | 657 | # We're using includematcher instead of patterns because it behaves slightly |
|
656 | 658 | # better (giving narrower results) than patternmatcher. |
|
657 | 659 | def testVisitdirIncludeInclude2(self): |
|
658 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
659 | m2 = matchmod.match('', '', include=['path:folder']) | |
|
660 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
661 | m2 = matchmod.match(b'', b'', include=[b'path:folder']) | |
|
660 | 662 | um = matchmod.unionmatcher([m1, m2]) |
|
661 | self.assertEqual(um.visitdir('.'), True) | |
|
662 | self.assertEqual(um.visitdir('dir'), True) | |
|
663 | self.assertEqual(um.visitdir('dir/subdir'), 'all') | |
|
664 | self.assertFalse(um.visitdir('dir/foo')) | |
|
665 | self.assertEqual(um.visitdir('folder'), 'all') | |
|
663 | self.assertEqual(um.visitdir(b'.'), True) | |
|
664 | self.assertEqual(um.visitdir(b'dir'), True) | |
|
665 | self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | |
|
666 | self.assertFalse(um.visitdir(b'dir/foo')) | |
|
667 | self.assertEqual(um.visitdir(b'folder'), b'all') | |
|
666 | 668 | # OPT: These should probably be 'all' not True. |
|
667 | self.assertEqual(um.visitdir('dir/subdir/z'), True) | |
|
668 | self.assertEqual(um.visitdir('dir/subdir/x'), True) | |
|
669 | self.assertEqual(um.visitdir(b'dir/subdir/z'), True) | |
|
670 | self.assertEqual(um.visitdir(b'dir/subdir/x'), True) | |
|
669 | 671 | |
|
670 | 672 | def testVisitchildrensetIncludeInclude2(self): |
|
671 | m1 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
672 | m2 = matchmod.match('', '', include=['path:folder']) | |
|
673 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
674 | m2 = matchmod.match(b'', b'', include=[b'path:folder']) | |
|
673 | 675 | um = matchmod.unionmatcher([m1, m2]) |
|
674 | self.assertEqual(um.visitchildrenset('.'), {'folder', 'dir'}) | |
|
675 | self.assertEqual(um.visitchildrenset('dir'), {'subdir'}) | |
|
676 | self.assertEqual(um.visitchildrenset('dir/subdir'), 'all') | |
|
677 | self.assertEqual(um.visitchildrenset('dir/foo'), set()) | |
|
678 | self.assertEqual(um.visitchildrenset('folder'), 'all') | |
|
676 | self.assertEqual(um.visitchildrenset(b'.'), {b'folder', b'dir'}) | |
|
677 | self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'}) | |
|
678 | self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | |
|
679 | self.assertEqual(um.visitchildrenset(b'dir/foo'), set()) | |
|
680 | self.assertEqual(um.visitchildrenset(b'folder'), b'all') | |
|
679 | 681 | # OPT: These next two could be 'all' instead of 'this'. |
|
680 | self.assertEqual(um.visitchildrenset('dir/subdir/z'), 'this') | |
|
681 | self.assertEqual(um.visitchildrenset('dir/subdir/x'), 'this') | |
|
682 | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this') | |
|
683 | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'this') | |
|
682 | 684 | |
|
683 | 685 | # We're using includematcher instead of patterns because it behaves slightly |
|
684 | 686 | # better (giving narrower results) than patternmatcher. |
|
685 | 687 | def testVisitdirIncludeInclude3(self): |
|
686 | m1 = matchmod.match('', '', include=['path:dir/subdir/x']) | |
|
687 | m2 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
688 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir/x']) | |
|
689 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
688 | 690 | um = matchmod.unionmatcher([m1, m2]) |
|
689 | self.assertEqual(um.visitdir('.'), True) | |
|
690 | self.assertEqual(um.visitdir('dir'), True) | |
|
691 | self.assertEqual(um.visitdir('dir/subdir'), 'all') | |
|
692 | self.assertFalse(um.visitdir('dir/foo')) | |
|
693 | self.assertFalse(um.visitdir('folder')) | |
|
694 | self.assertEqual(um.visitdir('dir/subdir/x'), 'all') | |
|
691 | self.assertEqual(um.visitdir(b'.'), True) | |
|
692 | self.assertEqual(um.visitdir(b'dir'), True) | |
|
693 | self.assertEqual(um.visitdir(b'dir/subdir'), b'all') | |
|
694 | self.assertFalse(um.visitdir(b'dir/foo')) | |
|
695 | self.assertFalse(um.visitdir(b'folder')) | |
|
696 | self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all') | |
|
695 | 697 | # OPT: this should probably be 'all' not True. |
|
696 | self.assertEqual(um.visitdir('dir/subdir/z'), True) | |
|
698 | self.assertEqual(um.visitdir(b'dir/subdir/z'), True) | |
|
697 | 699 | |
|
698 | 700 | def testVisitchildrensetIncludeInclude3(self): |
|
699 | m1 = matchmod.match('', '', include=['path:dir/subdir/x']) | |
|
700 | m2 = matchmod.match('', '', include=['path:dir/subdir']) | |
|
701 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir/x']) | |
|
702 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
701 | 703 | um = matchmod.unionmatcher([m1, m2]) |
|
702 | self.assertEqual(um.visitchildrenset('.'), {'dir'}) | |
|
703 | self.assertEqual(um.visitchildrenset('dir'), {'subdir'}) | |
|
704 | self.assertEqual(um.visitchildrenset('dir/subdir'), 'all') | |
|
705 | self.assertEqual(um.visitchildrenset('dir/foo'), set()) | |
|
706 | self.assertEqual(um.visitchildrenset('folder'), set()) | |
|
707 | self.assertEqual(um.visitchildrenset('dir/subdir/x'), 'all') | |
|
704 | self.assertEqual(um.visitchildrenset(b'.'), {b'dir'}) | |
|
705 | self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'}) | |
|
706 | self.assertEqual(um.visitchildrenset(b'dir/subdir'), b'all') | |
|
707 | self.assertEqual(um.visitchildrenset(b'dir/foo'), set()) | |
|
708 | self.assertEqual(um.visitchildrenset(b'folder'), set()) | |
|
709 | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all') | |
|
708 | 710 | # OPT: this should probably be 'all' not 'this'. |
|
709 | self.assertEqual(um.visitchildrenset('dir/subdir/z'), 'this') | |
|
711 | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'this') | |
|
710 | 712 | |
|
711 | 713 | # We're using includematcher instead of patterns because it behaves slightly |
|
712 | 714 | # better (giving narrower results) than patternmatcher. |
|
713 | 715 | def testVisitdirIncludeInclude4(self): |
|
714 | m1 = matchmod.match('', '', include=['path:dir/subdir/x']) | |
|
715 | m2 = matchmod.match('', '', include=['path:dir/subdir/z']) | |
|
716 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir/x']) | |
|
717 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir/z']) | |
|
716 | 718 | um = matchmod.unionmatcher([m1, m2]) |
|
717 | 719 | # OPT: these next three could probably be False as well. |
|
718 | self.assertEqual(um.visitdir('.'), True) | |
|
719 | self.assertEqual(um.visitdir('dir'), True) | |
|
720 | self.assertEqual(um.visitdir('dir/subdir'), True) | |
|
721 | self.assertFalse(um.visitdir('dir/foo')) | |
|
722 | self.assertFalse(um.visitdir('folder')) | |
|
723 | self.assertEqual(um.visitdir('dir/subdir/z'), 'all') | |
|
724 | self.assertEqual(um.visitdir('dir/subdir/x'), 'all') | |
|
720 | self.assertEqual(um.visitdir(b'.'), True) | |
|
721 | self.assertEqual(um.visitdir(b'dir'), True) | |
|
722 | self.assertEqual(um.visitdir(b'dir/subdir'), True) | |
|
723 | self.assertFalse(um.visitdir(b'dir/foo')) | |
|
724 | self.assertFalse(um.visitdir(b'folder')) | |
|
725 | self.assertEqual(um.visitdir(b'dir/subdir/z'), b'all') | |
|
726 | self.assertEqual(um.visitdir(b'dir/subdir/x'), b'all') | |
|
725 | 727 | |
|
726 | 728 | def testVisitchildrensetIncludeInclude4(self): |
|
727 | m1 = matchmod.match('', '', include=['path:dir/subdir/x']) | |
|
728 | m2 = matchmod.match('', '', include=['path:dir/subdir/z']) | |
|
729 | m1 = matchmod.match(b'', b'', include=[b'path:dir/subdir/x']) | |
|
730 | m2 = matchmod.match(b'', b'', include=[b'path:dir/subdir/z']) | |
|
729 | 731 | um = matchmod.unionmatcher([m1, m2]) |
|
730 | self.assertEqual(um.visitchildrenset('.'), {'dir'}) | |
|
731 | self.assertEqual(um.visitchildrenset('dir'), {'subdir'}) | |
|
732 | self.assertEqual(um.visitchildrenset('dir/subdir'), {'x', 'z'}) | |
|
733 | self.assertEqual(um.visitchildrenset('dir/foo'), set()) | |
|
734 | self.assertEqual(um.visitchildrenset('folder'), set()) | |
|
735 | self.assertEqual(um.visitchildrenset('dir/subdir/z'), 'all') | |
|
736 | self.assertEqual(um.visitchildrenset('dir/subdir/x'), 'all') | |
|
732 | self.assertEqual(um.visitchildrenset(b'.'), {b'dir'}) | |
|
733 | self.assertEqual(um.visitchildrenset(b'dir'), {b'subdir'}) | |
|
734 | self.assertEqual(um.visitchildrenset(b'dir/subdir'), {b'x', b'z'}) | |
|
735 | self.assertEqual(um.visitchildrenset(b'dir/foo'), set()) | |
|
736 | self.assertEqual(um.visitchildrenset(b'folder'), set()) | |
|
737 | self.assertEqual(um.visitchildrenset(b'dir/subdir/z'), b'all') | |
|
738 | self.assertEqual(um.visitchildrenset(b'dir/subdir/x'), b'all') | |
|
737 | 739 | |
|
738 | 740 | class SubdirMatcherTests(unittest.TestCase): |
|
739 | 741 | |
|
740 | 742 | def testVisitdir(self): |
|
741 | m = matchmod.match('', '', include=['path:dir/subdir']) | |
|
742 | sm = matchmod.subdirmatcher('dir', m) | |
|
743 | m = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
744 | sm = matchmod.subdirmatcher(b'dir', m) | |
|
743 | 745 | |
|
744 | self.assertEqual(sm.visitdir('.'), True) | |
|
745 | self.assertEqual(sm.visitdir('subdir'), 'all') | |
|
746 | self.assertEqual(sm.visitdir(b'.'), True) | |
|
747 | self.assertEqual(sm.visitdir(b'subdir'), b'all') | |
|
746 | 748 | # OPT: These next two should probably be 'all' not True. |
|
747 | self.assertEqual(sm.visitdir('subdir/x'), True) | |
|
748 | self.assertEqual(sm.visitdir('subdir/z'), True) | |
|
749 | self.assertFalse(sm.visitdir('foo')) | |
|
749 | self.assertEqual(sm.visitdir(b'subdir/x'), True) | |
|
750 | self.assertEqual(sm.visitdir(b'subdir/z'), True) | |
|
751 | self.assertFalse(sm.visitdir(b'foo')) | |
|
750 | 752 | |
|
751 | 753 | def testVisitchildrenset(self): |
|
752 | m = matchmod.match('', '', include=['path:dir/subdir']) | |
|
753 | sm = matchmod.subdirmatcher('dir', m) | |
|
754 | m = matchmod.match(b'', b'', include=[b'path:dir/subdir']) | |
|
755 | sm = matchmod.subdirmatcher(b'dir', m) | |
|
754 | 756 | |
|
755 | self.assertEqual(sm.visitchildrenset('.'), {'subdir'}) | |
|
756 | self.assertEqual(sm.visitchildrenset('subdir'), 'all') | |
|
757 | self.assertEqual(sm.visitchildrenset(b'.'), {b'subdir'}) | |
|
758 | self.assertEqual(sm.visitchildrenset(b'subdir'), b'all') | |
|
757 | 759 | # OPT: These next two should probably be 'all' not 'this'. |
|
758 | self.assertEqual(sm.visitchildrenset('subdir/x'), 'this') | |
|
759 | self.assertEqual(sm.visitchildrenset('subdir/z'), 'this') | |
|
760 | self.assertEqual(sm.visitchildrenset('foo'), set()) | |
|
760 | self.assertEqual(sm.visitchildrenset(b'subdir/x'), b'this') | |
|
761 | self.assertEqual(sm.visitchildrenset(b'subdir/z'), b'this') | |
|
762 | self.assertEqual(sm.visitchildrenset(b'foo'), set()) | |
|
761 | 763 | |
|
762 | 764 | class PrefixdirMatcherTests(unittest.TestCase): |
|
763 | 765 | |
|
764 | 766 | def testVisitdir(self): |
|
765 | m = matchmod.match(util.localpath('root/d'), 'e/f', | |
|
766 | ['../a.txt', 'b.txt']) | |
|
767 | pm = matchmod.prefixdirmatcher('root', 'd/e/f', 'd', m) | |
|
767 | m = matchmod.match(util.localpath(b'root/d'), b'e/f', | |
|
768 | [b'../a.txt', b'b.txt']) | |
|
769 | pm = matchmod.prefixdirmatcher(b'root', b'd/e/f', b'd', m) | |
|
768 | 770 | |
|
769 | 771 | # `m` elides 'd' because it's part of the root, and the rest of the |
|
770 | 772 | # patterns are relative. |
|
771 | self.assertEqual(bool(m('a.txt')), False) | |
|
772 | self.assertEqual(bool(m('b.txt')), False) | |
|
773 | self.assertEqual(bool(m('e/a.txt')), True) | |
|
774 | self.assertEqual(bool(m('e/b.txt')), False) | |
|
775 | self.assertEqual(bool(m('e/f/b.txt')), True) | |
|
773 | self.assertEqual(bool(m(b'a.txt')), False) | |
|
774 | self.assertEqual(bool(m(b'b.txt')), False) | |
|
775 | self.assertEqual(bool(m(b'e/a.txt')), True) | |
|
776 | self.assertEqual(bool(m(b'e/b.txt')), False) | |
|
777 | self.assertEqual(bool(m(b'e/f/b.txt')), True) | |
|
776 | 778 | |
|
777 | 779 | # The prefix matcher re-adds 'd' to the paths, so they need to be |
|
778 | 780 | # specified when using the prefixdirmatcher. |
|
779 | self.assertEqual(bool(pm('a.txt')), False) | |
|
780 | self.assertEqual(bool(pm('b.txt')), False) | |
|
781 | self.assertEqual(bool(pm('d/e/a.txt')), True) | |
|
782 | self.assertEqual(bool(pm('d/e/b.txt')), False) | |
|
783 | self.assertEqual(bool(pm('d/e/f/b.txt')), True) | |
|
781 | self.assertEqual(bool(pm(b'a.txt')), False) | |
|
782 | self.assertEqual(bool(pm(b'b.txt')), False) | |
|
783 | self.assertEqual(bool(pm(b'd/e/a.txt')), True) | |
|
784 | self.assertEqual(bool(pm(b'd/e/b.txt')), False) | |
|
785 | self.assertEqual(bool(pm(b'd/e/f/b.txt')), True) | |
|
784 | 786 | |
|
785 | self.assertEqual(m.visitdir('.'), True) | |
|
786 | self.assertEqual(m.visitdir('e'), True) | |
|
787 | self.assertEqual(m.visitdir('e/f'), True) | |
|
788 | self.assertEqual(m.visitdir('e/f/g'), False) | |
|
787 | self.assertEqual(m.visitdir(b'.'), True) | |
|
788 | self.assertEqual(m.visitdir(b'e'), True) | |
|
789 | self.assertEqual(m.visitdir(b'e/f'), True) | |
|
790 | self.assertEqual(m.visitdir(b'e/f/g'), False) | |
|
789 | 791 | |
|
790 | self.assertEqual(pm.visitdir('.'), True) | |
|
791 | self.assertEqual(pm.visitdir('d'), True) | |
|
792 | self.assertEqual(pm.visitdir('d/e'), True) | |
|
793 | self.assertEqual(pm.visitdir('d/e/f'), True) | |
|
794 | self.assertEqual(pm.visitdir('d/e/f/g'), False) | |
|
792 | self.assertEqual(pm.visitdir(b'.'), True) | |
|
793 | self.assertEqual(pm.visitdir(b'd'), True) | |
|
794 | self.assertEqual(pm.visitdir(b'd/e'), True) | |
|
795 | self.assertEqual(pm.visitdir(b'd/e/f'), True) | |
|
796 | self.assertEqual(pm.visitdir(b'd/e/f/g'), False) | |
|
795 | 797 | |
|
796 | 798 | def testVisitchildrenset(self): |
|
797 | m = matchmod.match(util.localpath('root/d'), 'e/f', | |
|
798 | ['../a.txt', 'b.txt']) | |
|
799 | pm = matchmod.prefixdirmatcher('root', 'd/e/f', 'd', m) | |
|
799 | m = matchmod.match(util.localpath(b'root/d'), b'e/f', | |
|
800 | [b'../a.txt', b'b.txt']) | |
|
801 | pm = matchmod.prefixdirmatcher(b'root', b'd/e/f', b'd', m) | |
|
800 | 802 | |
|
801 | 803 | # OPT: visitchildrenset could possibly return {'e'} and {'f'} for these |
|
802 | 804 | # next two, respectively; patternmatcher does not have this |
|
803 | 805 | # optimization. |
|
804 | self.assertEqual(m.visitchildrenset('.'), 'this') | |
|
805 | self.assertEqual(m.visitchildrenset('e'), 'this') | |
|
806 | self.assertEqual(m.visitchildrenset('e/f'), 'this') | |
|
807 | self.assertEqual(m.visitchildrenset('e/f/g'), set()) | |
|
806 | self.assertEqual(m.visitchildrenset(b'.'), b'this') | |
|
807 | self.assertEqual(m.visitchildrenset(b'e'), b'this') | |
|
808 | self.assertEqual(m.visitchildrenset(b'e/f'), b'this') | |
|
809 | self.assertEqual(m.visitchildrenset(b'e/f/g'), set()) | |
|
808 | 810 | |
|
809 | 811 | # OPT: visitchildrenset could possibly return {'d'}, {'e'}, and {'f'} |
|
810 | 812 | # for these next three, respectively; patternmatcher does not have this |
|
811 | 813 | # optimization. |
|
812 | self.assertEqual(pm.visitchildrenset('.'), 'this') | |
|
813 | self.assertEqual(pm.visitchildrenset('d'), 'this') | |
|
814 | self.assertEqual(pm.visitchildrenset('d/e'), 'this') | |
|
815 | self.assertEqual(pm.visitchildrenset('d/e/f'), 'this') | |
|
816 | self.assertEqual(pm.visitchildrenset('d/e/f/g'), set()) | |
|
814 | self.assertEqual(pm.visitchildrenset(b'.'), b'this') | |
|
815 | self.assertEqual(pm.visitchildrenset(b'd'), b'this') | |
|
816 | self.assertEqual(pm.visitchildrenset(b'd/e'), b'this') | |
|
817 | self.assertEqual(pm.visitchildrenset(b'd/e/f'), b'this') | |
|
818 | self.assertEqual(pm.visitchildrenset(b'd/e/f/g'), set()) | |
|
817 | 819 | |
|
818 | 820 | if __name__ == '__main__': |
|
819 | 821 | silenttestrunner.main(__name__) |
General Comments 0
You need to be logged in to leave comments.
Login now