provider tests: TestSecurityKeychainAnswers's fake security is a program macOS has let run
The full suite ata61a6f954(+ #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 ./... at1a16fc0b5+ 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.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user