From 167df7055098d0d6b5bdf7d4008c76bd5f567bae Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 16 Oct 2026 02:51:13 +0800 Subject: [PATCH] provider tests: TestSecurityKeychainAnswers's fake security is a program macOS has let run The full suite at a61a6f954 (+ #2440's helper fix, which doesn't touch internal/provider) went red in TestSecurityKeychainAnswers after 10.03s: "exit 44: the keychain didn't give it to magpie (refused, or no answer)". 10s is keychainWait. The test wrote its fake `security` with os.WriteFile, and on macOS a newly written program's first exec waits for the system's check, several seconds while a go test ./... starts its binaries, which ate the whole wait. It now writes it through testenv.Program, as the other timed fakes do, from the pool of files macOS has let run. Run: - go test ./internal/provider -run '^TestSecurityKeychainAnswers$' -count=5: ok; go test -timeout 45m ./internal/provider ./internal/claudebridge: ok. - gofmt -l clean; go vet -tags nogui darwin, linux, windows on internal/provider. - Not reproduced on purpose: the red needs the system's first-run check to be slow, which only the full run's load gave. - Full suite: go test -timeout 45m ./... at 1a16fc0b5 + these two commits, EXIT 1: 65 packages ok; internal/gui red only in TestSetAnswersWhileDevinAndProvidersHang (set slow/slow-1 took 12.4s, three suites running at once; untouched by this change), output added to #1375. --- internal/provider/codex_store_unix_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/provider/codex_store_unix_test.go b/internal/provider/codex_store_unix_test.go index 2493ea60c..7932d5cfd 100644 --- a/internal/provider/codex_store_unix_test.go +++ b/internal/provider/codex_store_unix_test.go @@ -10,6 +10,8 @@ import ( "path/filepath" "strings" "testing" + + "github.com/yetone/magpie/internal/testenv" ) // securityKeychain reads `security` as macOS answers: exit 44 is no item, @@ -32,9 +34,9 @@ delete-generic-password) exit 44 ;; esac exit 2 ` - if err := os.WriteFile(filepath.Join(bin, "security"), []byte(script), 0o755); err != nil { - t.Fatal(err) - } + // a program macOS has let run already: a new one's first exec waits for + // its check, past the keychain's wait under a full run's load + testenv.Program(t, filepath.Join(bin, "security"), script) t.Setenv("PATH", bin+string(os.PathListSeparator)+os.Getenv("PATH")) k := securityKeychain{} if _, err := k.Find(codexKeychainService, "cli|none"); !errors.Is(err, fs.ErrNotExist) {