Esempio n. 1
0
    def test_common_prefix_stripping(self):
        class Options:
            source = os.path.join('src', 'test.tar')
            destination = 'destdir1'

        # create tar file for testing
        os.makedirs('src/test_prefix')
        file_to_tar = os.path.join('src', 'test_prefix', 'test.txt')
        open(file_to_tar, 'w').close()
        tar = tarfile.open(os.path.join('src', 'test.tar'), 'w')
        tar.add(file_to_tar)
        tar.close()

        t = TarContentPlugin('tar_content', Options(),
                             self.project_options)
        os.mkdir(t.sourcedir)
        t.pull()
        t.build()

        # the 'test_prefix' part of the path should have been removed
        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, 'destdir1')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/test.txt')))
Esempio n. 2
0
    def test_install_destination_dir_exists(self):
        class Options:
            destination = "destdir1"

        t = TarContentPlugin("tar_content", Options(), self.project_options)
        open(os.path.join(t.build_basedir, "test.txt"), "w").close()
        t.build()

        self.assertTrue(os.path.exists(os.path.join(self.install_prefix, "destdir1")))
        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, "destdir1/test.txt"))
        )
Esempio n. 3
0
    def test_install_destination_dir_exists(self):
        class Options:
            destination = "destdir1"

        t = TarContentPlugin("tar_content", Options(), self.project_options)
        open(os.path.join(t.build_basedir, "test.txt"), "w").close()
        t.build()

        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, "destdir1")))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, "destdir1/test.txt")))
Esempio n. 4
0
    def test_install_destination_dir_exists(self):
        class Options:
            destination = 'destdir1'

        t = TarContentPlugin('tar_content', Options(), self.project_options)
        open(os.path.join(t.build_basedir, 'test.txt'), 'w').close()
        t.build()

        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, 'destdir1')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/test.txt')))
Esempio n. 5
0
    def test_install_destination_dir_exists(self):
        class Options:
            destination = 'destdir1'

        t = TarContentPlugin('tar_content', Options(),
                             self.project_options)
        open(os.path.join(t.build_basedir, 'test.txt'), 'w').close()
        t.build()

        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, 'destdir1')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/test.txt')))
    def test_install_destination_dir_exists(self):
        class Options:
            source = os.path.join("src", "test.tar")
            destination = "destdir1"

        # create tar file for testing
        os.mkdir("src")
        file_to_tar = os.path.join("src", "test.txt")
        open(file_to_tar, "w").close()
        tar = tarfile.open(os.path.join("src", "test.tar"), "w")
        tar.add(file_to_tar)
        tar.close()

        t = TarContentPlugin("tar_content", Options())
        t.build()

        self.assertTrue(os.path.exists(os.path.join(self.install_prefix, "destdir1")))
        self.assertTrue(os.path.exists(os.path.join(self.install_prefix, "destdir1/test.txt")))
Esempio n. 7
0
    def test_common_prefix_stripping_symlink(self):
        class Options:
            source = os.path.join('src', 'test.tar')
            destination = 'destdir1'

        # create tar file for testing
        os.makedirs('src/test_prefix')
        file_to_tar = os.path.join('src', 'test_prefix', 'test.txt')
        open(file_to_tar, 'w').close()

        file_to_link = os.path.join('src', 'test_prefix', 'link.txt')
        os.symlink("./test.txt", file_to_link)
        self.assertTrue(os.path.islink(file_to_link))

        def check_for_symlink(tarinfo):
            self.assertTrue(tarinfo.issym())
            self.assertEqual(file_to_link, tarinfo.name)
            self.assertEqual(
                file_to_tar,
                os.path.normpath(
                    os.path.join(os.path.dirname(file_to_tar),
                                 tarinfo.linkname)))
            return tarinfo

        tar = tarfile.open(os.path.join('src', 'test.tar'), 'w')
        tar.add(file_to_tar)
        tar.add(file_to_link, filter=check_for_symlink)
        tar.close()

        t = TarContentPlugin('tar_content', Options(), self.project_options)
        os.mkdir(t.sourcedir)
        t.pull()
        t.build()

        # the 'test_prefix' part of the path should have been removed
        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, 'destdir1')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/test.txt')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/link.txt')))
Esempio n. 8
0
    def test_common_prefix_stripping_symlink(self):
        class Options:
            source = os.path.join('src', 'test.tar')
            destination = 'destdir1'

        # create tar file for testing
        os.makedirs('src/test_prefix')
        file_to_tar = os.path.join('src', 'test_prefix', 'test.txt')
        open(file_to_tar, 'w').close()

        file_to_link = os.path.join('src', 'test_prefix', 'link.txt')
        os.symlink("./test.txt", file_to_link)
        self.assertTrue(os.path.islink(file_to_link))

        def check_for_symlink(tarinfo):
            self.assertTrue(tarinfo.issym())
            self.assertEqual(file_to_link, tarinfo.name)
            self.assertEqual(file_to_tar, os.path.normpath(
                os.path.join(
                    os.path.dirname(file_to_tar), tarinfo.linkname)))
            return tarinfo

        tar = tarfile.open(os.path.join('src', 'test.tar'), 'w')
        tar.add(file_to_tar)
        tar.add(file_to_link, filter=check_for_symlink)
        tar.close()

        t = TarContentPlugin('tar_content', Options(),
                             self.project_options)
        os.mkdir(t.sourcedir)
        t.pull()
        t.build()

        # the 'test_prefix' part of the path should have been removed
        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, 'destdir1')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/test.txt')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/link.txt')))
    def test_install_destination_dir_exists(self):
        class Options:
            source = os.path.join('src', 'test.tar')
            destination = 'destdir1'

        # create tar file for testing
        os.mkdir('src')
        file_to_tar = os.path.join('src', 'test.txt')
        open(file_to_tar, 'w').close()
        tar = tarfile.open(os.path.join('src', 'test.tar'), "w")
        tar.add(file_to_tar)
        tar.close()

        t = TarContentPlugin('tar_content', Options())
        t.build()

        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, 'destdir1')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/test.txt')))
Esempio n. 10
0
    def test_install_destination_dir_exists(self):
        class Options:
            source = os.path.join('src', 'test.tar')
            destination = 'destdir1'

        # create tar file for testing
        os.mkdir('src')
        file_to_tar = os.path.join('src', 'test.txt')
        open(file_to_tar, 'w').close()
        tar = tarfile.open(os.path.join('src', 'test.tar'), 'w')
        tar.add(file_to_tar)
        tar.close()

        t = TarContentPlugin('tar_content', Options(),
                             self.project_options)
        os.mkdir(t.sourcedir)
        t.pull()
        t.build()

        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, 'destdir1')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/test.txt')))
Esempio n. 11
0
    def test_common_prefix_stripping(self):
        class Options:
            source = os.path.join('src', 'test.tar')
            destination = 'destdir1'

        # create tar file for testing
        os.makedirs('src/test_prefix')
        file_to_tar = os.path.join('src', 'test_prefix', 'test.txt')
        open(file_to_tar, 'w').close()
        tar = tarfile.open(os.path.join('src', 'test.tar'), 'w')
        tar.add(file_to_tar)
        tar.close()

        t = TarContentPlugin('tar_content', Options(), self.project_options)
        os.mkdir(t.sourcedir)
        t.pull()
        t.build()

        # the 'test_prefix' part of the path should have been removed
        self.assertTrue(
            os.path.exists(os.path.join(self.install_prefix, 'destdir1')))
        self.assertTrue(
            os.path.exists(
                os.path.join(self.install_prefix, 'destdir1/test.txt')))