示例#1
0
    def test_build_environment(self):
        plugin = cmake.CMakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.builddir)
        plugin.build()

        expected = {}

        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]),
                )
示例#2
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,
            ),
        ])
示例#3
0
    def test_build_environment(self):
        plugin = cmake.CMakePlugin('test-part', self.options,
                                   self.project_options)
        os.makedirs(plugin.builddir)
        plugin.build()

        expected = {}

        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.assertEqual(3, self.run_mock.call_count)
        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.assertEqual(
                    environment[variable], value,
                    'Expected ${}={}, but it was {}'.format(
                        variable, value, environment[variable]))
示例#4
0
    def test_build_referencing_sourcedir_if_no_subdir(self):
        plugin = cmake.CMakePlugin('test-part', self.options,
                                   self.project_options)
        os.makedirs(plugin.builddir)
        plugin.build()

        self.run_mock.assert_has_calls([
            mock.call(['cmake', plugin.sourcedir, '-DCMAKE_INSTALL_PREFIX='],
                      cwd=plugin.builddir, env=mock.ANY),
            mock.call(['make', '-j2'], cwd=plugin.builddir, env=mock.ANY),
            mock.call(['make', 'install',
                       'DESTDIR={}'.format(plugin.installdir)],
                      cwd=plugin.builddir, env=mock.ANY)])
示例#5
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,
            )
        ])
示例#6
0
    def test_build_referencing_sourcedir_if_no_subdir(self):
        class Options:
            configflags = []

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

        self.run_mock.assert_has_calls([
            mock.call(['cmake', plugin.sourcedir, '-DCMAKE_INSTALL_PREFIX='],
                      cwd=plugin.builddir),
            mock.call(
                ['make', 'install', 'DESTDIR={}'.format(plugin.installdir)],
                cwd=plugin.builddir)
        ])
示例#7
0
    def test_build_referencing_sourcedir_if_no_subdir(self):
        plugin = cmake.CMakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.builddir)
        plugin.build()

        self.run_mock.assert_has_calls([
            mock.call(
                ["cmake", plugin.sourcedir, "-DCMAKE_INSTALL_PREFIX="],
                cwd=plugin.builddir,
                env=mock.ANY,
            ),
            mock.call(["make", "-j2"], cwd=plugin.builddir, env=mock.ANY),
            mock.call(
                ["make", "install", "DESTDIR={}".format(plugin.installdir)],
                cwd=plugin.builddir,
                env=mock.ANY,
            ),
        ])
示例#8
0
    def test_build_referencing_sourcedir_with_subdir(self):
        class Options:
            configflags = []
            source_subdir = 'subdir'

        plugin = cmake.CMakePlugin('test-part', Options(),
                                   self.project_options)
        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(['make', '-j2'], cwd=plugin.builddir, env=mock.ANY),
            mock.call(
                ['make', 'install', 'DESTDIR={}'.format(plugin.installdir)],
                cwd=plugin.builddir,
                env=mock.ANY)
        ])
示例#9
0
    def test_build(self):
        plugin = cmake.CMakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.builddir)
        plugin.build()

        self.run_mock.assert_has_calls([
            mock.call(
                ["cmake", plugin.sourcedir, "-DCMAKE_INSTALL_PREFIX="] +
                self.expected_configflags,
                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,
            ),
        ])