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