diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index a96af2f41..04737384f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -121,6 +121,8 @@ jobs: ./internal/search \ ./internal/skill \ ./internal/skillignore \ + ./internal/sync \ + ./internal/trash \ ./internal/ui \ ./internal/uidist \ ./internal/utils \ diff --git a/internal/sync/agent_run_test.go b/internal/sync/agent_run_test.go index 45d9b83b9..309689cee 100644 --- a/internal/sync/agent_run_test.go +++ b/internal/sync/agent_run_test.go @@ -3,6 +3,7 @@ package sync import ( "os" "path/filepath" + "runtime" "slices" "strings" "testing" @@ -60,6 +61,9 @@ func TestRunAgentSync_InvalidFilterFailsOnlyThatTarget(t *testing.T) { } func TestRunAgentSync_PruneErrorBecomesWarning(t *testing.T) { + if runtime.GOOS == "windows" { + t.Skip("Windows reports reading a file as a directory as not-exist, which prune ignores") + } // A dry run skips creating the target, so prune reads a path that is a file. targetPath := filepath.Join(t.TempDir(), "agents") os.WriteFile(targetPath, []byte("not a directory"), 0644) diff --git a/internal/sync/agent_sync_test.go b/internal/sync/agent_sync_test.go index d008d2763..502cb30d5 100644 --- a/internal/sync/agent_sync_test.go +++ b/internal/sync/agent_sync_test.go @@ -7,6 +7,7 @@ import ( "testing" "skillshare/internal/resource" + "skillshare/internal/utils" ) func TestCheckAgentCollisions_NoCollision(t *testing.T) { @@ -465,7 +466,7 @@ func TestSyncAgents_SymlinkMode_NewDir(t *testing.T) { if err != nil { t.Fatalf("Lstat: %v", err) } - if info.Mode()&os.ModeSymlink == 0 { + if !utils.IsLinkMode(targetDir, info.Mode()) { t.Error("expected targetDir to be a symlink") } } diff --git a/internal/sync/extension_test.go b/internal/sync/extension_test.go index 8524c5ee1..f8bf37193 100644 --- a/internal/sync/extension_test.go +++ b/internal/sync/extension_test.go @@ -4,6 +4,7 @@ import ( "os" "os/exec" "path/filepath" + "runtime" "strings" "testing" ) @@ -93,9 +94,12 @@ func TestListExtensions(t *testing.T) { if err := os.WriteFile(filepath.Join(geminiDir, "extension.yaml"), []byte("run: [\"cat\"]\n"), 0644); err != nil { t.Fatal(err) } - // (b) single-file executable extension - if err := os.WriteFile(filepath.Join(dir, "conv.sh"), []byte("#!/bin/sh\ncat\n"), 0755); err != nil { - t.Fatal(err) + // (b) single-file executable extension; it relies on the shebang and the + // executable bit, so it exists only on Unix + if runtime.GOOS != "windows" { + if err := os.WriteFile(filepath.Join(dir, "conv.sh"), []byte("#!/bin/sh\ncat\n"), 0755); err != nil { + t.Fatal(err) + } } // (c) directory without manifest — excluded if err := os.MkdirAll(filepath.Join(dir, "notanext"), 0755); err != nil { @@ -111,6 +115,9 @@ func TestListExtensions(t *testing.T) { t.Fatalf("ListExtensions: %v", err) } want := []string{"conv.sh", "gemini-commands"} // sorted + if runtime.GOOS == "windows" { + want = []string{"gemini-commands"} + } if len(got) != len(want) { t.Fatalf("got %v, want %v", got, want) } diff --git a/internal/sync/extras_test.go b/internal/sync/extras_test.go index 803d21556..0fbab90ed 100644 --- a/internal/sync/extras_test.go +++ b/internal/sync/extras_test.go @@ -4,6 +4,8 @@ import ( "os" "path/filepath" "testing" + + "skillshare/internal/utils" ) // setupExtrasTest creates source and target directories under a temp root. @@ -589,7 +591,7 @@ func TestSyncExtra_SymlinkMode(t *testing.T) { if err != nil { t.Fatal(err) } - if info.Mode()&os.ModeSymlink == 0 { + if !utils.IsLinkMode(tgt, info.Mode()) { t.Error("expected target to be a symlink") } diff --git a/internal/sync/file_backups_test.go b/internal/sync/file_backups_test.go index ec966bfe5..b7f323c4a 100644 --- a/internal/sync/file_backups_test.go +++ b/internal/sync/file_backups_test.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "path/filepath" + "runtime" "strings" "testing" ) @@ -142,7 +143,8 @@ func TestRestoreFileBackup_SavesCurrentFirst(t *testing.T) { if err != nil || string(data) != "now" { t.Fatalf("saved version = %q, %v", data, err) } - if info, _ := os.Stat(path); info.Mode().Perm() != 0600 { + // Windows has no permission bits to preserve. + if info, _ := os.Stat(path); runtime.GOOS != "windows" && info.Mode().Perm() != 0600 { t.Fatalf("mode = %v, want the file's own 0600", info.Mode().Perm()) } } diff --git a/internal/sync/merge_test.go b/internal/sync/merge_test.go index 292802bb6..f048a14d5 100644 --- a/internal/sync/merge_test.go +++ b/internal/sync/merge_test.go @@ -6,6 +6,7 @@ import ( "testing" "skillshare/internal/config" + "skillshare/internal/utils" ) // setupMergeTest creates isolated source and target directories with skills. @@ -42,7 +43,7 @@ func TestSyncTargetMerge_CreatesLinks(t *testing.T) { t.Errorf("expected symlink for %s: %v", name, err) continue } - if info.Mode()&os.ModeSymlink == 0 { + if !utils.IsLinkMode(linkPath, info.Mode()) { t.Errorf("expected %s to be a symlink", name) } } @@ -134,7 +135,7 @@ func TestSyncTargetMerge_ForceReplacesLocal(t *testing.T) { if err != nil { t.Fatal(err) } - if info.Mode()&os.ModeSymlink == 0 { + if !utils.IsLinkMode(filepath.Join(tgt, "alpha"), info.Mode()) { t.Error("expected symlink after force replace") } } diff --git a/internal/sync/relative_test.go b/internal/sync/relative_test.go index 28e7893f1..0f695ed37 100644 --- a/internal/sync/relative_test.go +++ b/internal/sync/relative_test.go @@ -133,6 +133,11 @@ func TestShouldUseRelative_DivergentSymlink(t *testing.T) { } } +// posixAbs gives a slash-form path the volume it needs to be absolute on Windows. +func posixAbs(p string) string { + return filepath.VolumeName(os.TempDir()) + filepath.FromSlash(p) +} + func TestResolveReadlink(t *testing.T) { tests := []struct { name string @@ -142,15 +147,15 @@ func TestResolveReadlink(t *testing.T) { }{ { "absolute dest unchanged", - "/abs/source/skill", - "/project/.claude/skills/skill", - "/abs/source/skill", + posixAbs("/abs/source/skill"), + posixAbs("/project/.claude/skills/skill"), + posixAbs("/abs/source/skill"), }, { "relative dest resolved from link parent", "../../.skillshare/skills/skill", - "/project/.claude/skills/skill", - "/project/.skillshare/skills/skill", + posixAbs("/project/.claude/skills/skill"), + posixAbs("/project/.skillshare/skills/skill"), }, } for _, tt := range tests { @@ -170,8 +175,8 @@ func TestLinkNeedsReformat(t *testing.T) { wantRelative bool expected bool }{ - {"absolute dest wants relative", "/abs/path/to/skill", true, true}, - {"absolute dest wants absolute", "/abs/path/to/skill", false, false}, + {"absolute dest wants relative", posixAbs("/abs/path/to/skill"), true, true}, + {"absolute dest wants absolute", posixAbs("/abs/path/to/skill"), false, false}, {"relative dest wants relative", "../../.skillshare/skills/foo", true, false}, {"relative dest wants absolute", "../../.skillshare/skills/foo", false, true}, {"empty dest", "", true, false}, diff --git a/internal/sync/symlinked_dir_test.go b/internal/sync/symlinked_dir_test.go index baea10ce8..65085e26c 100644 --- a/internal/sync/symlinked_dir_test.go +++ b/internal/sync/symlinked_dir_test.go @@ -6,6 +6,7 @@ import ( "testing" "skillshare/internal/config" + "skillshare/internal/utils" ) // --- Discover tests: source dir is a symlink --- @@ -165,7 +166,7 @@ func TestSyncTargetMerge_TargetIsSymlink(t *testing.T) { if err != nil { t.Fatalf("expected symlink at %q: %v", linkPath, err) } - if info.Mode()&os.ModeSymlink == 0 { + if !utils.IsLinkMode(linkPath, info.Mode()) { t.Fatal("expected a symlink") }