Exemple #1
0
    def test_resolve(self):
        config = os.path.join(test_data_dir, 'mopack-tarball.yml')
        self.assertPopen(['mopack', 'resolve', config,
                          '-Pprefix=' + self.prefix])
        self.assertExists('mopack/src/hello/hello-bfg/build.bfg')
        self.assertExists('mopack/build/hello/')
        self.assertExists('mopack/logs/hello.log')
        self.assertExists('mopack/mopack.json')

        self.assertPkgConfigUsage('hello')
        self.check_list_files([config])

        output = json.loads(slurp('mopack/mopack.json'))
        self.assertEqual(output['metadata'], {
            'options': cfg_options(
                common={'deploy_paths': {'prefix': self.prefix}},
                bfg9000={}
            ),
            'packages': [
                cfg_tarball_pkg(
                    'hello', config,
                    path={'base': 'cfgdir', 'path': 'hello-bfg.tar.gz'},
                    guessed_srcdir='hello-bfg',
                    builder=cfg_bfg9000_builder('hello')
                ),
            ],
        })

        self.assertPopen(['mopack', 'deploy'])
        include_prefix = '' if platform_name() == 'windows' else 'include/'
        lib_prefix = '' if platform_name() == 'windows' else 'lib/'
        with pushd(self.prefix):
            self.assertExists(include_prefix + 'hello.hpp')
            self.assertExists(lib_prefix + 'pkgconfig/hello.pc')
Exemple #2
0
    def test_resolve(self):
        config = os.path.join(test_data_dir, 'mopack-git.yml')
        self.assertPopen(['mopack', 'resolve', config,
                          '-Pprefix=' + self.prefix])
        self.assertExists('mopack/src/bencodehpp/build.bfg')
        self.assertExists('mopack/build/bencodehpp/')
        self.assertExists('mopack/logs/bencodehpp.log')
        self.assertExists('mopack/mopack.json')

        self.assertPkgConfigUsage('bencodehpp')
        self.check_list_files([config])

        output = json.loads(slurp('mopack/mopack.json'))
        self.assertEqual(output['metadata'], {
            'options': cfg_options(
                common={'deploy_paths': {'prefix': self.prefix}},
                bfg9000={}
            ),
            'packages': [
                cfg_git_pkg(
                    'bencodehpp', config,
                    repository='https://github.com/jimporter/bencode.hpp.git',
                    rev=['tag', 'v0.2.1'],
                    builder=cfg_bfg9000_builder('bencodehpp'),
                ),
            ],
        })

        self.assertPopen(['mopack', 'deploy'])
        include_prefix = '' if platform_name() == 'windows' else 'include/'
        lib_prefix = '' if platform_name() == 'windows' else 'lib/'
        with pushd(self.prefix):
            self.assertExists(include_prefix + 'bencode.hpp')
            self.assertExists(lib_prefix + 'pkgconfig/bencodehpp.pc')
Exemple #3
0
    def test_resolve(self):
        config = os.path.join(test_data_dir, 'mopack-outer-cmake.yml')
        self.assertPopen(['mopack', 'resolve', config,
                          '-Pprefix=' + self.prefix])
        self.assertExists('mopack/build/greeter/')
        self.assertExists('mopack/logs/greeter.log')
        self.assertExists('mopack/build/hello/')
        self.assertExists('mopack/logs/hello.log')
        self.assertExists('mopack/mopack.json')

        include_path = [os.path.join(test_data_dir, 'greeter-cmake',
                                     'include')]
        library_path = [os.path.join(self.pkgbuilddir, 'greeter')]
        self.assertPathUsage('greeter', include_path=include_path,
                             library_path=library_path)

        self.assertPkgConfigUsage('hello')

        output = json.loads(slurp('mopack/mopack.json'))
        self.assertEqual(output['metadata'], {
            'options': cfg_options(
                common={'deploy_paths': {'prefix': self.prefix}},
                bfg9000={}, cmake={}
            ),
            'packages': [
                cfg_tarball_pkg(
                    'hello',
                    os.path.join(test_data_dir, 'greeter-cmake', 'mopack.yml'),
                    path={'base': 'cfgdir',
                          'path': os.path.join('..', 'hello-bfg.tar.gz')},
                    guessed_srcdir='hello-bfg',
                    builder=cfg_bfg9000_builder('hello'),
                ),
                cfg_directory_pkg(
                    'greeter', config,
                    path={'base': 'cfgdir', 'path': 'greeter-cmake'},
                    builder=cfg_cmake_builder(
                        'greeter',
                        usage=cfg_path_usage(
                            include_path=[{'base': 'srcdir',
                                           'path': 'include'}],
                            library_path=[{'base': 'builddir', 'path': ''}],
                            libraries=[{'type': 'guess', 'name': 'greeter'}],
                        )
                    )
                ),
            ],
        })

        self.assertPopen(['mopack', 'deploy'])
        include_prefix = '' if platform_name() == 'windows' else 'include/'
        lib_prefix = '' if platform_name() == 'windows' else 'lib/'
        with pushd(self.prefix):
            self.assertExists('include/greeter.hpp')
            self.assertExists(include_prefix + 'hello.hpp')
            self.assertExists(lib_prefix + 'pkgconfig/hello.pc')
Exemple #4
0
    def test_windows(self):
        def mock_execute(*args, **kwargs):
            raise OSError()

        with mock.patch('platform.system', return_value='Windows'), \
             mock.patch('subprocess.check_output', mock_execute):  # noqa:
            self.assertEqual(platforms.platform_name(), 'windows')
Exemple #5
0
    def test_resolve(self):
        want_tarball = platform_name() == 'windows'

        config = os.path.join(test_data_dir, 'mopack-conditional.yml')
        self.assertPopen(['mopack', 'resolve', config])
        self.assertExistence('mopack/src/hello/hello-bfg/build.bfg',
                             want_tarball)
        self.assertExists('mopack/build/hello/')
        self.assertExists('mopack/logs/hello.log')
        self.assertExists('mopack/mopack.json')

        self.assertPkgConfigUsage('hello')

        output = json.loads(slurp('mopack/mopack.json'))
        if want_tarball:
            hellopkg = {
                'name': 'hello',
                'config_file': config,
                'resolved': True,
                'source': 'tarball',
                '_version': 1,
                'submodules': None,
                'should_deploy': True,
                'builder': cfg_bfg9000_builder('hello'),
                'url': None,
                'path': {
                    'base': 'cfgdir',
                    'path': 'hello-bfg.tar.gz'
                },
                'files': [],
                'srcdir': None,
                'guessed_srcdir': 'hello-bfg',
                'patch': None,
            }
        else:
            hellopkg = {
                'name': 'hello',
                'config_file': config,
                'resolved': True,
                'source': 'directory',
                '_version': 1,
                'submodules': None,
                'should_deploy': True,
                'builder': cfg_bfg9000_builder('hello'),
                'path': {
                    'base': 'cfgdir',
                    'path': 'hello-bfg'
                },
            }
        self.assertEqual(output['metadata'], {
            'options': cfg_options(bfg9000={}),
            'packages': [hellopkg],
        })
Exemple #6
0
 def test_unknown(self):
     with mock.patch('platform.system', return_value='Goofy'):
         self.assertEqual(platforms.platform_name(), 'goofy')
Exemple #7
0
 def test_cygwin_native_python(self):
     with mock.patch('platform.system', return_value='Windows'), \
          mock.patch('subprocess.check_output',
                     return_value='CYGWIN_NT-6.1-WOW64'):  # noqa
         self.assertEqual(platforms.platform_name(), 'cygwin')
Exemple #8
0
 def test_cygwin(self):
     with mock.patch('platform.system', return_value='CYGWIN_NT-6.1-WOW64'):
         self.assertEqual(platforms.platform_name(), 'cygwin')
Exemple #9
0
 def test_windows_with_uname(self):
     with mock.patch('platform.system', return_value='Windows'), \
          mock.patch('subprocess.check_output',
                     return_value='foobar'):  # noqa:
         self.assertEqual(platforms.platform_name(), 'windows')
Exemple #10
0
 def test_macos(self):
     with mock.patch('platform.system', return_value='Darwin'):
         self.assertEqual(platforms.platform_name(), 'darwin')
Exemple #11
0
 def test_linux(self):
     with mock.patch('platform.system', return_value='Linux'):
         self.assertEqual(platforms.platform_name(), 'linux')
    def test_resolve(self):
        config = os.path.join(test_data_dir, 'mopack-custom-builder.yml')
        self.assertPopen(
            ['mopack', 'resolve', config, '-Pprefix=' + self.prefix])
        self.assertExists('mopack/src/hello/hello-bfg/build.bfg')
        self.assertExists('mopack/build/hello/')
        self.assertExists('mopack/logs/hello.log')
        self.assertExists('mopack/mopack.json')

        self.assertPkgConfigUsage('hello')

        output = json.loads(slurp('mopack/mopack.json'))
        self.assertEqual(
            output['metadata'], {
                'options':
                cfg_options(common={'deploy_paths': {
                    'prefix': self.prefix
                }}),
                'packages': [
                    cfg_tarball_pkg(
                        'hello',
                        config,
                        path={
                            'base': 'cfgdir',
                            'path': 'hello-bfg.tar.gz'
                        },
                        guessed_srcdir='hello-bfg',
                        builder=cfg_custom_builder(
                            'hello',
                            build_commands=[
                                [
                                    'bfg9000', 'configure', {
                                        'base': 'builddir',
                                        'path': ''
                                    },
                                    [
                                        '--prefix=', {
                                            'base': 'absolute',
                                            'path': self.prefix
                                        }
                                    ]
                                ],
                                [
                                    'cd',
                                    [{
                                        'base': 'builddir',
                                        'path': ''
                                    }, '/.']
                                ],
                                ['ninja'],
                            ],
                            deploy_commands=[
                                ['ninja', 'install'],
                            ],
                            usage=cfg_pkg_config_usage(pcfile='hello'))),
                ],
            })

        self.assertPopen(['mopack', '--debug', 'deploy'])
        include_prefix = '' if platform_name() == 'windows' else 'include/'
        lib_prefix = '' if platform_name() == 'windows' else 'lib/'
        with pushd(self.prefix):
            self.assertExists(include_prefix + 'hello.hpp')
            self.assertExists(lib_prefix + 'pkgconfig/hello.pc')