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 runtimeconfig
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -176,8 +177,14 @@ func TestSaveChannelsRoundTrip(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("stat: %v", err)
|
||||
}
|
||||
if info.Mode().Perm()&0o077 != 0 {
|
||||
t.Fatalf("channels.json mode = %v, want owner-only (0600)", info.Mode().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. SaveChannels still requests 0600 (see channels.go).
|
||||
if info.Mode().Perm()&0o077 != 0 {
|
||||
t.Fatalf("channels.json mode = %v, want owner-only (0600)", info.Mode().Perm())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
@@ -39,8 +40,14 @@ func TestSaveLoadPlugins_RoundTrip(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("stat: %v", err)
|
||||
}
|
||||
if perm := info.Mode().Perm(); perm != 0o600 {
|
||||
t.Fatalf("mode = %o, want 600", 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. SavePlugins still requests 0600 (see plugins.go).
|
||||
if perm := info.Mode().Perm(); perm != 0o600 {
|
||||
t.Fatalf("mode = %o, want 600", perm)
|
||||
}
|
||||
}
|
||||
got, err := LoadPlugins(path)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user