Example #1
0
    def test_build_nonexecutable_autogen(self, stdout_mock):
        plugin = autotools.AutotoolsPlugin("test-part", self.options,
                                           self.project)
        os.makedirs(plugin.sourcedir)

        # Make a non-executable autogen.sh
        with open(os.path.join(plugin.sourcedir, "autogen.sh"), "w") as f:
            f.write("#!/bin/sh")

        patcher = mock.patch.object(autotools.AutotoolsPlugin, "run")
        run_mock = patcher.start()

        # We want to mock out every run() call except the one to autogen
        def _run(cmd, env=None):
            if "./autogen.sh" in cmd:
                patcher.stop()
                output = plugin.run(cmd, env=env)
                patcher.start()
                return output

        run_mock.side_effect = _run

        # An exception will be raised if build can't handle the non-executable
        # autogen.
        plugin.build()
Example #2
0
    def build_with_autoreconf(self):
        plugin = autotools.AutotoolsPlugin("test-part", self.options,
                                           self.project)
        os.makedirs(plugin.sourcedir)

        # No configure or autogen.sh.

        plugin.build()

        return plugin
Example #3
0
    def build_with_configure(self):
        plugin = autotools.AutotoolsPlugin("test-part", self.options,
                                           self.project)
        os.makedirs(plugin.builddir)

        # Create both configure and autogen.sh.
        # Configure should take precedence.
        open(os.path.join(plugin.builddir, "configure"), "w").close()
        open(os.path.join(plugin.builddir, "autogen.sh"), "w").close()

        plugin.build()

        return plugin
Example #4
0
def test_cross_compile(mock_run, monkeypatch, project, options, deb_arch,
                       triplet):
    monkeypatch.setattr(snapcraft_legacy.project.Project, "is_cross_compiling",
                        True)

    project = snapcraft_legacy.project.Project(target_deb_arch=deb_arch)
    project._snap_meta = meta.snap.Snap(name="test-snap", base="core18")

    plugin = autotools.AutotoolsPlugin("test-part", options, project)
    plugin.enable_cross_compilation()
    configure_file = Path(plugin.builddir) / "configure"
    configure_file.parent.mkdir(parents=True)
    configure_file.touch()

    plugin.build()

    mock_run.assert_has_calls(
        [mock.call(["./configure", "--prefix=", f"--host={triplet}"])])
Example #5
0
    def build_with_autogen(self, files=None, dirs=None):
        plugin = autotools.AutotoolsPlugin("test-part", self.options,
                                           self.project)
        os.makedirs(plugin.builddir)

        if not files:
            files = ["autogen.sh"]
        if not dirs:
            dirs = []

        # No configure-- only autogen.sh. Make sure it's executable.
        for filename in files:
            open(os.path.join(plugin.builddir, filename), "w").close()
            os.chmod(
                os.path.join(plugin.builddir, filename),
                stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR,
            )
        for directory in dirs:
            os.makedirs(os.path.join(plugin.builddir, directory))

        plugin.build()

        return plugin
Example #6
0
 def test_fileset_ignores(self):
     plugin = autotools.AutotoolsPlugin("test-part", self.options,
                                        self.project)
     expected_fileset = ["-**/*.la"]
     fileset = plugin.snap_fileset()
     self.assertListEqual(expected_fileset, fileset)