Skip to content

fix: 修复 Windows 插件安装与 service 测试 - #6342

Open
mordekasiser wants to merge 2 commits into
Wei-Shaw:mainfrom
mordekasiser:codex/windows-service-test-fixes
Open

fix: 修复 Windows 插件安装与 service 测试#6342
mordekasiser wants to merge 2 commits into
Wei-Shaw:mainfrom
mordekasiser:codex/windows-service-test-fixes

Conversation

@mordekasiser

Copy link
Copy Markdown

问题

Windows 下 go test ./internal/service 暴露两类跨平台缺陷:

  • 插件安装器使用 zip.OpenReader 打开上传临时包,ZIP 句柄直到函数返回才关闭;安装流程在句柄仍打开时执行 os.Rename,Windows 返回文件占用错误,真实插件安装和 4 个安装器测试失败。
  • 内容审计快照测试用 1ns TTL 触发过期,依赖连续两次系统时钟读数不同;Windows 时钟分辨率会让测试间歇性无法触发后台刷新。
  • 插件测试直接断言 POSIX 可执行位,Windows 不报告该权限位。

修复

  • 插件归档完成校验和解压后立即关闭 ZIP 句柄,再提交安装目录和插件包文件。
  • 关闭失败沿用现有 defer 清理上传临时包和解压目录,不留下已安装半成品。
  • 插件产物在所有平台校验为普通文件,仅在非 Windows 平台校验可执行位。
  • 内容审计测试使用稳定 TTL,并将已加载快照显式回拨到过期时间,继续验证刷新失败时保留旧配置。

验证

  • 修复前:4 个插件安装器测试稳定返回 Windows 文件占用错误;内容审计刷新测试存在间歇失败。
  • 5 项原失败测试连续运行 10 轮通过。
  • 插件安装器与内容审计快照相关测试连续运行 3 轮通过。
  • go test -count=1 ./internal/service 通过,耗时 127.790 秒。
  • go vet ./internal/service 通过。
  • git diff --check 通过。

当前 Windows 工具链未启用 CGO,未运行 go test -race

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.

1 participant