test(platform): 修 Windows 上平台脆弱的断言(不削弱测试意图)

- trace/task: 亚 tick 耗时合法读到 0(本机时钟步长约 0.44ms),改为断言非负且 Duration == EndedAt-StartedAt
- user/runtimeconfig: Windows 无法表示普通文件的 POSIX 权限位(Stat 恒 0666),0600 断言仅在非 Windows 生效,注释写明实现确实请求 0600
- exec: MSYS pwd 把同一目录渲染成 /tmp/...;改用「标记文件相对名解析」+「与显式 root 的 pwd 输出逐字相等」两条跨平台断言 + 变异验证
- 只读排查全仓同类脆弱断言,结果记入 DevDocs/工作小结
This commit is contained in:
AskaEth committed 2026-10-03 16:08:52 +08:00
1 parent fbbfcc95ee
commit 29aa60d0eb
6 files changed
+89 -21

No files matched your search

+6 -2
View File
@@ -219,8 +219,12 @@ func TestManager_ForegroundTask_FastCompletes(t *testing.T) {
if snap.Output.Stdout != "fast out" {
t.Errorf("Stdout=%q, want fast out", snap.Output.Stdout)
}
if !snap.FinishedAt.After(snap.StartedAt) {
t.Errorf("FinishedAt=%v should be after StartedAt=%v", snap.FinishedAt, snap.StartedAt)
// The monotonic clock may be too coarse to tick between StartedAt and
// FinishedAt, so a task that finishes in less than one tick legitimately
// reads the same stamp for both. Assert the platform-independent invariant
// instead: the finish time is never before the start time.
if snap.FinishedAt.Before(snap.StartedAt) {
t.Errorf("FinishedAt=%v should not be before StartedAt=%v", snap.FinishedAt, snap.StartedAt)
}
}