chore: 适配 macOS 编译(测试期望改用平台路径分隔符、统一 LF 行尾)

This commit is contained in:
2026-10-09 10:40:08 +08:00
parent 7243f73d33
commit 79ebc82227
2 changed files with 24 additions and 9 deletions
+12
View File
@@ -0,0 +1,12 @@
# 统一按 LF 存储、按 LF 检出,避免 Windows / macOS 之间整文件 diff 噪音
* text=auto eol=lf
# 明确的二进制文件
*.png binary
*.ico binary
*.exe binary
*.jpg binary
*.jpeg binary
*.gif binary
*.icns binary
*.zip binary
+12 -9
View File
@@ -2,6 +2,7 @@ package core
import (
"os"
"path/filepath"
"strings"
"testing"
@@ -31,23 +32,25 @@ func TestBuildDir(t *testing.T) {
want string
}{
{"{title}", "[Noxe] 0820 Qingxiao [AI Generated]"},
{"{artist}/{title}", `Noxe\[Noxe] 0820 Qingxiao [AI Generated]`},
{"{group}/{title}", `CriticalHAI\[Noxe] 0820 Qingxiao [AI Generated]`},
{"{category}/{group}/{title}", `misc\CriticalHAI\[Noxe] 0820 Qingxiao [AI Generated]`},
{"{tags:2}/{artist}/{title}", `qingxiao_rover\Noxe\[Noxe] 0820 Qingxiao [AI Generated]`},
{"{tags}/{artist}/{title}", `qingxiao_rover_big breasts_x-ray_ai generated\Noxe\[Noxe] 0820 Qingxiao [AI Generated]`},
{"{artist}/{title}", `Noxe/[Noxe] 0820 Qingxiao [AI Generated]`},
{"{group}/{title}", `CriticalHAI/[Noxe] 0820 Qingxiao [AI Generated]`},
{"{category}/{group}/{title}", `misc/CriticalHAI/[Noxe] 0820 Qingxiao [AI Generated]`},
{"{tags:2}/{artist}/{title}", `qingxiao_rover/Noxe/[Noxe] 0820 Qingxiao [AI Generated]`},
{"{tags}/{artist}/{title}", `qingxiao_rover_big breasts_x-ray_ai generated/Noxe/[Noxe] 0820 Qingxiao [AI Generated]`},
{"{tag1}-{tag2}", "qingxiao-rover"},
{"{artist} - {gid} - {title}", "Noxe - 4239274 - [Noxe] 0820 Qingxiao [AI Generated]"},
{"{gid}", "4239274"},
{"{lang}/{title}", `chinese\[Noxe] 0820 Qingxiao [AI Generated]`},
{"{unknown}/{title}", `{unknown}\[Noxe] 0820 Qingxiao [AI Generated]`}, // 未知占位符原样保留
{"{lang}/{title}", `chinese/[Noxe] 0820 Qingxiao [AI Generated]`},
{"{unknown}/{title}", `{unknown}/[Noxe] 0820 Qingxiao [AI Generated]`}, // 未知占位符原样保留
}
for _, tt := range tests {
t.Run(tt.tpl, func(t *testing.T) {
got := BuildDir(tt.tpl, g)
if got != tt.want {
t.Errorf("\n got: %q\nwant: %q", got, tt.want)
// 期望值用 / 书写,再换成本机路径分隔符(Windows 是 \)
want := strings.ReplaceAll(tt.want, "/", string(filepath.Separator))
if got != want {
t.Errorf("\n got: %q\nwant: %q", got, want)
}
})
}