From 248edad80c4d6150e19cd14be7eeeab8a0c9ce00 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 15 Nov 2026 22:38:32 +0800 Subject: [PATCH] provider: a plugin host ends with the test whose HOME it started in (#6761) TestRemoveListedAccountLeavesHiddenNamesake failed in full runs (CI Test at e99307fb8, ubuntu) and passed alone. A bisect over the 1779 tests that run before it found TestPluginEmptyKeyKeyAsked: its PluginAPIKey starts a real plugin host (Bun) and leaves it up. plugin.SignOut asks a running host, and that host's files are the earlier test's HOME, so the remove landed there and this test's plugin-auth.json kept the account. claudeHome (which movedPlugin and the culprit both use) now stops a host that is up before it sets the new HOME, and again in cleanup. That covers every provider test that sets a HOME through it, not only this pair. Run (mote, then mica as mote was over its cores): - red before: -run '^(TestPluginEmptyKeyKeyAsked|TestRemoveListedAccountLeavesHiddenNamesake)$' -> "the account removed is still signed in"; green after. - go vet ./internal/provider/; go test -count=1 -timeout 45m ./internal/provider/ ./internal/plugin/ at this tree: ok 142.9s, ok 171.6s. Not run: the full suite (test-only change in one package's helper). --- internal/provider/account_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/internal/provider/account_test.go b/internal/provider/account_test.go index 9cef36e72..0ec68eb2f 100644 --- a/internal/provider/account_test.go +++ b/internal/provider/account_test.go @@ -19,6 +19,7 @@ import ( "github.com/yetone/magpie/internal/catalog" "github.com/yetone/magpie/internal/codexcat" + "github.com/yetone/magpie/internal/plugin" "github.com/yetone/magpie/internal/testenv" ) @@ -325,10 +326,23 @@ func claudeHome(t *testing.T) string { t.Setenv("USERPROFILE", home) t.Setenv("XDG_CONFIG_HOME", filepath.Join(home, ".config")) t.Setenv("XDG_CACHE_HOME", filepath.Join(home, ".cache")) + // a plugin host is this test's HOME's: one an earlier test left up + // would answer a sign-out in that test's files, not these (#6761), so + // none is up before, and the one this test starts ends with it + stopPluginHost() + t.Cleanup(stopPluginHost) forgetClaudeCredential() return home } +// stopPluginHost stops a plugin host that is up, so the next call starts +// one under the HOME it is made in. +func stopPluginHost() { + if plugin.Running() { + plugin.Restart() + } +} + func TestClaudeAccountIsProvider(t *testing.T) { home := claudeHome(t) creds := claudeSignIn(t, home, time.Now().Add(time.Hour))