Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

Fix Windows CI: .exe suffix, USERPROFILE, skip Unix-specific tests

Martin Vogelb679b8a5ffec
diff --git a/cmd/codebase-memory-mcp/cli_test.go b/cmd/codebase-memory-mcp/cli_test.go
index 060b22e50..76a27a68b 100644
--- a/cmd/codebase-memory-mcp/cli_test.go
+++ b/cmd/codebase-memory-mcp/cli_test.go
@@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "runtime"
"strings"
"testing"
"time"
@@ -20,7 +21,11 @@ func TestMain(m *testing.M) {
panic("create temp dir: " + err.Error())
}
- binPath := filepath.Join(tmpDir, "codebase-memory-mcp")
+ binName := "codebase-memory-mcp"
+ if runtime.GOOS == "windows" {
+ binName += ".exe"
+ }
+ binPath := filepath.Join(tmpDir, binName)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
cmd := exec.CommandContext(ctx, "go", "build", "-o", binPath, "./")
cmd.Dir = "."
@@ -45,6 +50,15 @@ func testCmd(t *testing.T, args ...string) *exec.Cmd {
return exec.CommandContext(ctx, testBinPath, args...)
}
+// testEnvWithHome returns env vars with HOME (and USERPROFILE on Windows) set.
+func testEnvWithHome(home string, extra ...string) []string {
+ env := append(os.Environ(), "HOME="+home)
+ if runtime.GOOS == "windows" {
+ env = append(env, "USERPROFILE="+home)
+ }
+ return append(env, extra...)
+}
+
func TestCLI_Version(t *testing.T) {
out, err := testCmd(t, "--version").CombinedOutput()
if err != nil {
@@ -59,7 +73,7 @@ func TestCLI_Version(t *testing.T) {
func TestCLI_InstallDryRun(t *testing.T) {
home := t.TempDir()
cmd := testCmd(t, "install", "--dry-run")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+t.TempDir())
+ cmd.Env = testEnvWithHome(home, "PATH="+t.TempDir())
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("install --dry-run failed: %v\n%s", err, out)
@@ -78,7 +92,7 @@ func TestCLI_InstallDryRun(t *testing.T) {
func TestCLI_UninstallDryRun(t *testing.T) {
home := t.TempDir()
cmd := testCmd(t, "uninstall", "--dry-run")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+t.TempDir())
+ cmd.Env = testEnvWithHome(home, "PATH="+t.TempDir())
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("uninstall --dry-run failed: %v\n%s", err, out)
@@ -116,7 +130,7 @@ func TestCLI_InstallAndUninstall(t *testing.T) {
// Install
cmd := testCmd(t, "install")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+emptyPath, "SHELL=/bin/zsh")
+ cmd.Env = testEnvWithHome(home, "PATH="+emptyPath, "SHELL=/bin/zsh")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("install failed: %v\n%s", err, out)
@@ -138,7 +152,7 @@ func TestCLI_InstallAndUninstall(t *testing.T) {
// Uninstall
cmd = testCmd(t, "uninstall")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+emptyPath)
+ cmd.Env = testEnvWithHome(home, "PATH="+emptyPath)
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("uninstall failed: %v\n%s", err, out)
@@ -166,7 +180,7 @@ func TestCLI_InstallRemovesOldSkill(t *testing.T) {
}
cmd := testCmd(t, "install")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+emptyPath, "SHELL=/bin/zsh")
+ cmd.Env = testEnvWithHome(home, "PATH="+emptyPath, "SHELL=/bin/zsh")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("install failed: %v\n%s", err, out)
@@ -186,7 +200,7 @@ func TestCLI_InstallIdempotent(t *testing.T) {
for i := 0; i < 2; i++ {
cmd := testCmd(t, "install")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+emptyPath, "SHELL=/bin/zsh")
+ cmd.Env = testEnvWithHome(home, "PATH="+emptyPath, "SHELL=/bin/zsh")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("install round %d failed: %v\n%s", i, err, out)
@@ -204,7 +218,7 @@ func TestCLI_InstallForceOverwrites(t *testing.T) {
emptyPath := t.TempDir()
cmd := testCmd(t, "install")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+emptyPath, "SHELL=/bin/zsh")
+ cmd.Env = testEnvWithHome(home, "PATH="+emptyPath, "SHELL=/bin/zsh")
if out, err := cmd.CombinedOutput(); err != nil {
t.Fatalf("first install failed: %v\n%s", err, out)
}
@@ -215,7 +229,7 @@ func TestCLI_InstallForceOverwrites(t *testing.T) {
}
cmd = testCmd(t, "install")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+emptyPath, "SHELL=/bin/zsh")
+ cmd.Env = testEnvWithHome(home, "PATH="+emptyPath, "SHELL=/bin/zsh")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("second install failed: %v\n%s", err, out)
@@ -226,7 +240,7 @@ func TestCLI_InstallForceOverwrites(t *testing.T) {
}
cmd = testCmd(t, "install", "--force")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+emptyPath, "SHELL=/bin/zsh")
+ cmd.Env = testEnvWithHome(home, "PATH="+emptyPath, "SHELL=/bin/zsh")
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("force install failed: %v\n%s", err, out)
@@ -238,12 +252,15 @@ func TestCLI_InstallForceOverwrites(t *testing.T) {
}
func TestCLI_InstallPATHAppend(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("shell RC PATH append is Unix-specific")
+ }
+
home := t.TempDir()
- t.Setenv("SHELL", "/bin/zsh")
emptyPath := t.TempDir()
cmd := testCmd(t, "install")
- cmd.Env = append(os.Environ(), "HOME="+home, "PATH="+emptyPath, "SHELL=/bin/zsh")
+ cmd.Env = testEnvWithHome(home, "PATH="+emptyPath, "SHELL=/bin/zsh")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("install failed: %v\n%s", err, out)
diff --git a/cmd/codebase-memory-mcp/install_test.go b/cmd/codebase-memory-mcp/install_test.go
index dc96eec76..0b9b6b445 100644
--- a/cmd/codebase-memory-mcp/install_test.go
+++ b/cmd/codebase-memory-mcp/install_test.go
@@ -3,13 +3,31 @@ package main
import (
"os"
"path/filepath"
+ "runtime"
"strings"
"testing"
)
+// setTestHome overrides the home directory for both Unix (HOME) and Windows (USERPROFILE).
+func setTestHome(t *testing.T, home string) {
+ t.Helper()
+ t.Setenv("HOME", home)
+ if runtime.GOOS == "windows" {
+ t.Setenv("USERPROFILE", home)
+ }
+}
+
+// exeSuffix returns ".exe" on Windows, empty string otherwise.
+func exeSuffix() string {
+ if runtime.GOOS == "windows" {
+ return ".exe"
+ }
+ return ""
+}
+
func TestInstallSkillCreation(t *testing.T) {
home := t.TempDir()
- t.Setenv("HOME", home)
+ setTestHome(t, home)
claudeSkillsDir := filepath.Join(home, ".claude", "skills")
@@ -41,7 +59,8 @@ func TestInstallSkillCreation(t *testing.T) {
if len(data) == 0 {
t.Fatalf("skill file %s is empty", skillFile)
}
- if !strings.HasPrefix(string(data), "---\n") {
+ normalized := strings.ReplaceAll(string(data), "\r\n", "\n")
+ if !strings.HasPrefix(normalized, "---\n") {
t.Fatalf("skill %s missing YAML frontmatter", name)
}
if !strings.Contains(string(data), "name: "+name) {
@@ -52,7 +71,7 @@ func TestInstallSkillCreation(t *testing.T) {
func TestInstallIdempotent(t *testing.T) {
home := t.TempDir()
- t.Setenv("HOME", home)
+ setTestHome(t, home)
claudeSkillsDir := filepath.Join(home, ".claude", "skills")
@@ -79,7 +98,7 @@ func TestInstallIdempotent(t *testing.T) {
func TestUninstallRemovesSkills(t *testing.T) {
home := t.TempDir()
- t.Setenv("HOME", home)
+ setTestHome(t, home)
claudeSkillsDir := filepath.Join(home, ".claude", "skills")
@@ -110,7 +129,7 @@ func TestUninstallRemovesSkills(t *testing.T) {
func TestFindCLI_NotFound(t *testing.T) {
t.Setenv("PATH", t.TempDir())
- t.Setenv("HOME", t.TempDir())
+ setTestHome(t, t.TempDir())
result := findCLI("nonexistent-binary-xyz")
if result != "" {
@@ -121,7 +140,7 @@ func TestFindCLI_NotFound(t *testing.T) {
func TestFindCLI_FoundOnPATH(t *testing.T) {
tmpDir := t.TempDir()
- fakeBin := filepath.Join(tmpDir, "fakecli")
+ fakeBin := filepath.Join(tmpDir, "fakecli"+exeSuffix())
if err := os.WriteFile(fakeBin, []byte("#!/bin/sh\n"), 0o600); err != nil {
t.Fatalf("write fake binary: %v", err)
}
@@ -130,15 +149,19 @@ func TestFindCLI_FoundOnPATH(t *testing.T) {
}
t.Setenv("PATH", tmpDir)
- result := findCLI("fakecli")
+ result := findCLI("fakecli" + exeSuffix())
if result == "" {
t.Fatal("expected to find fakecli on PATH")
}
}
func TestFindCLI_FallbackPaths(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("fallback paths use Unix-specific locations")
+ }
+
home := t.TempDir()
- t.Setenv("HOME", home)
+ setTestHome(t, home)
t.Setenv("PATH", t.TempDir())
localBin := filepath.Join(home, ".local", "bin")
@@ -173,8 +196,12 @@ func TestDetectBinaryPath(t *testing.T) {
}
func TestDetectShellRC(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("shell RC detection is Unix-specific")
+ }
+
home := t.TempDir()
- t.Setenv("HOME", home)
+ setTestHome(t, home)
tests := []struct {
shell string
@@ -201,8 +228,12 @@ func TestDetectShellRC(t *testing.T) {
}
func TestDetectShellRC_BashWithBashrc(t *testing.T) {
+ if runtime.GOOS == "windows" {
+ t.Skip("shell RC detection is Unix-specific")
+ }
+
home := t.TempDir()
- t.Setenv("HOME", home)
+ setTestHome(t, home)
t.Setenv("SHELL", "/bin/bash")
bashrc := filepath.Join(home, ".bashrc")
@@ -233,7 +264,7 @@ func TestDryRun(t *testing.T) {
func TestCodexInstructionsCreation(t *testing.T) {
home := t.TempDir()
- t.Setenv("HOME", home)
+ setTestHome(t, home)
instrDir := filepath.Join(home, ".codex", "instructions")
instrFile := filepath.Join(instrDir, "codebase-memory-mcp.md")
@@ -284,7 +315,7 @@ func TestSkillFilesContent(t *testing.T) {
func TestRemoveOldMonolithicSkill(t *testing.T) {
home := t.TempDir()
- t.Setenv("HOME", home)
+ setTestHome(t, home)
oldDir := filepath.Join(home, ".claude", "skills", "codebase-memory-mcp")
if err := os.MkdirAll(oldDir, 0o750); err != nil {