def get_running_env(**kwargs): from mozbuild.base import MozbuildObject config = MozbuildObject.from_environment() mach_cmd = MagicMock() def get_binary_path(*args): return "" mach_cmd.get_binary_path = get_binary_path mach_cmd.topsrcdir = config.topsrcdir mach_cmd.topobjdir = config.topobjdir mach_cmd.distdir = config.distdir mach_cmd._mach_context = MagicMock() mach_cmd._mach_context.state_dir = tempfile.mkdtemp() mach_cmd.run_process.return_value = 0 mach_args = { "flavor": "desktop-browser", "test_objects": None, "resolve_tests": True, "browsertime-clobber": False, "browsertime-install-url": None, } mach_args.update(kwargs) hooks = Hooks(mach_cmd, mach_args.pop("hooks", None)) env = MachEnvironment(mach_cmd, hooks=hooks, **mach_args) metadata = Metadata(mach_cmd, env, "desktop-browser") return mach_cmd, metadata, env
def get_running_env(**kwargs): from mozbuild.base import MozbuildObject config = MozbuildObject.from_environment() mach_cmd = MagicMock() def get_binary_path(*args): return "" def run_pip(args): pip = Path(sys.executable).parent / "pip" subprocess.check_call( [str(pip)] + args, stderr=subprocess.STDOUT, cwd=config.topsrcdir, universal_newlines=True, ) mach_cmd.get_binary_path = get_binary_path mach_cmd.topsrcdir = config.topsrcdir mach_cmd.topobjdir = config.topobjdir mach_cmd.distdir = config.distdir mach_cmd._mach_context = MagicMock() mach_cmd._mach_context.state_dir = tempfile.mkdtemp() mach_cmd.run_process.return_value = 0 mach_cmd.virtualenv_manager = MagicMock() mach_cmd.virtualenv_manager.python_path = sys.executable mach_cmd.virtualenv_manager.bin_path = Path(sys.executable).parent mach_cmd.virtualenv_manager._run_pip = run_pip mach_args = { "flavor": "desktop-browser", "test_objects": None, "resolve_tests": True, "browsertime-clobber": False, "browsertime-install-url": None, } mach_args.update(kwargs) hooks = Hooks(mach_cmd, mach_args.pop("hooks", None)) tests = mach_args.get("tests", []) if len(tests) > 0: script = ScriptInfo(tests[0]) else: script = None env = MachEnvironment(mach_cmd, hooks=hooks, **mach_args) metadata = Metadata(mach_cmd, env, "desktop-browser", script) return mach_cmd, metadata, env
def get_running_env(**kwargs): from mozbuild.base import MozbuildObject config = MozbuildObject.from_environment() mach_cmd = MagicMock() mach_cmd.get_binary_path = lambda: "" mach_cmd.topsrcdir = config.topsrcdir mach_cmd.topobjdir = config.topobjdir mach_cmd._mach_context = MagicMock() mach_cmd._mach_context.state_dir = tempfile.mkdtemp() mach_args = { "flavor": "script", "test_objects": None, "resolve_tests": True, "browsertime-clobber": False, "browsertime-install-url": None, } mach_args.update(kwargs) env = MachEnvironment(mach_cmd, **mach_args) metadata = Metadata(mach_cmd, env, "script") return mach_cmd, metadata, env