def test_compile_options(self): compiler = AttrDict(flavor='gcc') with mock.patch('bfg9000.shell.execute', mock_execute): pkg = PkgConfigPackage('foo', 'elf', SpecifierSet(''), PackageKind.shared, self.tool) self.assertEqual(pkg.compile_options(compiler), opts.option_list(['-I/usr/include']))
def test_compile_options(self): compiler = AttrDict(flavor='gcc') with mock.patch('bfg9000.shell.execute', mock_execute): pkg = PkgConfigPackage(self.tool, 'foo', format='elf') header_dir = HeaderDirectory(Path('/usr/include')) self.assertEqual( pkg.compile_options(compiler), opts.option_list('-DMACRO', opts.include_dir(header_dir)))
def test_link_options_coff(self): linker = AttrDict(flavor='gcc', builder=AttrDict(object_format='coff')) with mock.patch('bfg9000.shell.execute', mock_execute): pkg = PkgConfigPackage('foo', 'elf', SpecifierSet(''), PackageKind.shared, self.tool) self.assertEqual( pkg.link_options(linker), opts.option_list('-L/usr/lib', opts.lib_literal('-lfoo')))
def test_link_options_coff(self): linker = AttrDict(flavor='gcc', builder=AttrDict(object_format='coff')) with mock.patch('bfg9000.shell.execute', mock_execute): pkg = PkgConfigPackage(self.tool, 'foo', format='elf') self.assertEqual( pkg.link_options(linker), opts.option_list('-pthread', opts.lib_dir(Directory(Path('/usr/lib'))), opts.lib_literal('-lfoo')))
def test_link_options_elf_uninst(self): linker = AttrDict(flavor='gcc', builder=AttrDict(object_format='elf')) with mock.patch('bfg9000.shell.execute', mock_execute_uninst): pkg = PkgConfigPackage('foo', 'elf', SpecifierSet(''), PackageKind.shared, self.tool) self.assertEqual( pkg.link_options(linker), opts.option_list( '-L/path/to/build/foo', opts.lib_literal('-lfoo'), opts.rpath_dir(Path('/path/to/build/foo'), 'uninstalled'), opts.rpath_dir(Path('/usr/lib'), 'installed')))
def test_link_options_static(self): linker = AttrDict(flavor='gcc') with mock.patch('bfg9000.shell.execute', mock_execute): pkg = PkgConfigPackage(self.tool, 'foo', format='elf', kind=PackageKind.static) self.assertEqual(pkg.static, True) self.assertEqual( pkg.link_options(linker), opts.option_list('-pthread', opts.lib_dir(Directory(Path('/usr/lib'))), opts.lib_literal('-lfoo'), opts.lib_literal('-lstatic')))
def test_link_options_macho_uninst(self): linker = AttrDict(flavor='gcc', builder=AttrDict(object_format='mach-o')) with mock.patch('bfg9000.shell.execute', mock_execute_uninst): pkg = PkgConfigPackage(self.tool, 'foo', format='elf') self.assertEqual( pkg.link_options(linker), opts.option_list( '-pthread', opts.lib_dir(Directory(Path('/path/to/build/foo'))), opts.lib_literal('-lfoo'), opts.install_name_change('/path/to/build/foo/libfoo.dylib', '/usr/lib/libfoo.dylib')))
def test_empty_version(self): def mock_execute_empty_version(args, **kwargs): if '--modversion' in args: return '\n' return mock_execute(args, **kwargs) with mock.patch('bfg9000.shell.execute', mock_execute_empty_version): pkg = PkgConfigPackage(self.tool, 'foo', format='elf') self.assertEqual(pkg.version, None)
def test_create(self): specifier = SpecifierSet('') with mock.patch('bfg9000.shell.execute', mock_execute): pkg = PkgConfigPackage('foo', 'elf', specifier, PackageKind.shared, self.tool) self.assertEqual(pkg.name, 'foo') self.assertEqual(pkg.format, 'elf') self.assertEqual(pkg.version, Version('1.0')) self.assertEqual(pkg.specifier, specifier) self.assertEqual(pkg.static, False)
def test_link_options_macho_requires(self): linker = AttrDict(flavor='gcc', builder=AttrDict(object_format='mach-o')) with mock.patch('bfg9000.shell.execute', mock_execute_requires): pkg = PkgConfigPackage('foo', 'elf', SpecifierSet(''), PackageKind.shared, self.tool) self.assertEqual( pkg.link_options(linker), opts.option_list( '-L/path/to/build/foo', opts.lib_literal('-lfoo'), opts.install_name_change('/path/to/build/foo/libfoo.dylib', '/usr/lib/libfoo.dylib'), opts.install_name_change('/path/to/build/bar/libbar.dylib', '/usr/lib/libbar.dylib'), opts.install_name_change('/path/to/build/baz/libbaz.dylib', '/usr/lib/libbaz.dylib'), ))