Esempio n. 1
0
    def test_usage_full(self):
        builder = self.make_builder('foo',
                                    build_commands=['make'],
                                    usage={
                                        'type': 'pkg_config',
                                        'path': 'pkgconf'
                                    })
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.build_commands, [
            ShellArguments(['make']),
        ])
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           path='pkgconf',
                           submodules=None,
                           _options=self.make_options(),
                           _path_bases=self.path_bases))

        self.check_build(builder,
                         usage={
                             'type': 'pkg_config',
                             'path': self.pkgconfdir('foo', 'pkgconf'),
                             'pcfiles': ['foo'],
                             'extra_args': [],
                         })
Esempio n. 2
0
    def test_deploy(self):
        builder = self.make_builder('foo',
                                    build_commands=['make'],
                                    deploy_commands=['make install'],
                                    usage='pkg_config')
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.build_commands, [
            ShellArguments(['make']),
        ])
        self.assertEqual(builder.deploy_commands, [
            ShellArguments(['make', 'install']),
        ])
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           submodules=None,
                           _options=self.make_options(),
                           _path_bases=self.path_bases))

        self.check_build(builder)

        with mock_open_log() as mopen, \
             mock.patch('mopack.builders.custom.pushd'), \
             mock.patch('subprocess.run') as mcall:  # noqa
            builder.deploy(self.pkgdir, self.srcdir)
            mopen.assert_called_with(
                os.path.join(self.pkgdir, 'logs', 'deploy', 'foo.log'), 'a')
            mcall.assert_called_with(['make', 'install'],
                                     stdout=subprocess.PIPE,
                                     stderr=subprocess.STDOUT,
                                     universal_newlines=True,
                                     check=True)
Esempio n. 3
0
    def test_cd(self):
        opts = self.make_options()

        builder = self.make_builder('foo',
                                    build_commands=[
                                        'configure $srcdir/build',
                                        'cd $builddir',
                                        'make',
                                    ],
                                    usage='pkg_config')
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.build_commands, [
            ShellArguments(['configure', (Path('srcdir', ''), '/build')]),
            ShellArguments(['cd', Path('builddir', '')]),
            ShellArguments(['make']),
        ])
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           submodules=None,
                           _options=opts,
                           _path_bases=self.path_bases))

        with mock.patch('os.chdir') as mcd:
            builddir = os.path.join(self.pkgdir, 'build', 'foo')
            self.check_build(builder,
                             build_commands=[
                                 ['configure', self.srcdir + '/build'],
                                 ['make'],
                             ])
            mcd.assert_called_once_with(builddir)
Esempio n. 4
0
    def test_path_objects(self):
        opts = self.make_options()

        builder = self.make_builder('foo',
                                    build_commands=[
                                        'configure $srcdir/build',
                                        ['make', '-C', '$builddir'],
                                    ],
                                    usage='pkg_config')
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.build_commands, [
            ShellArguments(['configure', (Path('srcdir', ''), '/build')]),
            ShellArguments(['make', '-C', Path('builddir', '')]),
        ])
        self.assertEqual(builder.deploy_commands, [])
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           submodules=None,
                           _options=opts,
                           _path_bases=self.path_bases))

        self.check_build(
            builder,
            build_commands=[
                ['configure', self.srcdir + '/build'],
                ['make', '-C',
                 os.path.join(self.pkgdir, 'build', 'foo')],
            ])
Esempio n. 5
0
    def test_usage_str(self):
        builder = self.make_builder('foo', usage='pkg_config')
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.extra_args, ShellArguments())
        self.assertEqual(builder.usage, PkgConfigUsage(
            'foo', submodules=None, _options=self.make_options(),
            _path_bases=self.path_bases
        ))

        self.check_build(builder)
Esempio n. 6
0
    def test_extra_args(self):
        builder = self.make_builder('foo', extra_args='--extra args')
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.extra_args,
                         ShellArguments(['--extra', 'args']))
        self.assertEqual(builder.usage, PkgConfigUsage(
            'foo', submodules=None, _options=self.make_options(),
            _path_bases=self.path_bases
        ))

        self.check_build(builder, extra_args=['--extra', 'args'])
Esempio n. 7
0
    def test_deploy_paths(self):
        deploy_paths = {'prefix': '/usr/local', 'goofy': '/foo/bar'}
        builder = self.make_builder('foo', deploy_paths=deploy_paths)
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.extra_args, ShellArguments())
        self.assertEqual(builder.usage, PkgConfigUsage(
            'foo', submodules=None, _options=self.make_options(),
            _path_bases=self.path_bases
        ))

        self.check_build(builder, extra_args=['--prefix', '/usr/local'])
Esempio n. 8
0
    def test_toolchain(self):
        builder = self.make_builder('foo', this_options={
            'toolchain': 'toolchain.bfg'
        })
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.extra_args, ShellArguments())
        self.assertEqual(builder.usage, PkgConfigUsage(
            'foo', submodules=None, _options=self.make_options(),
            _path_bases=self.path_bases
        ))

        self.check_build(builder, extra_args=[
            '--toolchain', os.path.join(self.config_dir, 'toolchain.bfg')
        ])
Esempio n. 9
0
    def test_basic(self):
        builder = self.make_builder('foo', usage='pkg_config')
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           submodules=None,
                           _options=self.make_options(),
                           _path_bases=self.path_bases))

        self.check_build(builder)

        with mock.patch('subprocess.run') as mcall:
            builder.deploy(self.pkgdir, self.srcdir)
            mcall.assert_not_called()
Esempio n. 10
0
    def test_basic(self):
        builder = self.make_builder('foo',
                                    build_commands=['configure', 'make'],
                                    usage='pkg_config')
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.build_commands, [
            ShellArguments(['configure']),
            ShellArguments(['make']),
        ])
        self.assertEqual(builder.deploy_commands, [])
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           submodules=None,
                           _options=self.make_options(),
                           _path_bases=self.path_bases))

        self.check_build(builder)
Esempio n. 11
0
    def test_usage_full(self):
        usage = {'type': 'pkg_config', 'path': 'pkgconf'}
        builder = self.make_builder('foo', usage=usage)
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           path='pkgconf',
                           submodules=None,
                           _options=self.make_options(),
                           _path_bases=self.path_bases))

        self.check_build(builder,
                         usage={
                             'type': 'pkg_config',
                             'path': self.pkgconfdir('foo', 'pkgconf'),
                             'pcfiles': ['foo'],
                             'extra_args': [],
                         })
Esempio n. 12
0
    def test_deploy_paths(self):
        deploy_paths = {'prefix': '/usr/local', 'goofy': '/foo/bar'}
        builder = self.make_builder('foo',
                                    usage='pkg_config',
                                    deploy_paths=deploy_paths)
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.extra_args, ShellArguments())
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           submodules=None,
                           _options=self.make_options(),
                           _path_bases=self.path_bases))

        self.check_build(builder,
                         extra_args=[
                             '-DCMAKE_INSTALL_PREFIX:PATH=' +
                             os.path.abspath('/usr/local')
                         ])
Esempio n. 13
0
    def test_toolchain(self):
        builder = self.make_builder(
            'foo',
            usage={'type': 'pkg_config'},
            this_options={'toolchain': 'toolchain.cmake'})
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.extra_args, ShellArguments())
        self.assertEqual(
            builder.usage,
            PkgConfigUsage('foo',
                           submodules=None,
                           _options=self.make_options(),
                           _path_bases=self.path_bases))

        self.check_build(builder,
                         extra_args=[
                             '-DCMAKE_TOOLCHAIN_FILE=' +
                             os.path.join(self.config_dir, 'toolchain.cmake')
                         ])
Esempio n. 14
0
    def test_rehydrate(self):
        opts = self.make_options()
        path_bases = ('srcdir', 'builddir')
        usage = PkgConfigUsage('foo',
                               submodules=None,
                               _options=opts,
                               _path_bases=path_bases)
        data = through_json(usage.dehydrate())
        self.assertEqual(usage, Usage.rehydrate(data, _options=opts))

        usage = PkgConfigUsage('foo',
                               submodules=None,
                               extra_args=['foo'],
                               _options=opts,
                               _path_bases=path_bases)
        data = through_json(usage.dehydrate())
        self.assertEqual(usage, Usage.rehydrate(data, _options=opts))
Esempio n. 15
0
    def test_basic(self):
        builder = self.make_builder('foo')
        self.assertEqual(builder.name, 'foo')
        self.assertEqual(builder.extra_args, ShellArguments())
        self.assertEqual(builder.usage, PkgConfigUsage(
            'foo', submodules=None, _options=self.make_options(),
            _path_bases=self.path_bases
        ))

        self.check_build(builder)

        with mock_open_log() as mopen, \
             mock.patch('mopack.builders.bfg9000.pushd'), \
             mock.patch('subprocess.run') as mcall:  # noqa
            builder.deploy(self.pkgdir, self.srcdir)
            mopen.assert_called_with(os.path.join(
                self.pkgdir, 'logs', 'deploy', 'foo.log'
            ), 'a')
            mcall.assert_called_with(
                ['ninja', 'install'], stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT, universal_newlines=True,
                check=True
            )