Skip to content

[DevEx] Fix unit test failures on Windows (POSIX path literals, symlink privilege, locale-dependent assertions) #68

Closed

Description

@yjg-djb

Background

CI 只在 ubuntu 上运行(.github/workflows/pr.yml),但 Folio 是 Electron 桌面应用,Windows 是重要目标平台。Windows 贡献者在本地执行 bun test --isolate 会遇到 5 个失败,全部可以在干净 main 上复现(与具体改动无关),导致 Windows 上无法做可靠的本地回归——分不清是自己改坏了还是本来就坏。

实测环境:Windows 11 (10.0.26200) + Bun 1.4.2,干净 main 检出后直接运行。

失败清单

# 测试 位置 根因
1 AgentKernelHost > builds the kernel on the electron userData store apps/electron/src/main/kernelHost.test.ts:333 断言硬编码 POSIX 字面量 /tmp/finagent-test/store,Windows 上 path 拼接返回反斜杠(\tmp\finagent-test\store)
2 PiRuntimeAdapter > isolates sessions by switching the runtime session file packages/shared/src/agent/pi-runtime-agent-backend.test.ts:528 同类:期望 /tmp/pi/s1.jsonl,Windows 实际 \tmp\pi\s1.jsonl
3 SkillHub V2 > blocks symlink escapes outside the skill directory packages/skill-hub/src/index.v2.test.ts:94 fs.symlink 在 Windows 需要开发者模式或管理员权限,无权限时 EPERM 直接 fail(而非 skip)
4 score formatting > renders short shas and dates packages/ui/src/components/evaluation/format.test.ts:111 formatDate 用 toLocaleDateString(undefined, …) 跟随系统 locale,zh-CN Windows 输出 2023年11月14日,断言却假定英文格式 Nov 14, 2023
5 TodayView > renders portfolio + movers data without NaN/undefined packages/ui/src/components/today/TodayView.test.tsx 仅在全量运行(与其他文件同批)时失败,单包运行通过——疑似测试间共享状态或时序不稳定,需排查

Requirements

  • 路径断言不得硬编码 POSIX 字面量:用 node:path 的 join 构造期望值,或对实际值做分隔符归一化后再断言;
  • symlink 用例在环境不支持(EPERM)时 skip 并给出原因,支持时保持原安全语义不变——安全测试不能用"假装通过"代替跳过;
  • locale 相关断言与系统 locale 解耦(固定 locale 或注入),产品代码 formatDate 保留 locale 感知行为(这是 i18n 应有语义),仅让测试确定化;
  • 排查 fix: harden credential persistence #5 的顺序依赖/共享状态根因并隔离或修复,不允许简单 it.skip 掉事;
  • 不改变产品行为;若发现根因在产品代码(如路径处理本身跨平台不正确),需在 PR 中单独说明。

Acceptance Criteria

  • Windows 10/11 + Bun 上 bun test --isolate 与干净 main 相比 0 个新增失败,上述 5 项中确定性失败全部修复、条件性失败正确 skip 或根治;
  • ubuntu/Linux 上结果不劣于当前 main(路径用 join 构造后 POSIX 语义不变);
  • CI 三道 gate(Typecheck / Unit tests / Secret scan)全绿;
  • PR 附 Windows 实测报告:命令、环境、分组 pass/fail、skip 明细。

Activity

  1. yjg-djb commented on Sep 11, 2026

    @yjg-djb
    ContributorAuthor

    /claim

  2. added
    claimed
    on Sep 11, 2026
  3. github-actions commented on Sep 11, 2026

    @github-actions

    @yjg-djb 已认领该 Issue,并已自动设为 Assignee。提交 PR 时请在描述中写 Closes #68。

  4. added a commit that references this issue on Sep 11, 2026
    6ecdab9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

claimed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions