"""Exercise the actual remote build command without fetching or compiling a game.""" import importlib.util import json import struct import sys import types from pathlib import Path import pytest RESOURCES = Path(__file__).resolve().parents[1] / "resources" def test_build_launches_package_manager_as_container_root_with_host_isolation(tmp_path, monkeypatch): if not hasattr(__import__("os"), "getuid"): monkeypatch.setattr(__import__("os"), "getuid", lambda: 0, raising=False) if "pwd" not in sys.modules: monkeypatch.setitem(sys.modules, "pwd", types.SimpleNamespace(getpwuid=lambda uid: None)) spec = importlib.util.spec_from_file_location("build_container_remote_install", RESOURCES / "remote_install.py") remote = importlib.util.module_from_spec(spec) monkeypatch.setitem(sys.modules, spec.name, remote) spec.loader.exec_module(remote) remote.HOME = tmp_path / "home" remote.HOME.mkdir() remote.CACHE = remote.HOME / "cache" remote.GAME = remote.HOME / "Games/HaloCENativeVR" remote.owned(remote.CACHE) resources = remote.CACHE / "resources" resources.mkdir() (resources / "frame-controls.patch").write_bytes(b"synthetic patch; git is mocked") script = (RESOURCES / "build-native.sh").read_bytes() (resources / "build-native.sh").write_bytes(script) run_id = "e" * 32 directory = remote.CACHE / "runs" / run_id remote.owned(directory) remote.prepare(run_id) upload = directory / "upload" header = bytearray(2048) header[:4] = b"daeh" header[-4:] = b"toof" struct.pack_into("