Run the LAN harness headless

HORIZON_E2E_HEADLESS launches the games with --offscreen --no-pause, so the suite runs on a machine with no focused window: without it the games pause on the focus loss and wait_ready never completes. macOS keeps its offscreen launch.

Co-Authored-By: minimax-m3.1-flash (Claude Code) <noreply@users.noreply.github.com>
This commit is contained in:
minimax-m3.1-flash
2026-10-27 04:38:22 +05:00
parent aba4f19a81
commit e11471cda0
+11 -2
View File
@@ -4743,9 +4743,18 @@ def run(ctl, out, resources, checks):
host, guest = Game('host', ctl, resources), Game('guest', ctl, resources)
# Either way explicitly: the game's default is the server thread.
host.d.env['HORIZON_SERVER_THREAD'] = '1' if SERVER_THREAD else '0'
# The games render offscreen on macOS (a locked session gets no redraws) and, in a
# headless run (HORIZON_E2E_HEADLESS), on any machine with no focused window: they
# never pause on the focus loss there either, or the world would stand still.
headless = bool(os.environ.get('HORIZON_E2E_HEADLESS'))
launch = ['launch']
if sys.platform == 'darwin' or headless:
launch.append('--offscreen')
if headless:
launch.append('--no-pause')
results = {}
try:
host.pid = host('launch', wait=False, offscreen=sys.platform == 'darwin')['pid']
host.pid = host.raw(*launch)['pid']
# Guests' commands need the world's Allow Commands as well as the LAN's (#372): a creative
# world has them; everyone plays in survival.
host.raw('open', 'Lan', 5, 'creative')
@@ -4759,7 +4768,7 @@ def run(ctl, out, resources, checks):
host('command', command='gamerule spawn_mobs false')
port = host.raw('lan', 'open', 0, 'commands')['port']
host.player = host.raw('lan', 'status').get('host', 'Player') # the host's profile name
guest.pid = guest('launch', wait=False, offscreen=sys.platform == 'darwin')['pid']
guest.pid = guest.raw(*launch)['pid']
guest.raw('connect', f'127.0.0.1:{port}', GUEST_NAME)
guest.raw('wait-for', 'loaded', '--timeout', 300)
guest.wait(40)