Beispiel #1
0
    def test_build_artifacts(self, link_or_copy_mock, link_or_copy_tree_mock,
                             run_mock):
        self.options.artifacts = ["dir_artifact", "file_artifact"]
        plugin = make.MakePlugin("test-part", self.options, self.project)

        os.makedirs(os.path.join(plugin.builddir, "dir_artifact"))

        plugin.build()

        self.assertThat(run_mock.call_count, Equals(1))
        run_mock.assert_has_calls([mock.call(["make", "-j2"], env=None)])
        self.assertThat(link_or_copy_mock.call_count, Equals(1))
        link_or_copy_mock.assert_has_calls([
            mock.call(
                os.path.join(plugin.builddir, "file_artifact"),
                os.path.join(plugin.installdir, "file_artifact"),
            )
        ])
        self.assertThat(link_or_copy_tree_mock.call_count, Equals(1))
        link_or_copy_tree_mock.assert_has_calls([
            mock.call(
                os.path.join(plugin.builddir, "dir_artifact"),
                os.path.join(plugin.installdir, "dir_artifact"),
            )
        ])
Beispiel #2
0
    def test_build_artifacts(self, link_or_copy_mock, link_or_copy_tree_mock,
                             run_mock):
        self.options.artifacts = ['dir_artifact', 'file_artifact']
        plugin = make.MakePlugin('test-part', self.options,
                                 self.project_options)

        os.makedirs(os.path.join(plugin.sourcedir, 'dir_artifact'))

        plugin.build()

        self.assertEqual(1, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['make', '-j2']),
        ])
        self.assertEqual(1, link_or_copy_mock.call_count)
        link_or_copy_mock.assert_has_calls([
            mock.call(
                os.path.join(plugin.builddir, 'file_artifact'),
                os.path.join(plugin.installdir, 'file_artifact'),
            )
        ])
        self.assertEqual(1, link_or_copy_tree_mock.call_count)
        link_or_copy_tree_mock.assert_has_calls([
            mock.call(
                os.path.join(plugin.builddir, 'dir_artifact'),
                os.path.join(plugin.installdir, 'dir_artifact'),
            )
        ])
Beispiel #3
0
    def test_build_empty_install_var(self, run_mock):
        self.options.make_install_var = ""
        plugin = make.MakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.assertThat(run_mock.call_count, Equals(2))
        run_mock.assert_has_calls([
            mock.call(["make", "-j2"], env=None),
            mock.call(["make", "install"], env=None),
        ])
Beispiel #4
0
    def test_build(self, run_mock):
        plugin = make.MakePlugin('test-part', self.options,
                                 self.project_options)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.assertEqual(2, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['make', '-j2']),
            mock.call(
                ['make', 'install', 'DESTDIR={}'.format(plugin.installdir)])
        ])
Beispiel #5
0
    def test_build_empty_install_var(self, run_mock):
        self.options.make_install_var = ''
        plugin = make.MakePlugin('test-part', self.options,
                                 self.project_options)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.assertThat(run_mock.call_count, Equals(2))
        run_mock.assert_has_calls([
            mock.call(['make', '-j2'], env=None),
            mock.call(['make', 'install'], env=None)
        ])
Beispiel #6
0
    def test_make_with_env(self, run_mock):
        plugin = make.MakePlugin('test-part', self.options,
                                 self.project_options)
        os.makedirs(plugin.sourcedir)

        env = {'foo': 'bar'}
        plugin.make(env=env)

        self.assertThat(run_mock.call_count, Equals(2))
        run_mock.assert_has_calls([
            mock.call(['make', '-j2'], env=env),
            mock.call(['make', 'install',
                       'DESTDIR={}'.format(plugin.installdir)], env=env)
        ])
Beispiel #7
0
    def test_build_makefile(self, run_mock):
        self.options.makefile = 'makefile.linux'
        plugin = make.MakePlugin('test-part', self.options,
                                 self.project_options)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.assertThat(run_mock.call_count, Equals(2))
        run_mock.assert_has_calls([
            mock.call(['make', '-f', 'makefile.linux', '-j2'], env=None),
            mock.call(['make', '-f', 'makefile.linux', 'install',
                       'DESTDIR={}'.format(plugin.installdir)], env=None)
        ])
Beispiel #8
0
    def test_build_disable_parallel(self, run_mock):
        self.options.disable_parallel = True
        plugin = make.MakePlugin('test-part', self.options,
                                 self.project_options)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.assertThat(run_mock.call_count, Equals(2))
        run_mock.assert_has_calls([
            mock.call(['make', '-j1'], env=None),
            mock.call(['make', 'install',
                       'DESTDIR={}'.format(plugin.installdir)], env=None)
        ])
Beispiel #9
0
    def test_make_with_env(self, run_mock):
        plugin = make.MakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.sourcedir)

        env = {"foo": "bar"}
        plugin.make(env=env)

        self.assertThat(run_mock.call_count, Equals(2))
        run_mock.assert_has_calls([
            mock.call(["make", "-j2"], env=env),
            mock.call(
                ["make", "install", "DESTDIR={}".format(plugin.installdir)],
                env=env),
        ])
Beispiel #10
0
    def test_build(self, run_mock):
        plugin = make.MakePlugin("test-part", self.options, self.project)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.assertThat(run_mock.call_count, Equals(2))
        run_mock.assert_has_calls([
            mock.call(["make", "-j2"], env=None),
            mock.call(
                ["make", "install", "DESTDIR={}".format(plugin.installdir)],
                env=None,
            ),
        ])
Beispiel #11
0
    def test_build_makefile(self, run_mock):
        self.options.makefile = 'makefile.linux'
        plugin = make.MakePlugin('test-part', self.options)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.get_parallel_build_count_mock.assert_called_with()

        self.assertEqual(2, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['make', '-f', 'makefile.linux', '-j2']),
            mock.call(['make', '-f', 'makefile.linux', 'install',
                       'DESTDIR={}'.format(plugin.installdir)])
        ])
Beispiel #12
0
    def test_build_install_var(self, run_mock):
        self.options.make_install_var = 'PREFIX'
        plugin = make.MakePlugin('test-part', self.options,
                                 self.project_options)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.assertEqual(2, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['make', '-j2'], env=None),
            mock.call(
                ['make', 'install', 'PREFIX={}'.format(plugin.installdir)],
                env=None)
        ])
    def test_build_artifacts(self, link_or_copy_mock, run_mock):
        self.options.artifacts = ['artifact1', 'artifact2']
        plugin = make.MakePlugin('test-part', self.options,
                                 self.project_options)
        os.makedirs(plugin.sourcedir)

        plugin.build()

        self.assertEqual(1, run_mock.call_count)
        run_mock.assert_has_calls([
            mock.call(['make', '-j2']),
        ])
        self.assertEqual(2, link_or_copy_mock.call_count)
        for artifact in self.options.artifacts:
            link_or_copy_mock.assert_has_calls([
                mock.call(
                    os.path.join(plugin.builddir, artifact),
                    os.path.join(plugin.installdir, artifact),
                )
            ])