清理测试编译warning #509

Merged
lhk229 merged 6 commits from opt/test-compile-warning into master 2026-10-01 15:29:23 +08:00
Member
No description provided.
lhk229 added 1 commit 2026-09-24 13:29:07 +08:00
清理测试编译中的未使用导入与辅助代码
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m24s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m3s
Project CI / Backend tests (pull_request) Successful in 3m48s
Project CI / Frontend tests (pull_request) Successful in 1m49s
Project CI / Native shell tests (pull_request) Successful in 5m43s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 8m17s
Project CI / Repository checks (pull_request) Successful in 1m57s
Project CI / AI game creator shell web tests (pull_request) Successful in 1m20s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 9m10s
1424c3ee5a
限定 GUI 和平台测试导入的编译范围,删除多余导入与重导出
删除三个无调用的测试辅助函数,消除冗余赋值
补齐 DirectHome 命令工具禁用断言,明确测试路径校验参数用途
更新开发运维文档中的测试编译告警处理边界
lhk229 marked the pull request as work in progress 2026-09-24 13:30:16 +08:00
lhk229 self-assigned this 2026-09-24 13:30:22 +08:00
lhk229 added 2 commits 2026-09-24 15:02:43 +08:00
删除七个无调用的测试辅助函数和包装方法
限定 Unix、Unity 与模板假数据辅助代码的编译条件
删除失去测试入口的旧协议措辞断言及多余导入
同步记录测试辅助代码与现役协议的保留边界
按生产接入边界拆分桌面模块并减少测试编译告警
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m29s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Failing after 1m44s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m57s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Failing after 2m48s
Project CI / Frontend tests (pull_request) Successful in 2m49s
Project CI / Repository checks (pull_request) Successful in 2m53s
Project CI / Backend tests (pull_request) Successful in 4m38s
Project CI / AI game creator shell web tests (pull_request) Successful in 1m33s
Project CI / Native shell tests (pull_request) Successful in 6m17s
9b109d75d5
将桌面启动、命令注册和窗口接入集中到非测试模块,保持命令集合与注册顺序不变
拆分命令专属辅助、上传网络执行和素材生成派发,保留共享业务实现及原有测试
按实际消费者限定生产导入和重导出,测试死代码告警由341条降至198条
更新源码接线检查、开发运维文档和共享开发流程
验证普通目标与测试目标编译、60条Rust测试、7条前端测试及配置格式编码文档检查
未运行全量构建或跨平台验证,跳过一个Windows原生弹窗用例
lhk229 added 2 commits 2026-10-01 14:45:02 +08:00
分离桌面启动与命令包装,按实际消费者限定编译范围
保留共享业务实现并补充设计会话、取消回合、UI 与音频派发定向回归
同步壳结构检查和编译告警保留边界文档
合并 origin/master 最新变更
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m50s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Failing after 2m8s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m25s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Failing after 3m38s
Project CI / Frontend tests (pull_request) Successful in 2m51s
Project CI / Backend tests (pull_request) Successful in 4m31s
Project CI / Repository checks (pull_request) Successful in 2m52s
Project CI / AI game creator shell web tests (pull_request) Successful in 1m46s
Project CI / Native shell tests (pull_request) Successful in 6m16s
ccfe0205b3
合入主分支 73090437f,保留现役认证、发布、线程队列与 UI 工作流
协调桌面接线拆分与共享测试编译边界,迁移取消回合断言
通过配置、壳契约、编码及文档检查;Rust 检查受本地 Claude SDK 随包依赖缺失阻塞
Author
Member

代码评审(opt/test-compile-warning → master)

对比 origin/master(73090437)到 ccfe0205。89 个文件,+5600 / −5140。

这次改动把桌面启动、Tauri 命令和 GUI 接线拆到 #[cfg(not(test))] 模块,并删掉只在测试编译里告警的死辅助代码。命令注册、预览退出、快照 Periodic 变体和测试替身都留在对应的 cfg 两侧,生产构建边界大体对齐。

有两处 #[cfg(not(test))] 收得过宽,把仍被始终编译路径调用的符号藏掉了。按当前模块结构,cargo check --tests 会在下面两处失败;普通非测试构建仍然能通过。这次是按 cfg 和调用点核对的,没有另跑完整的 cargo check --tests。

[bug] MCP loopback 在测试编译中被摘掉

apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs:2136

start_external_mcp_loopback(2136)和 stop_external_mcp_loopback(2185)标了 #[cfg(not(test))],测试编译里这两个名字不存在。始终编译的 direct_game_creator_claude_code_chat_at(agent/claude_code_cli.rs:660)会调用前者,同文件 ExternalMcpStopGuard::drop(agent/claude_code_cli.rs:86)会调用后者。该聊天函数又被未加 cfg 的 direct_game_creator_codex_chat_at_with_optional_observer(agent/codex_app_server/mod.rs:5344)在 Claude Code CLI 模式下调用。agent.rs 对 direct_tools_mcp::* 的再导出和 claude_code_cli 的 use super::* 都没有测试门禁,函数体在 cfg(test) 下仍会做类型检查。HTTP 处理函数和容量测试仍留在测试编译里,缺的是 loopback 启停。

建议:去掉这两个函数以及它们专属的 ExternalMcpServer / EXTERNAL_MCP_SERVER 上的 #[cfg(not(test))],让 loopback 继续跟着 Claude Direct 路径编译。Tauri 命令 start_game_creator_external_mcp、stop_game_creator_external_mcp 和 run_direct_tools_mcp_if_requested 可以继续留在非测试门禁后面。

[bug] 会话校验包装在测试编译中被摘掉

apps/ai-game-creator-shell/src-tauri/src/platform_session.rs:242

validate_platform_session_input 标了 #[cfg(not(test))]。未加 cfg 的 install_client_session_locally(commands.rs:4596)在 spawn_blocking 里直接调用它,再写入 runner 与平台会话。auth_session.rs:626 的 commit_authenticated_session 同样始终编译,并等待这次安装完成。commands 与 platform_session 都是无条件模块,crate 根对 platform_session::* 的导入也没有测试门禁。

建议:去掉 validate_platform_session_input 上的 #[cfg(not(test))]。它只是对仍参与测试编译的 validated_platform_session_snapshot 的薄包装,会话安装路径在测试里也要能编过。fixture 加载留在 platform_session/startup.rs 的非测试模块里即可。

## 代码评审(`opt/test-compile-warning` → `master`) 对比 `origin/master`(`73090437`)到 `ccfe0205`。89 个文件,+5600 / −5140。 这次改动把桌面启动、Tauri 命令和 GUI 接线拆到 `#[cfg(not(test))]` 模块,并删掉只在测试编译里告警的死辅助代码。命令注册、预览退出、快照 `Periodic` 变体和测试替身都留在对应的 cfg 两侧,生产构建边界大体对齐。 有两处 `#[cfg(not(test))]` 收得过宽,把仍被始终编译路径调用的符号藏掉了。按当前模块结构,`cargo check --tests` 会在下面两处失败;普通非测试构建仍然能通过。这次是按 cfg 和调用点核对的,没有另跑完整的 `cargo check --tests`。 ### [bug] MCP loopback 在测试编译中被摘掉 `apps/ai-game-creator-shell/src-tauri/src/agent/direct_tools_mcp.rs:2136` `start_external_mcp_loopback`(2136)和 `stop_external_mcp_loopback`(2185)标了 `#[cfg(not(test))]`,测试编译里这两个名字不存在。始终编译的 `direct_game_creator_claude_code_chat_at`(`agent/claude_code_cli.rs:660`)会调用前者,同文件 `ExternalMcpStopGuard::drop`(`agent/claude_code_cli.rs:86`)会调用后者。该聊天函数又被未加 cfg 的 `direct_game_creator_codex_chat_at_with_optional_observer`(`agent/codex_app_server/mod.rs:5344`)在 Claude Code CLI 模式下调用。`agent.rs` 对 `direct_tools_mcp::*` 的再导出和 `claude_code_cli` 的 `use super::*` 都没有测试门禁,函数体在 `cfg(test)` 下仍会做类型检查。HTTP 处理函数和容量测试仍留在测试编译里,缺的是 loopback 启停。 建议:去掉这两个函数以及它们专属的 `ExternalMcpServer` / `EXTERNAL_MCP_SERVER` 上的 `#[cfg(not(test))]`,让 loopback 继续跟着 Claude Direct 路径编译。Tauri 命令 `start_game_creator_external_mcp`、`stop_game_creator_external_mcp` 和 `run_direct_tools_mcp_if_requested` 可以继续留在非测试门禁后面。 ### [bug] 会话校验包装在测试编译中被摘掉 `apps/ai-game-creator-shell/src-tauri/src/platform_session.rs:242` `validate_platform_session_input` 标了 `#[cfg(not(test))]`。未加 cfg 的 `install_client_session_locally`(`commands.rs:4596`)在 `spawn_blocking` 里直接调用它,再写入 runner 与平台会话。`auth_session.rs:626` 的 `commit_authenticated_session` 同样始终编译,并等待这次安装完成。`commands` 与 `platform_session` 都是无条件模块,crate 根对 `platform_session::*` 的导入也没有测试门禁。 建议:去掉 `validate_platform_session_input` 上的 `#[cfg(not(test))]`。它只是对仍参与测试编译的 `validated_platform_session_snapshot` 的薄包装,会话安装路径在测试里也要能编过。fixture 加载留在 `platform_session/startup.rs` 的非测试模块里即可。
lhk229 added 1 commit 2026-10-01 15:17:46 +08:00
修复合并后共享运行链路的测试编译边界
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m36s
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 2m13s
Project CI / Backend tests (pull_request) Successful in 3m54s
Project CI / Frontend tests (pull_request) Successful in 2m22s
Project CI / Native shell tests (pull_request) Successful in 6m1s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 9m30s
Project CI / AI game creator shell web tests (pull_request) Successful in 2m1s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 10m22s
Project CI / Repository checks (pull_request) Successful in 2m44s
e53d4f611e
恢复 Claude Direct 所需 MCP loopback 启停及工具桥的测试可见性
恢复认证会话校验与线程队列事件构造函数的测试可见性
同步编译边界文档,通过 AGC 测试目标编译检查
lhk229 marked the pull request as ready for review 2026-10-01 15:27:24 +08:00
lhk229 merged commit 55375b1406 into master 2026-10-01 15:29:23 +08:00
lhk229 deleted branch opt/test-compile-warning 2026-10-01 15:29:24 +08:00
Sign in to join this conversation.