summaryrefslogtreecommitdiffstats
path: root/tests/test_project.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-10 21:35:48 -0500
committerMike Frysinger <vapier@google.com>2020-02-11 04:23:26 +0000
commit07392ed32662006c029299bc06617310cfe17957 (patch)
tree844401eb75253096795c47689943164e840ffe8a /tests/test_project.py
parent3285e4b436b7f25563179f5bc7191074d3515698 (diff)
downloadgit-repo-07392ed32662006c029299bc06617310cfe17957.tar.gz
project: allow src=. with symlinksv2.1.1
Some Android/Nest manifests are using <linkfile> with src="." to create stable paths to specific projects. Allow that specific use case as it seems reasonable to support. Bug: https://crbug.com/gerrit/11218 Change-Id: I16dbe8d9fe42ea45440afcb61404c753bff1930d Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254330 Reviewed-by: Chanho Park <parkch98@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'tests/test_project.py')
-rw-r--r--tests/test_project.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_project.py b/tests/test_project.py
index 6d82da11..dc41f4c0 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -314,6 +314,14 @@ class LinkFile(CopyLinkTestCase):
314 lf._Link() 314 lf._Link()
315 self.assertExists(os.path.join(self.topdir, 'foo')) 315 self.assertExists(os.path.join(self.topdir, 'foo'))
316 316
317 def test_src_self(self):
318 """Link to the project itself."""
319 dest = os.path.join(self.topdir, 'foo', 'bar')
320 lf = self.LinkFile('.', 'foo/bar')
321 lf._Link()
322 self.assertExists(dest)
323 self.assertEqual('../git-project', os.readlink(dest))
324
317 def test_dest_subdir(self): 325 def test_dest_subdir(self):
318 """Link a file to a subdir of a checkout.""" 326 """Link a file to a subdir of a checkout."""
319 src = os.path.join(self.worktree, 'foo.txt') 327 src = os.path.join(self.worktree, 'foo.txt')
@@ -323,6 +331,21 @@ class LinkFile(CopyLinkTestCase):
323 lf._Link() 331 lf._Link()
324 self.assertExists(os.path.join(self.topdir, 'sub', 'dir', 'foo', 'bar')) 332 self.assertExists(os.path.join(self.topdir, 'sub', 'dir', 'foo', 'bar'))
325 333
334 def test_src_block_relative(self):
335 """Do not allow relative symlinks."""
336 BAD_SOURCES = (
337 './',
338 '..',
339 '../',
340 'foo/.',
341 'foo/./bar',
342 'foo/..',
343 'foo/../foo',
344 )
345 for src in BAD_SOURCES:
346 lf = self.LinkFile(src, 'foo')
347 self.assertRaises(error.ManifestInvalidPathError, lf._Link)
348
326 def test_update(self): 349 def test_update(self):
327 """Make sure changed targets get updated.""" 350 """Make sure changed targets get updated."""
328 dest = os.path.join(self.topdir, 'sym') 351 dest = os.path.join(self.topdir, 'sym')