From df49305e22b45ab9dc9635aaa842ecdf93da80c8 Mon Sep 17 00:00:00 2001 From: yetone Date: Mon, 12 Oct 2026 00:39:50 +0800 Subject: [PATCH] agent: TestOmo and TestJcodeHome no longer fail where omo or jcode is installed (#1646, ggbdpq) Both tests check that the agent is not detected before its folder exists. Detected also looks for the agent's command on PATH, so an omo or jcode installed on the host made the tests fail. Both tests now run with an empty temp dir as PATH. The TestOmo line is the reporter's. To find every test with this problem, the whole agent package was run with a fake executable on PATH for each agent id and Bin (145 names): - TestOmo and TestJcodeHome failed. - TestInstallWithoutNodeStopsWhenTheDownloadFails also failed, but only because the fake curl stood in for the real one. That is not an agent detection. With this change, both tests pass with the fakes on PATH. go test -tags nogui ./internal/agent/ is green, and gofmt -l and go vet are clean on darwin, linux and windows. --- internal/agent/jcode_test.go | 1 + internal/agent/omo_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/internal/agent/jcode_test.go b/internal/agent/jcode_test.go index 86fe8bb08..f94c1d8fa 100644 --- a/internal/agent/jcode_test.go +++ b/internal/agent/jcode_test.go @@ -284,6 +284,7 @@ X-Team = "mine" // the file while jcode still starts on it is said. func TestJcodeHome(t *testing.T) { home, _ := jcodeHome(t, "") + t.Setenv("PATH", t.TempDir()) // no jcode on PATH: only its folder tells (#1646) dir := filepath.Join(home, "elsewhere") t.Setenv("JCODE_HOME", dir) a := jcode(home) diff --git a/internal/agent/omo_test.go b/internal/agent/omo_test.go index b8c2a6aed..7a40affb8 100644 --- a/internal/agent/omo_test.go +++ b/internal/agent/omo_test.go @@ -18,6 +18,7 @@ import ( // Pi's ~/.pi is left alone; its own model takes magpie out again. func TestOmo(t *testing.T) { home := syncHome(t) + t.Setenv("PATH", t.TempDir()) // no omo on PATH: only its folder tells (#1646) var a *Agent for _, x := range All() { if x.ID == "omo" {