Skip to content

Windows: 4 个测试因依赖 Unix 特定机制无法运行 #81

@Lellansin

Description

@Lellansin

问题

以下 4 个测试因依赖 Unix 特有的工具或执行机制,在 Windows 上无法正常运行:

1. readClipboardImage uses osascript fallback on macOS when pngpaste is missing

  • 文件src/tests/clipboard.test.ts
  • 原因:mock 脚本使用 #!/bin/sh shebang,Windows 不识别;osascript 是 macOS 独占工具

2. launchNotifyScript passes DURATION and falls back to /bin/sh for non-executable scripts

  • 文件src/tests/settings-and-notify.test.ts
  • 原因:硬编码 Unix 路径 /tmp/notify.sh/bin/sh

3. SessionManager adds -y when launching MCP servers through npx

  • 文件src/tests/session.test.ts
  • 原因:mock npx 可执行文件无扩展名,Windows 上 cmd.exe 通过 PATHEXT 无法找到

4. WebSearch executes the configured script with the query as one argument

  • 文件src/tests/web-search-handler.test.ts
  • 原因:创建 #!/bin/sh 脚本文件,Windows spawn() 抛出 EFTYPE

当前状态

PR #77 中已将这 4 个测试标记为 skip: process.platform === "win32" 以恢复 Windows CI。

修复方向

  • macOS 专用测试 → 维持跳过,追加平台备注
  • /bin/sh 回退 → 测试代码层面模拟,不实际调用 shell
  • npx mock → Windows 上创建 npx.cmd 替代无扩展名文件
  • WebSearch 脚本 → 改用跨平台兼容的 spawn 方式

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions