Mercurial > public > mercurial-scm > hg
diff tests/test-manifest.py @ 43964:8f67735344ae
tests: convert the `root` arg of matchmod.match() to local path separators
This fixes tests that broke with 8b1a9ba375e5, complaining that "X not under
root /repo". The vast majority of real uses are to pass `repo.root`, which is
normalized by `wdirvfs.base` being set to the result of `os.path.realpath()`.
Failure to convert looks like this:
--- c:/Users/Matt/hg/tests/test-match.py.out
+++ c:/Users/Matt/hg/tests/test-match.py.err
@@ -0,0 +1,48 @@
+ERROR: testVisitchildrensetGlob (__main__.IncludeMatcherTests)
+
+Traceback (most recent call last):
+ File "c:\Users\Matt\hg\tests\test-match.py", line 180, in testVisitchildrensetGlob
+ m = matchmod.match(b'/repo', b'', include=[b'glob:dir/z*'])
+ File "c:\Users\Matt\hg\mercurial\match.py", line 271, in match
+ kindpats = normalize(include, b'glob', root, cwd, auditor, warn)
+ File "c:\Users\Matt\hg\mercurial\match.py", line 322, in _donormalize
+ pat = pathutil.canonpath(root, cwd, pat, auditor=auditor)
+ File "c:\Users\Matt\hg\mercurial\pathutil.py", line 251, in canonpath
+ _(b"%s not under root '%s'") % (myname, root), hint=hint
+Abort: dir/z* not under root '/repo'
+ERROR: testVisitdirGlob (__main__.IncludeMatcherTests)
Differential Revision: https://phab.mercurial-scm.org/D7724
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 26 Dec 2019 16:45:56 -0500 |
parents | 8b1a9ba375e5 |
children | 0bf3b5e80d30 |
line wrap: on
line diff
--- a/tests/test-manifest.py Fri Dec 27 16:47:47 2019 +0100 +++ b/tests/test-manifest.py Thu Dec 26 16:45:56 2019 -0500 @@ -9,6 +9,7 @@ from mercurial import ( manifest as manifestmod, match as matchmod, + util, ) EMTPY_MANIFEST = b'' @@ -169,7 +170,7 @@ m[b'foo'] = want + b'+' self.assertEqual(want, m[b'foo']) # make sure the suffix survives a copy - match = matchmod.match(b'/repo', b'', [b're:foo']) + match = matchmod.match(util.localpath(b'/repo'), b'', [b're:foo']) m2 = m.matches(match) self.assertEqual(want, m2[b'foo']) self.assertEqual(1, len(m2)) @@ -186,7 +187,7 @@ def testMatchException(self): m = self.parsemanifest(A_SHORT_MANIFEST) - match = matchmod.match(b'/repo', b'', [b're:.*']) + match = matchmod.match(util.localpath(b'/repo'), b'', [b're:.*']) def filt(path): if path == b'foo': @@ -328,7 +329,9 @@ actually exist.''' m = self.parsemanifest(A_DEEPER_MANIFEST) - match = matchmod.match(b'/repo', b'', [b'a/f'], default=b'relpath') + match = matchmod.match( + util.localpath(b'/repo'), b'', [b'a/f'], default=b'relpath' + ) m2 = m.matches(match) self.assertEqual([], m2.keys()) @@ -348,7 +351,7 @@ '''Tests matches() for what should be a full match.''' m = self.parsemanifest(A_DEEPER_MANIFEST) - match = matchmod.match(b'/repo', b'', [b'']) + match = matchmod.match(util.localpath(b'/repo'), b'', [b'']) m2 = m.matches(match) self.assertEqual(m.keys(), m2.keys()) @@ -358,7 +361,9 @@ match against all files within said directory.''' m = self.parsemanifest(A_DEEPER_MANIFEST) - match = matchmod.match(b'/repo', b'', [b'a/b'], default=b'relpath') + match = matchmod.match( + util.localpath(b'/repo'), b'', [b'a/b'], default=b'relpath' + ) m2 = m.matches(match) self.assertEqual( @@ -392,7 +397,9 @@ when not in the root directory.''' m = self.parsemanifest(A_DEEPER_MANIFEST) - match = matchmod.match(b'/repo', b'a/b', [b'.'], default=b'relpath') + match = matchmod.match( + util.localpath(b'/repo'), b'a/b', [b'.'], default=b'relpath' + ) m2 = m.matches(match) self.assertEqual( @@ -415,7 +422,7 @@ deeper than the specified directory.''' m = self.parsemanifest(A_DEEPER_MANIFEST) - match = matchmod.match(b'/repo', b'', [b'a/b/*/*.txt']) + match = matchmod.match(util.localpath(b'/repo'), b'', [b'a/b/*/*.txt']) m2 = m.matches(match) self.assertEqual( @@ -467,7 +474,7 @@ sorted(dirs), ) - match = matchmod.match(b'/repo', b'', [b'path:a/b/']) + match = matchmod.match(util.localpath(b'/repo'), b'', [b'path:a/b/']) dirs = [s._dir for s in m.walksubtrees(matcher=match)] self.assertEqual(sorted([b'a/b/', b'a/b/c/', b'a/b/d/']), sorted(dirs))