def test_link_symlink_to_dir(self): os.symlink('bar', os.path.join('foo', 'bar-link')) file_utils.link_or_copy_tree('foo', 'qux') # Verify that the symlink remains a symlink self.assertThat(os.path.join('qux', 'bar-link'), unit.LinkExists('bar'))
def test_link_symlink_to_dir(self): os.symlink("bar", os.path.join("foo", "bar-link")) file_utils.link_or_copy_tree("foo", "qux") # Verify that the symlink remains a symlink self.assertThat(os.path.join("qux", "bar-link"), unit.LinkExists("bar"))
def test_link_symlink_to_file(self): # Create a symlink to a file os.symlink('2', os.path.join('foo', '2-link')) file_utils.link_or_copy_tree('foo', 'qux') # Verify that the symlink remains a symlink self.assertThat(os.path.join('qux', '2-link'), unit.LinkExists('2'))
def test_link_symlink_to_file(self): # Create a symlink to a file os.symlink("2", os.path.join("foo", "2-link")) file_utils.link_or_copy_tree("foo", "qux") # Verify that the symlink remains a symlink self.assertThat(os.path.join("qux", "2-link"), unit.LinkExists("2"))
def test_pull_keeps_symlinks(self): # Create a source containing a directory, a file and symlinks to both. os.makedirs(os.path.join("src", "dir")) open(os.path.join("src", "dir", "file"), "w").close() os.symlink("dir", os.path.join("src", "dir_symlink")) os.symlink("file", os.path.join("src", "dir", "file_symlink")) local = sources.Local("src", "destination") local.pull() # Verify that both the file and the directory symlinks were kept. self.expectThat(os.path.join("destination", "dir"), DirExists()) self.expectThat(os.path.join("destination", "dir_symlink"), unit.LinkExists("dir")) self.expectThat(os.path.join("destination", "dir", "file"), FileExists()) self.expectThat(os.path.join("destination", "dir", "file_symlink"), unit.LinkExists("file"))
def test_pull_keeps_symlinks(self): # Create a source containing a directory, a file and symlinks to both. os.makedirs(os.path.join('src', 'dir')) open(os.path.join('src', 'dir', 'file'), 'w').close() os.symlink('dir', os.path.join('src', 'dir_symlink')) os.symlink('file', os.path.join('src', 'dir', 'file_symlink')) local = sources.Local('src', 'destination') local.pull() # Verify that both the file and the directory symlinks were kept. self.expectThat(os.path.join('destination', 'dir'), DirExists()) self.expectThat(os.path.join('destination', 'dir_symlink'), unit.LinkExists('dir')) self.expectThat(os.path.join('destination', 'dir', 'file'), FileExists()) self.expectThat(os.path.join('destination', 'dir', 'file_symlink'), unit.LinkExists('file'))
def test_dump_symlinks_to_libc(self): plugin = DumpPlugin('dump', self.options, self.project_options) os.makedirs(plugin.builddir) # Even though this symlink is absolute, since it's to libc the copy # plugin shouldn't try to follow it or modify it. libc_libs = snapcraft.repo.Repo.get_package_libraries('libc6') # We don't care which lib we're testing with, as long as it's a .so. libc_library_path = [lib for lib in libc_libs if '.so' in lib][0] os.symlink(libc_library_path, os.path.join(plugin.builddir, 'libc-link')) plugin.build() self.assertThat(os.path.join(plugin.installdir, 'libc-link'), unit.LinkExists(libc_library_path))
def test_copy_symlinks_to_libc(self): self.mock_options.files = {"*": "."} c = CopyPlugin("copy", self.mock_options, self.project_options) # These directories are created by the pluginhandler os.makedirs(c.builddir) # Even though this symlink is absolute, since it's to libc the copy # plugin shouldn't try to follow it or modify it. libc_libs = snapcraft.repo.Repo.get_package_libraries("libc6") # We don't care which lib we're testing with, as long as it's a .so. libc_library_path = [lib for lib in libc_libs if ".so" in lib][0] os.symlink(libc_library_path, os.path.join(c.builddir, "libc-link")) c.build() self.assertThat(os.path.join(c.installdir, "libc-link"), unit.LinkExists(libc_library_path))