mirror of
https://github.com/black-ant/Ant-Browser.git
synced 2026-07-14 18:48:55 +08:00
channel: master version: 1.1.0 source-ref: master published-at-utc: 2026-03-20T14:14:07Z
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package fsutil
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
goruntime "runtime"
|
|
"testing"
|
|
)
|
|
|
|
func TestNormalizePathInputConvertsWindowsSeparators(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
got := NormalizePathInput(`chrome\Chrom-144\chrome.exe`)
|
|
want := filepath.Join("chrome", "Chrom-144", "chrome.exe")
|
|
if got != want {
|
|
t.Fatalf("NormalizePathInput() = %q, want %q", got, want)
|
|
}
|
|
}
|
|
|
|
func TestEnsureExecutableRepairsMissingExecBitsOnUnix(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if goruntime.GOOS == "windows" {
|
|
t.Skip("Windows does not use POSIX execute bits")
|
|
}
|
|
|
|
path := filepath.Join(t.TempDir(), "tool")
|
|
if err := os.WriteFile(path, []byte("stub"), 0o644); err != nil {
|
|
t.Fatalf("写入测试文件失败: %v", err)
|
|
}
|
|
|
|
if err := EnsureExecutable(path); err != nil {
|
|
t.Fatalf("EnsureExecutable() 返回错误: %v", err)
|
|
}
|
|
|
|
info, err := os.Stat(path)
|
|
if err != nil {
|
|
t.Fatalf("读取测试文件状态失败: %v", err)
|
|
}
|
|
if info.Mode()&0o111 == 0 {
|
|
t.Fatalf("EnsureExecutable() 未补充执行权限: mode=%#o", info.Mode().Perm())
|
|
}
|
|
}
|