def make_env(platform=None, clear_variables=False): args = (Path('bfgdir', Root.srcdir), None, None, abspath('srcdir'), abspath('builddir'), {}, (False, False), None) if platform: with mock.patch('bfg9000.platforms.host.platform_name', return_value=platform): env = Environment(*(args + (platform, ))) else: env = Environment(*args) if clear_variables: env.variables = {} return env
def make_env(platform=None, clear_variables=False, variables={}): args = (Path('bfgdir', Root.srcdir), None, None, abspath('srcdir'), abspath('builddir'), {}, (False, False)) if platform: with mock.patch('bfg9000.platforms.core.platform_name', return_value=platform): env = Environment(*args) else: env = Environment(*args) if clear_variables: env.variables = {} env.variables.update(variables) return env
def test_upgrade_from_v4(self): env = Environment.load(os.path.join(test_data_dir, 'environment', 'v4')) self.assertEqual(env.bfgdir, Path('/path/to')) self.assertEqual(env.backend, 'make') self.assertEqual(env.srcdir, Path('/root/srcdir')) self.assertEqual(env.builddir, Path('/root/builddir')) self.assertDictsEqual( env.install_dirs, { InstallRoot.prefix: Path('/root/prefix'), InstallRoot.exec_prefix: Path('', InstallRoot.prefix), InstallRoot.bindir: Path('bin', InstallRoot.exec_prefix), InstallRoot.libdir: Path('lib', InstallRoot.exec_prefix), InstallRoot.includedir: Path('include', InstallRoot.prefix), }) self.assertEqual(env.library_mode, LibraryMode(True, False)) self.assertEqual(env.extra_args, []) variables = {u'HOME': u'/home/user'} self.assertEqual(env.variables, variables) self.assertEqual(env.host_platform.name, 'linux') self.assertEqual(env.target_platform.name, 'linux')
def test_upgrade_from_v4(self): env = Environment.load(os.path.join(test_data_dir, 'environment', 'v4')) self.assertEqual(env.bfgdir, Path('/path/to', Root.absolute)) self.assertEqual(env.backend, 'make') self.assertEqual(env.srcdir, Path('/root/srcdir', Root.absolute)) self.assertEqual(env.builddir, Path('/root/builddir', Root.absolute)) self.assertDictsEqual( env.install_dirs, { InstallRoot.prefix: Path('/root/prefix', Root.absolute), InstallRoot.exec_prefix: Path('', InstallRoot.prefix), InstallRoot.bindir: Path('bin', InstallRoot.exec_prefix), InstallRoot.libdir: Path('lib', InstallRoot.exec_prefix), InstallRoot.includedir: Path('include', InstallRoot.prefix), }) self.assertEqual(env.library_mode, LibraryMode(True, False)) self.assertEqual(env.extra_args, []) variables = {u'HOME': u'/home/user'} if platform_info().family == 'windows' and sys.version_info[0] == 2: variables = {str(k): str(v) for k, v in iteritems(variables)} self.assertEqual(env.variables, variables) self.assertEqual(env.host_platform.name, 'linux') self.assertEqual(env.target_platform.name, 'linux')
def make_env(platform=None, clear_variables=False, variables={}): args = (abspath('bfgdir'), None, None, abspath('srcdir'), abspath('builddir')) if platform: with mock.patch('bfg9000.platforms.core.platform_name', return_value=platform): env = Environment(*args) else: env = Environment(*args) env.finalize({InstallRoot.prefix: abspath('prefix')}, (False, False)) if clear_variables: env.variables = {} env.variables.update(variables) return env
def make_env(self): env = Environment(Path('bfgdir', Root.srcdir), None, None, Path('/srcdir'), Path('/builddir')) env.install_dirs[InstallRoot.prefix] = Path('/prefix') env.install_dirs[InstallRoot.exec_prefix] = Path('/exec-prefix') return env
import unittest from collections import namedtuple from six import iteritems from bfg9000.backends import list_backends from bfg9000.environment import Environment from bfg9000.path import InstallRoot, makedirs, Path, Root from bfg9000.platforms import platform_info, platform_name this_dir = os.path.abspath(os.path.dirname(__file__)) examples_dir = os.path.join(this_dir, '..', '..', 'examples') test_data_dir = os.path.join(this_dir, '..', 'data') test_stage_dir = os.path.join(this_dir, '..', 'stage') env = Environment(None, None, None, None, None, None, (False, False), None) Target = namedtuple('Target', ['name', 'path']) if os.getenv('BACKENDS', '').strip(): backends = os.getenv('BACKENDS').split(' ') else: backends = [k for k, v in iteritems(list_backends()) if v.priority > 0] _unset = object() def cleandir(path, recreate=True): if os.path.exists(path): # Windows seems to keep an executable file open a little bit after the # process returns from wait(), so try a few times, sleeping a bit in