fix(test): 修复 Windows PowerShell 5 UI 脚本解析
为 run-ui-tests.ps1 补充 UTF-8 BOM,新增 BUG/Fix 与 TESTING 记录。 Windows PowerShell 5.1 完整 UI 回归 1 轮通过;按用户确认同时纳入 /demo/ 忽略规则。
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
# Fix-BUG-20261005-0001
|
||||
|
||||
> 适用场景:记录某个 BUG 的修复方案、影响评估、验证结果与落地信息。
|
||||
|
||||
## 关联信息
|
||||
|
||||
- Fix ID: Fix-BUG-20261005-0001
|
||||
- 关联 BUG ID: BUG-20261005-0001
|
||||
- 修复目标: 让 `scripts/run-ui-tests.ps1` 可由 Windows PowerShell 5.1 和 PowerShell 7 一致解析执行
|
||||
- 状态:已验证
|
||||
- 负责人: Codex
|
||||
- 分支 / 版本: `master`,修复基线 `3d08bac`
|
||||
|
||||
## 根因分析
|
||||
|
||||
- 根因: `run-ui-tests.ps1` 使用 UTF-8 无 BOM 保存。Windows PowerShell 5.1 不会稳定按 UTF-8 解释无 BOM 脚本,在 CP936 环境中误解中文注释字节,继而破坏 `Add-Type` C# here-string 的词法边界。
|
||||
- 触发条件: 使用 Windows PowerShell 5.1 读取当前脚本;PowerShell 7 默认按 UTF-8 读取,因此不触发。
|
||||
- 为什么之前没发现: 自动回归主要由 PowerShell 7 驱动;仓库只为 `scripts/test.ps1` 明确保留了 UTF-8 BOM,没有把同一约束覆盖到包含中文注释的 UI 子脚本。
|
||||
- 关键证据: 修复前 `powershell.exe ... run-ui-tests.ps1 -Repeat 0` 在解析阶段失败,文件首字节没有 `EF BB BF`;同仓库带 BOM 的 `scripts/test.ps1` 可被 Windows PowerShell 5.1 正确解析。
|
||||
|
||||
## 修复方案
|
||||
|
||||
- 修复思路: 仅在 `scripts/run-ui-tests.ps1` 文件起始处补充 UTF-8 BOM,使 Windows PowerShell 5.1 明确按 UTF-8 解码;不改动脚本业务逻辑。
|
||||
- 关键改动:
|
||||
- `scripts/run-ui-tests.ps1`:增加 UTF-8 BOM。
|
||||
- `开发记录/TESTING.md`:把 BOM 约束扩展到 `test.ps1` 与 `run-ui-tests.ps1`。
|
||||
- 新增对应 BUG/Fix 记录,保留复现、根因、验证与回滚边界。
|
||||
- 涉及文件 / 类 / 函数: `scripts/run-ui-tests.ps1`、`开发记录/TESTING.md`。
|
||||
- 影响的 API / 行为: 无框架 API 或 UI 场景行为变化;只改变 Windows PowerShell 5.1 的脚本解码结果。
|
||||
- 关键约束 / 不变量:
|
||||
- BOM 之外脚本正文必须保持字节等价。
|
||||
- Windows PowerShell 5.1 与 PowerShell 7 均须通过解析。
|
||||
- 完整 UI 回归仍须覆盖普通场景、`native-close` 和 `modal-close`。
|
||||
- 回滚点 / 开关: 可独立移除文件开头的三字节 BOM,但会恢复 Windows PowerShell 5.1 解析失败。
|
||||
|
||||
## 影响评估
|
||||
|
||||
- 影响范围: UI 自动化测试入口的文本编码识别。
|
||||
- 兼容性影响:改善 Windows PowerShell 5.1 兼容性;PowerShell 7 原行为保持不变。
|
||||
- 行为变化:无测试逻辑变化。
|
||||
- 性能影响:无。
|
||||
- 回归风险:
|
||||
- 极少数不支持 UTF-8 BOM 的通用文本工具可能显示一个不可见签名字符;PowerShell 5.1/7 均原生支持该格式。
|
||||
- 若编辑器后续以 UTF-8 无 BOM 重写文件,问题会复发,因此同步固化文档约束。
|
||||
|
||||
## 验证结果
|
||||
|
||||
- 验证步骤:
|
||||
|
||||
1. 检查 `run-ui-tests.ps1` 首三字节为 `EF BB BF`,并确认除 BOM 外正文与修复前一致。
|
||||
2. 使用 Windows PowerShell 5.1 执行 `-Repeat 0` 解析/入口冒烟。
|
||||
3. 使用 Windows PowerShell 5.1 执行完整 UI 回归 1 轮。
|
||||
4. 使用 PowerShell 7 解析脚本并执行入口冒烟。
|
||||
5. 检查新增文档链接、末尾换行、尾随空白和 Git 暂存范围。
|
||||
|
||||
- 验证结果:
|
||||
- 文件首三字节为 `EF BB BF`;解码时去除 BOM 后,脚本正文与 `3d08bac` 中的版本完全一致。
|
||||
- Windows PowerShell 5.1 执行 `-Repeat 0` 入口冒烟通过,不再出现 C# `using`/`StructLayout` 解析错误。
|
||||
- Windows PowerShell 5.1 执行完整 UI 回归 1 轮通过。
|
||||
- PowerShell 7 AST 解析错误数为 0。
|
||||
- 回归检查: UI 普通场景、`native-close` 与 `modal-close` 均由同一轮 Windows PowerShell 5.1 回归覆盖。
|
||||
- 验证证据: `TestResults/ui/20261005-012509-923-32588`。
|
||||
|
||||
## 落地信息
|
||||
|
||||
- Commit: 与修复代码同提交(见 Git 历史)
|
||||
- PR:无
|
||||
- 发布版本:未发布
|
||||
- 备注: 本次提交按用户要求同时收口仓库内其他未提交改动;这些改动不改变本 Fix 的根因与验证边界。
|
||||
Reference in New Issue
Block a user