Skip to content

[refactor][P1] Rust 后端零单元测试覆盖 — 关键模块靠人工验证 #295

Description

@appergb

背景

CLAUDE.md 明确写 "Rust side has no `cargo test` targets yet"。commands.rs 有少量 #[cfg(test)] 测试(~100 行),但 coordinator / hotkey / insertion / recorder 等核心模块完全没有测试

当前风险

  • coordinator.rs 3,842 行状态机仅靠人工验证
  • 一次重构引入逻辑 bug 的概率不低
  • 没有单元测试做安全网,未来重构(如 issue 拆 coordinator)门槛高

建议

按优先级补单元测试:

  1. coordinator.rsbegin_session / stop_dictation / cancel_session 状态机表驱动测试
  2. hotkey.rs — modifier 边沿解析(mac CGEventTap / win WH_KEYBOARD_LL adapter 用 mock)
  3. recorder.rs — 重采样 / RMS 计算(cpal stream 用 mock buffer)
  4. insertion.rs — clipboard restore、AX 直写降级路径

来源

工程审计基线 docs/audit-2026-05-06.md §1.2 / §1.4 高风险 #1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions