AskaEth
166342b021
fix(core,design): M147 修掉 test(ubuntu) 剩下的两条红(M144 被 fail-fast 挡住没看见)
`cargo test --workspace --all-targets --no-fail-fast` 在 docker 里(Debian 12 / rustc 1.99.1)
第一次跑全:app-iced 那条修好后,还有两个 target 各有一条 **Linux 专有**的确定性失败——
M144 只看到第一条,因为 cargo 默认在第一个失败 target 就停。两条都是「夹具/断言按 Windows
语义写死」,不是产品逻辑错。
1. `unlucky-core`:`platform::wallpaper::windows::tests::current_theme_expands_local_app_data_env_var`
(crates/core/src/platform/wallpaper/windows.rs:286,460 passed / 1 failed)
夹具用了**混合分隔符**:`LOCAL_APP_DATA` 写 `C:/Users/u/AppData/Local`,而 `CUSTOM_THEME`
写 `C:\Users\u\AppData\Local\…`。探针把 `%LOCALAPPDATA%` 展开后拼上 `\Microsoft\…`,得到
`C:/Users/u/AppData/Local\Microsoft\…`;`FakeIo` 却按 `CUSTOM_THEME` 建键。Windows 的
`Path` 把 `/` 与 `\` 都当分隔符 ⇒ 两个 PathBuf 相等;Linux 不 ⇒ 查不到文件 ⇒ 0 个候选。
修法:`LOCAL_APP_DATA` 改成反斜杠原样(`r"C:\Users\u\AppData\Local"`),展开结果与
`CUSTOM_THEME` 逐字节相同。测试仍能在 Linux 跑,不丢覆盖(不是加 cfg 门躲开)。
2. `unlucky-design`:`color::palettes::tests::accent_on_fixed_neutral_only_moves_the_neutral_hue`
(crates/design/src/color/palettes.rs,162 passed / 1 failed)
`assert_eq!(Palettes, Palettes)` 做 f64 位相等,而两侧算中性色相的路径不同:一侧取
`NEUTRAL_HUE_DEG` 字面量,一侧经 `atan2()` 现算——glibc 与 UCRT 差 1 ulp
(239.51420577630955 vs …964)。这正是 palettes.rs:361-365 那条注释自己警告过的坑。
修法:把「固定中性色相」喂成**种子色相的实测值**(`per_seed.neutral.hue_deg()`),两侧同源
⇒ 断言保持**逐位相等**(比放宽容差更紧),零额外行。`NEUTRAL_HUE_DEG` 与种子色相的绑定仍由
隔壁 `neutral_hue_is_the_default_seed_hue` 用 1e-9° 容差钉着。
⚠️ 这里没有照 tower 建议的「1e-9° 容差逐项比」:那个写法在 rustfmt 下要多 9 行,而本文件正好
400 行、顶在 guards.yml 的红线上。改完 399 行(比改前还少 1 行)。
验证(命令与 ci.yml 逐字一致,容器 ull-linux-check:bookworm):
- `cargo test --workspace --all-targets --no-fail-fast` → **exit 0**(原 exit 101,2 targets failed)
- `cargo clippy --workspace --all-targets -- -D warnings` → exit 0
- Windows:`cargo test -p unlucky-core --lib` → 464 passed / 0 failed;
`cargo test -p unlucky-design --lib` → 163 passed / 0 failed(不回归)
2026-11-06 20:19:03 +08:00
..
2026-11-05 21:30:13 +08:00
2026-11-05 14:08:37 +08:00
2026-11-06 20:06:56 +08:00
2026-11-05 21:30:13 +08:00
2026-11-06 20:19:03 +08:00
2026-11-06 20:19:03 +08:00
2026-11-05 20:08:52 +08:00
2026-11-05 21:30:13 +08:00
2026-11-05 21:30:13 +08:00