예제 #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()
예제 #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
예제 #3
0
 def test_cross_compile(self):
     plugin = autotools.AutotoolsPlugin("test-part", self.options,
                                        self.project)
     plugin.enable_cross_compilation()
     plugin.build()
     self.run_mock.assert_has_calls([
         mock.call(
             ["./configure", "--prefix=", "--host={}".format(self.triplet)],
             cwd=mock.ANY,
         )
     ])
예제 #4
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
예제 #5
0
def test_cross_compile(mock_run, monkeypatch, project, options, deb_arch, triplet):
    monkeypatch.setattr(snapcraft.project.Project, "is_cross_compiling", True)

    project = snapcraft.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 = pathlib.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}"])]
    )
예제 #6
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
예제 #7
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)