test(drive): cover dry-run collisions on Linux

This commit is contained in:
chichuan committed 2026-08-12 19:25:14 +08:00
1 parent e08fb484a8
commit 0e856f5a6e
2 files changed
+5 -5

No files matched your search

+3 -3
View File
@@ -184,7 +184,8 @@ func runDrivePull(cmd *cobra.Command, _ []string) error {
}
sort.Strings(relPaths)
if deps.Caller.DryRun() {
return printDrivePullDryRun(absDir, ifExists, remote, relPaths)
caseInsensitive := runtime.GOOS == "windows" || runtime.GOOS == "darwin"
return printDrivePullDryRun(absDir, ifExists, remote, relPaths, caseInsensitive)
}
// 落盘前先按目标文件系统的路径等价规则做一次全局冲突检查:大小写不敏感 FS 上
@@ -246,9 +247,8 @@ func runDrivePull(cmd *cobra.Command, _ []string) error {
return deps.Out.PrintJSON(res)
}
func printDrivePullDryRun(absDir, ifExists string, remote map[string]*remoteFile, relPaths []string) error {
func printDrivePullDryRun(absDir, ifExists string, remote map[string]*remoteFile, relPaths []string, caseInsensitive bool) error {
plan := drivePullResult{Items: make([]drivePullItem, 0, len(relPaths))}
caseInsensitive := runtime.GOOS == "windows" || runtime.GOOS == "darwin"
collided := detectTargetCollisions(absDir, relPaths, caseInsensitive)
for _, rel := range relPaths {
if collided[rel] {
@@ -219,14 +219,14 @@ func TestCrossPlatformCoverageDrivePull_dryRunPlanBranches(t *testing.T) {
t.Cleanup(func() { deps = prevDeps })
if err := printDrivePullDryRun(root, ifExistsSkip, remote,
[]string{"A.txt", "a.txt", "../escape", "skip.txt", "new.txt"}); err != nil {
[]string{"A.txt", "a.txt", "../escape", "skip.txt", "new.txt"}, true); err != nil {
t.Fatalf("skip plan: %v", err)
}
if text := out.String(); !strings.Contains(text, pullActionFailed) || !strings.Contains(text, pullActionSkipped) || !strings.Contains(text, pullActionDownloaded) {
t.Fatalf("skip plan did not cover failed/skipped/downloaded: %s", text)
}
out.Reset()
if err := printDrivePullDryRun(root, ifExistsSmart, remote, []string{"smart.txt"}); err != nil {
if err := printDrivePullDryRun(root, ifExistsSmart, remote, []string{"smart.txt"}, false); err != nil {
t.Fatalf("smart plan: %v", err)
}
if !strings.Contains(out.String(), pullActionSkipped) {