def test_equality(self): self.assertTrue(self.Path('a', path.Root.srcdir) == self.Path('a', path.Root.srcdir)) self.assertFalse(self.Path('a', path.Root.srcdir) != self.Path('a', path.Root.srcdir)) self.assertTrue(self.Path('a', path.InstallRoot.bindir, True) == self.Path('a', path.InstallRoot.bindir, True)) self.assertFalse(self.Path('a', path.InstallRoot.bindir, True) != self.Path('a', path.InstallRoot.bindir, True)) self.assertTrue(self.Path('a', path.Root.srcdir) == self.Path('a/', path.Root.srcdir)) self.assertFalse(self.Path('a', path.Root.srcdir) != self.Path('a/', path.Root.srcdir)) self.assertFalse(self.Path('a', path.Root.srcdir) == self.Path('a', path.Root.builddir)) self.assertTrue(self.Path('a', path.Root.srcdir) != self.Path('a', path.Root.builddir)) self.assertFalse(self.Path('a', path.Root.srcdir) == self.Path('b', path.Root.srcdir)) self.assertTrue(self.Path('a', path.Root.srcdir) != self.Path('b', path.Root.srcdir)) self.assertFalse(self.Path('a', path.InstallRoot.bindir, True) == self.Path('a', path.InstallRoot.bindir, False)) self.assertTrue(self.Path('a', path.InstallRoot.bindir, True) != self.Path('a', path.InstallRoot.bindir, False)) winpath = target.platform_info('winnt').Path linuxpath = target.platform_info('linux').Path self.assertFalse(winpath('a') == linuxpath('a')) self.assertTrue(winpath('a') != linuxpath('a')) self.assertFalse(self.Path('a', path.Root.srcdir) == 'a') self.assertTrue(self.Path('a', path.Root.srcdir) != 'a')
def test_cygwin(self): platform = target.platform_info('cygwin') self.assertEqual(platform.name, 'cygwin') self.assertEqual(platform.flavor, 'posix') windows = target.platform_info('cygwin') posix = target.platform_info('linux') for i in ('object_format', 'executable_ext', 'shared_library_ext', 'has_import_library', 'has_versioned_library'): self.assertEqual(getattr(platform, i), getattr(windows, i)) for i in ('has_frameworks', 'install_dirs'): self.assertEqual(getattr(platform, i), getattr(posix, i))
def test_cygwin(self): with mock.patch('platform.machine', return_value='x86_64'): platform = target.platform_info('cygwin') self.assertEqual(platform.name, 'cygwin') self.assertEqual(platform.species, 'cygwin') self.assertEqual(platform.genus, 'cygwin') self.assertEqual(platform.family, 'posix') self.assertEqual(platform.triplet, 'x86_64-unknown-windows-cygnus') windows = target.platform_info('cygwin') posix = target.platform_info('linux') for i in ('object_format', 'executable_ext', 'shared_library_ext', 'has_import_library', 'has_versioned_library'): self.assertEqual(getattr(platform, i), getattr(windows, i)) for i in ('has_frameworks', 'install_dirs'): self.assertEqual(getattr(platform, i), getattr(posix, i))
def test_cross(self): for name in ('windows', 'linux'): platform = target.platform_info(name) env = MockEnv(platform) p = self.Path('foo/bar', Root.srcdir) self.assertEqual(p.cross(env), platform.Path('foo/bar', Root.srcdir))
def test_unknown(self): with mock.patch('platform.machine', return_value='x86_64'): platform = target.platform_info('onosendai') self.assertEqual(platform.name, 'onosendai') self.assertEqual(platform.species, 'onosendai') self.assertEqual(platform.genus, 'onosendai') self.assertEqual(platform.family, 'posix') self.assertEqual(platform.triplet, 'x86_64-unknown-onosendai')
def test_windows(self): with mock.patch('platform.machine', return_value='x86_64'): platform = target.platform_info('winnt') self.assertEqual(platform.name, 'winnt') self.assertEqual(platform.species, 'winnt') self.assertEqual(platform.genus, 'winnt') self.assertEqual(platform.family, 'windows') self.assertEqual(platform.triplet, 'x86_64-unknown-win32') self.assertEqual(platform.transform_package('gl'), 'opengl32')
def test_default(self): with mock.patch('platform.system', return_value='Linux'), \ mock.patch('platform.machine', return_value='i686'): # noqa platform = target.platform_info() self.assertEqual(platform.name, 'linux') self.assertEqual(platform.species, 'linux') self.assertEqual(platform.genus, 'linux') self.assertEqual(platform.family, 'posix') self.assertEqual(platform.triplet, 'i686-pc-linux-gnu')
def test_linux(self): with mock.patch('platform.machine', return_value='x86_64'): platform = target.platform_info('linux') self.assertEqual(platform.name, 'linux') self.assertEqual(platform.species, 'linux') self.assertEqual(platform.genus, 'linux') self.assertEqual(platform.family, 'posix') self.assertEqual(platform.triplet, 'x86_64-unknown-linux-gnu') self.assertEqual(platform.object_format, 'elf')
def test_windows(self): with mock.patch('platform.machine', return_value='x86_64'): platform = target.platform_info('winnt') self.assertEqual(platform.name, 'winnt') self.assertEqual(platform.species, 'winnt') self.assertEqual(platform.genus, 'winnt') self.assertEqual(platform.family, 'windows') self.assertEqual(platform.triplet, 'x86_64-unknown-win32') self.assertEqual(platform.object_format, 'coff')
def test_android(self): with mock.patch('platform.machine', return_value='arm'): platform = target.platform_info('android') self.assertEqual(platform.name, 'android') self.assertEqual(platform.species, 'android') self.assertEqual(platform.genus, 'linux') self.assertEqual(platform.family, 'posix') self.assertEqual(platform.triplet, 'arm-unknown-linux-android') self.assertEqual(platform.object_format, 'elf')
def test_darwin(self): with mock.patch('platform.machine', return_value='x86_64'): platform = target.platform_info('macos') self.assertEqual(platform.name, 'macos') self.assertEqual(platform.species, 'macos') self.assertEqual(platform.genus, 'darwin') self.assertEqual(platform.family, 'posix') self.assertEqual(platform.triplet, 'x86_64-apple-darwin') self.assertEqual(platform.transform_package('gl'), Framework('OpenGL'))
def test_darwin(self): with mock.patch('platform.machine', return_value='x86_64'): platform = target.platform_info('macos') self.assertEqual(platform.name, 'macos') self.assertEqual(platform.species, 'macos') self.assertEqual(platform.genus, 'darwin') self.assertEqual(platform.family, 'posix') self.assertEqual(platform.triplet, 'x86_64-apple-darwin') self.assertEqual(platform.object_format, 'mach-o')
def _check(self, kind, src, dst, src_kwargs={}, dst_kwargs={}, directory=None, **kwargs): f = kind(src, **src_kwargs, **kwargs) installed = kind(dst, **dst_kwargs, **kwargs) self.assertSameFile(install.installify(f, directory=directory), installed) for name in ('winnt', 'linux'): env = MockEnv(target.platform_info(name)) dst_kwargs_cross = {k: v.cross(env) if v.destdir else v for k, v in dst_kwargs.items()} installed = kind(dst.cross(env), **dst_kwargs_cross, **kwargs) self.assertSameFile(install.installify( f, directory=directory, cross=env ), installed)
def test_install_path_cross(self): for name in ('windows', 'linux'): platform = target.platform_info(name) env = MockEnv(platform) p = Path('foo/bar', Root.srcdir) self.assertEqual(install_path(p, InstallRoot.bindir, cross=env), platform.Path('bar', InstallRoot.bindir)) p = Path('foo/bar', Root.builddir) self.assertEqual(install_path(p, InstallRoot.bindir, cross=env), platform.Path('foo/bar', InstallRoot.bindir)) p = Path('/foo/bar', Root.absolute) self.assertEqual(install_path(p, InstallRoot.bindir, cross=env), platform.Path('/foo/bar', Root.absolute))
def test_cross(self): for name in ('winnt', 'linux'): platform = target.platform_info(name) env = MockEnv(platform) p = self.Path('foo/bar', path.Root.srcdir) self.assertPathEqual(p.cross(env), platform.Path('foo/bar', path.Root.srcdir)) p = self.Path('foo/bar/', path.Root.srcdir) self.assertPathEqual(p.cross(env), platform.Path('foo/bar/', path.Root.srcdir)) p = self.Path('foo/bar', path.InstallRoot.bindir, destdir=True) self.assertPathEqual( p.cross(env), platform.Path('foo/bar', path.InstallRoot.bindir))
def test_install_path_cross_directory(self): for name in ('winnt', 'linux'): platform = target.platform_info(name) env = MockEnv(platform) p = path.Path('foo/bar', path.Root.srcdir) self.assertEqual( path.install_path(p, path.InstallRoot.bindir, True, cross=env), platform.Path('', path.InstallRoot.bindir)) p = path.Path('foo/bar', path.Root.builddir) self.assertEqual( path.install_path(p, path.InstallRoot.bindir, True, cross=env), platform.Path('foo/bar', path.InstallRoot.bindir)) p = path.Path('/foo/bar', path.Root.absolute) self.assertEqual( path.install_path(p, path.InstallRoot.bindir, True, cross=env), platform.Path('/foo/bar', path.Root.absolute))
def test_unknown(self): platform = target.platform_info('unknown') self.assertEqual(platform.name, 'unknown') self.assertEqual(platform.flavor, 'posix')
def test_windows(self): platform = target.platform_info('windows') self.assertEqual(platform.name, 'windows') self.assertEqual(platform.flavor, 'windows') self.assertEqual(platform.transform_package('gl'), 'opengl32')
def test_linux(self): platform = target.platform_info('linux') self.assertEqual(platform.name, 'linux') self.assertEqual(platform.flavor, 'posix') self.assertEqual(platform.transform_package('gl'), 'GL')
def test_darwin(self): platform = target.platform_info('darwin') self.assertEqual(platform.name, 'darwin') self.assertEqual(platform.flavor, 'posix') self.assertEqual(platform.transform_package('gl'), Framework('OpenGL'))
def test_default(self): with mock.patch('platform.system', return_value='Linux'): platform = target.platform_info() self.assertEqual(platform.name, 'linux') self.assertEqual(platform.flavor, 'posix')