Skip to content

Quiet plugin ring-buffer console echo during test runs#496

Merged
dsarno merged 1 commit into
mainfrom
test-noise-quiet
May 30, 2026
Merged

Quiet plugin ring-buffer console echo during test runs#496
dsarno merged 1 commit into
mainfrom
test-noise-quiet

Conversation

@dsarno

@dsarno dsarno commented May 30, 2026

Copy link
Copy Markdown
Contributor

Problem

A clean, all-green test_run printed thousands of alarming lines — making a passing run look broken. The bulk:

  • ~500 MCP | filler N lines from the log-ring bound test (test_dock),
  • per-test dispatcher [recv]/[send] chatter, and
  • [error] ... malformed result lines from negative-path suites (e.g. test_dispatcher) that deliberately drive failures.

Fix

McpLogBuffer.log() echoed every line to the Godot console unconditionally (the existing enabled field was never consulted). Now:

  • The console print is gated on enabled and console_echo. The ring buffer still records every line, so tests that assert on buffer contents via get_recent() / total_logged() are unaffected.
  • A new static console_echo (default true, so production logging is unchanged) is flipped off by the test runner for the duration of a run and restored afterward.

Scope / non-goals

  • Engine-level C++ errors (JSON parse failures, get_node() from outside the active tree, etc.) that negative-path tests intentionally trigger are not routed through our logger and still surface — that's inherent and out of scope.
  • The 33 raw print("MCP | ...") calls in the update/lifecycle paths are left as-is (real diagnostics, not buffer-routed). Trimming those is a possible follow-up.

Verification

Live on Godot 4.6.3 (test_run via the live editor):

Metric Before After
`MCP filler` lines during a run ~500
dispatcher [error] lines 2 0
total editor-console lines for a run thousands ~400
  • GDScript suite: 0 failures (new log_buffer suite asserts the ring still records under a muted echo; a brittle "defaults true" test was intentionally omitted since the runner mutes the flag mid-run).
  • 0 parse errors on Godot 4.6.3 and 4.3.

🤖 Generated with Claude Code

A clean, all-green `test_run` printed thousands of alarming lines — ~500
`MCP | filler N` from the log-ring bound test, plus per-test dispatcher
`[recv]/[send]` chatter and `[error] ... malformed result` from negative-path
suites that deliberately drive failures. It made a passing run look broken.

`McpLogBuffer.log()` echoed every line to the Godot console unconditionally
(the existing `enabled` field was never consulted). Gate the console `print`
on `enabled and console_echo`; the ring buffer still records every line, so
tests that assert on buffer contents are unaffected. The test runner flips the
new static `console_echo` off for the duration of a run and restores it after,
so live logging is unchanged outside tests.

This does NOT touch engine-level C++ errors (JSON parse, get_node-from-outside-
tree, etc.) that negative-path tests trigger — those aren't routed through our
logger and still surface. The 33 raw `print("MCP | ...")` calls in the
update/lifecycle paths are also left as-is (real diagnostics, not buffer-routed);
trimming those is a possible follow-up.

Verified live on Godot 4.6.3: `MCP | filler` lines during a run dropped from
~500 to 0, dispatcher `[error]` lines from 2 to 0, total editor log from
thousands to ~400. GDScript suite: 0 failures (new `log_buffer` suite asserts
the ring still records under a muted echo). 0 parse errors on 4.6.3 and 4.3.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Quiets the plugin's McpLogBuffer console echo during test runs so an all-green run isn't drowned in deliberately-induced ring-buffer fill messages and negative-path error chatter. The ring buffer continues to record every line, so content-based assertions are unaffected.

Changes:

  • Add a static console_echo flag on McpLogBuffer and gate the print() in log() on both enabled and console_echo.
  • Test runner saves, mutes, and restores console_echo around run_suites().
  • New test_log_buffer.gd suite verifying ring recording continues when echo is muted or enabled is false.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
plugin/addons/godot_ai/utils/log_buffer.gd Adds static var console_echo; gates console print on enabled and console_echo.
plugin/addons/godot_ai/testing/test_runner.gd Mutes McpLogBuffer.console_echo for duration of run_suites() and restores it.
test_project/tests/test_log_buffer.gd New suite asserting ring recording continues under muted echo / disabled instance.
test_project/tests/test_log_buffer.gd.uid UID file for the new test script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dsarno dsarno merged commit 4da5c57 into main May 30, 2026
16 checks passed
@dsarno dsarno deleted the test-noise-quiet branch May 30, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants