Exemplo n.º 1
0
    def test_build_referencing_sourcedir_with_subdir(self):
        self.options.source_subdir = "subdir"

        plugin = cmake.CMakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.builddir)
        plugin.build()

        sourcedir = os.path.join(plugin.sourcedir,
                                 plugin.options.source_subdir)
        self.run_mock.assert_has_calls([
            mock.call(
                ["cmake", sourcedir, "-DCMAKE_INSTALL_PREFIX="],
                cwd=plugin.builddir,
                env=mock.ANY,
            ),
            mock.call(
                ["cmake", "--build", ".", "--", "-j2"],
                cwd=plugin.builddir,
                env=mock.ANY,
            ),
            mock.call(
                ["cmake", "--build", ".", "--target", "install"],
                cwd=plugin.builddir,
                env=mock.ANY,
            ),
        ])
Exemplo n.º 2
0
    def test_build_environment(self):
        plugin = cmake.CMakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.builddir)
        plugin.build()

        expected = {}

        expected["DESTDIR"] = plugin.installdir
        expected["CMAKE_PREFIX_PATH"] = "$CMAKE_PREFIX_PATH:{}".format(
            self.stage_dir)
        expected["CMAKE_INCLUDE_PATH"] = "$CMAKE_INCLUDE_PATH:" + ":".join([
            "{0}/include", "{0}/usr/include", "{0}/include/{1}",
            "{0}/usr/include/{1}"
        ]).format(self.stage_dir, plugin.project.arch_triplet)
        expected["CMAKE_LIBRARY_PATH"] = "$CMAKE_LIBRARY_PATH:" + ":".join([
            "{0}/lib", "{0}/usr/lib", "{0}/lib/{1}", "{0}/usr/lib/{1}"
        ]).format(self.stage_dir, plugin.project.arch_triplet)

        self.assertThat(self.run_mock.call_count, Equals(3))
        for call_args in self.run_mock.call_args_list:
            environment = call_args[1]["env"]
            for variable, value in expected.items():
                self.assertTrue(
                    variable in environment,
                    'Expected variable "{}" to be in environment'.format(
                        variable),
                )

                self.assertThat(
                    environment[variable],
                    Equals(value),
                    "Expected ${}={}, but it was {}".format(
                        variable, value, environment[variable]),
                )
Exemplo n.º 3
0
    def test_build_disable_parallel(self):
        self.options.disable_parallel = True

        plugin = cmake.CMakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.builddir)
        plugin.build()

        self.run_mock.assert_has_calls([
            mock.call(
                ["cmake", "--build", ".", "--", "-j1"],
                cwd=plugin.builddir,
                env=mock.ANY,
            )
        ])
Exemplo n.º 4
0
    def test_build(self, project, mock_run, snaps, expected_configflags):
        class Options:
            configflags = []
            source_subdir = None

            make_parameters = []
            disable_parallel = False
            build_snaps = snaps

        plugin = cmake.CMakePlugin("test-part", Options(), project)
        os.makedirs(plugin.builddir)
        plugin.build()

        mock_run.assert_has_calls([
            mock.call(
                ["cmake", plugin.sourcedir, "-DCMAKE_INSTALL_PREFIX="] +
                expected_configflags,
                env=mock.ANY,
            ),
            mock.call(["cmake", "--build", ".", "--", "-j2"], env=mock.ANY),
            mock.call(["cmake", "--build", ".", "--target", "install"],
                      env=mock.ANY),
        ])