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:
1 parent
fbbfcc95ee
commit
29aa60d0eb
6 files changed
+89
-21
No files matched your search
@@ -3,6 +3,7 @@ package user
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -35,8 +36,14 @@ notes: "主人。陪伴对象。"
|
||||
if err != nil {
|
||||
t.Fatalf("stat saved profile: %v", err)
|
||||
}
|
||||
if perm := info.Mode().Perm(); perm != 0o600 {
|
||||
t.Errorf("saved file mode = %o, want 0600", perm)
|
||||
if runtime.GOOS != "windows" {
|
||||
// Windows has no POSIX permission bits for regular files: Chmod only
|
||||
// toggles the read-only flag and Stat reports 0666 regardless of the
|
||||
// requested 0600, so this assertion is only meaningful on Unix-like
|
||||
// platforms. SaveOwnerProfile still requests 0600 (see save.go).
|
||||
if perm := info.Mode().Perm(); perm != 0o600 {
|
||||
t.Errorf("saved file mode = %o, want 0600", perm)
|
||||
}
|
||||
}
|
||||
|
||||
got, err := LoadOwnerProfile(dst)
|
||||
|
||||
Reference in new issue
Block a user