From ff11275ae28b22faa3b28b133b34fb12c925da71 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 11 Nov 2026 17:27:04 +0800 Subject: [PATCH] library: the plugin test expects ${CLAUDE_PLUGIN_ROOT} replaced as written, JSON-escaped (#6065) TestPluginImportCarryOnOffRemove was red on Windows only (Windows CI compiles tests and runs none). The import replaces ${CLAUDE_PLUGIN_ROOT} with the plugin's folder as written, so "${CLAUDE_PLUGIN_ROOT}/scripts/lint.sh" becomes "C:\...\acme-kit/scripts/lint.sh", as Claude Code itself expands it. The test wanted filepath.Join's all-backslash path, and looked for it unescaped in raw JSON, where every backslash is doubled. It now expects root + "/scripts/lint.sh" (and bin/db, and the data folder) JSON-escaped. No product code changes. Run: go test -count=1 -run TestPlugin ./internal/library ok on Windows 11 (xiaomi-gpu, win-run), mote (macOS) and WSL magpie-desktop, at origin/main 961427f12 plus this. Before it, red alone on Windows at the same base. Not changed: TestGoneAgentListedToTakeOut and TestCheckMixedServerEachSide, still red on Windows (#4115). --- internal/library/plugin_test.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/library/plugin_test.go b/internal/library/plugin_test.go index 32d8aa931..5ab56f66f 100644 --- a/internal/library/plugin_test.go +++ b/internal/library/plugin_test.go @@ -1,6 +1,7 @@ package library import ( + "encoding/json" "os" "path/filepath" "strings" @@ -71,8 +72,12 @@ func TestPluginImportCarryOnOffRemove(t *testing.T) { if _, err := os.Lstat(filepath.Join(h, ".claude/skills/tdd")); err != nil { t.Errorf("claude skill: %v", err) } + // ${CLAUDE_PLUGIN_ROOT} is replaced as written, so the rest of the path + // keeps its forward slashes (as Claude Code expands it on Windows), and + // the files hold it JSON-escaped + inJSON := func(s string) string { b, _ := json.Marshal(s); return string(b[1 : len(b)-1]) } settings := read(t, filepath.Join(h, ".claude/settings.json")) - for _, want := range []string{filepath.Join(root, "scripts/lint.sh"), "Bash", "echo done"} { + for _, want := range []string{inJSON(root + "/scripts/lint.sh"), "Bash", "echo done"} { if !strings.Contains(settings, want) { t.Errorf("claude settings lack %q:\n%s", want, settings) } @@ -84,7 +89,7 @@ func TestPluginImportCarryOnOffRemove(t *testing.T) { t.Errorf("codex was given claude's own event:\n%s", codexHooks) } cj := read(t, filepath.Join(h, ".claude.json")) - if !strings.Contains(cj, filepath.Join(root, "bin/db")) || !strings.Contains(cj, data) { + if !strings.Contains(cj, inJSON(root+"/bin/db")) || !strings.Contains(cj, inJSON(data)) { t.Errorf("claude's server lacks the plugin's folders:\n%s", cj) } if !strings.Contains(read(t, filepath.Join(h, ".codex/config.toml")), "acme-db") {