Skip to content

Commit baebcc7

Browse files
dsarnoclaude
andcommitted
test+docs(game_eval): address self-review findings on #518
- Move the no-session test's skip-guard BEFORE _send_eval. The old guard checked conn.captured AFTER the call, so if a session were ever present on the bare plugin, _send_eval would already have armed timers and sent a real mcp:eval into the running game before the test could bail. Gate on _first_active_session() up front instead (precondition, not post-hoc) so the test can never have side effects. - tools/editor.py: note EVAL_GAME_NOT_READY also covers a missing/disabled _mcp_game_helper autoload, not just "still launching" -- matches the fuller handlers/editor.py wording so an LLM caller doesn't retry forever when the real fix is enabling the autoload. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c0de00e commit baebcc7

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/godot_ai/tools/editor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
'await' so user code can await internally. Errors return fast and
4040
actionable: EVAL_COMPILE_ERROR for a syntax/parse error,
4141
EVAL_RUNTIME_ERROR (with the real message + line) for a runtime
42-
error; EVAL_GAME_NOT_READY if the game is still launching (retry
43-
once it's up); a genuine infinite loop / never-firing await still
42+
error; EVAL_GAME_NOT_READY if the game isn't ready yet — still
43+
launching (retry once it's up) or the _mcp_game_helper autoload is
44+
missing/disabled; a genuine infinite loop / never-firing await still
4445
times out. 'await' only progresses while the game window is focused."""
4546

4647

test_project/tests/test_game_eval_errors.gd

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,16 @@ func test_send_eval_without_active_session_replies_game_not_ready() -> void:
406406
skip("No SceneTree available")
407407
return
408408
var plugin := McpDebuggerPlugin.new()
409-
var conn := _StubConnection.new()
410-
plugin._send_eval(tree, "return 1", "rid-no-session", conn, 10.0)
411-
if conn.captured.is_empty():
412-
## A live debugger session is present (e.g. a game running under this
413-
## editor), so the no-session branch wasn't exercised — don't false-fail.
414-
conn.free()
409+
## Gate BEFORE calling _send_eval: a bare plugin normally has no session, but
410+
## if one were present _send_eval would take its live path (arm timers, send a
411+
## real mcp:eval into the running game). Skip first so the test never has side
412+
## effects in that case rather than bailing after the fact.
413+
if plugin._first_active_session() != null:
415414
skip("an active debugger session is present; no-session branch not exercised")
416415
return
416+
var conn := _StubConnection.new()
417+
plugin._send_eval(tree, "return 1", "rid-no-session", conn, 10.0)
418+
assert_eq(conn.captured.size(), 1, "exactly one deferred reply is sent")
417419
assert_eq(conn.captured[0]["payload"]["error"]["code"], ErrorCodes.EVAL_GAME_NOT_READY,
418420
"no active debugger session replies with EVAL_GAME_NOT_READY, not INTERNAL_ERROR")
419421
conn.free()

0 commit comments

Comments
 (0)