Commit Graph
7 Commits
Author SHA1 Message Date
yetone 0896e9fad1 provider tests: waitPast waits up to signInDeadline, as waitDone does, not 5s
c702d9cfe (#1552) moved the sign-in tests' waits from 2s to
signInDeadline (90s), since a loaded CI box runs every package's binaries
at once. waitPast, the same wait for leaving any state, kept its own 5s.
At load ~125, TestSignInInstallsMissingCLI and TestMovedSignInAsBuiltIn
went red here with "still installing" after 5.0-5.8s, 3 of 40 runs.
waitPast returns as soon as the state moves, so the longer bound costs a
passing run nothing.

Ran:
- 6s injected into both fake installers after their release: the old
  bound red in both ("still installing"), this one green.
- go test ./internal/provider (at load ~120); gofmt -l; go vet, GOOS=linux
  and GOOS=windows go vet ./internal/provider.
2026-10-11 19:28:08 +08:00
yetone 2ff4ecb42d provider: the Devin install tests' held installer gives up when its test ends, and writes the CLI without the test's t
TestSignInInstallsMissingCLI and TestMovedSignInAsBuiltIn hold their fake
installer on a channel the test closes only after its first checks. A
Fatal before that left the installer blocked for the rest of the package's
run. f3c098da8 fixed the same hold in the Grok sibling with a cleanup;
these two were already gated and kept the leak. The hold now also ends on
the test's cleanup, and the installer returns an error then.

The installsMissingCLI fake also called testenv.Program(t, ...) on the
sign-in's goroutine. Under load (~125) its test hit waitPast's 5s first,
and the fake's late t.Fatal panicked the whole package ("Fail in goroutine
after TestSignInInstallsMissingCLI has completed"). It now uses
testenv.WriteProgram and returns the error.

Ran:
- An injected t.Fatal right after StartSignIn / StartPluginSignIn, plus a
  test that dumps goroutines a second later: on origin/main the fake is
  still blocked at install_test.go:40; with this, nothing is left.
- -race -count=20 of both tests, 2 runs each beside origin/main at load
  ~125-140: green on both.
- gofmt -l; go vet, GOOS=linux and GOOS=windows go vet ./internal/provider.
2026-10-11 19:28:08 +08:00
yetone 522da8f2e7 provider: Grok and Devin install in the Docker image again: a vendor's shell one-liner needs curl, which the image (bash and busybox wget since 7bfe3137) doesn't have, so the native installer runs there
ghcr.io/yetone/magpie:latest has /bin/bash and /bin/wget but no curl, so
shellInstallerRuns said yes and `curl … | bash` failed. TestShellInstallerNeedsCurl
fails on the old check.
2026-10-08 09:01:23 +08:00
hisilingandSiling 84d2d75205 provider: Windows 上 Devin 的登录装得上 Devin CLI 了:安装命令从 stdin 进 PowerShell,devin setup 不再卡住登录 (#1225) (#1226)
* provider: a sign-in on Windows installs its CLI past Microsoft Defender, which stopped the installer's command line as a Trojan (#1225)

On Windows the sign-in ran the vendor's installer as `powershell -NoProfile -ExecutionPolicy Bypass -Command irm https://static.devin.ai/cli/setup.ps1 | iex`, and Microsoft Defender takes that command line for Trojan:Win32/Commando.A!ml. It stopped PowerShell before it ran, so Devin's sign-in failed with "installing Devin CLI failed (fork/exec C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe: Access is denied.)" while Windows Security said it found a threat (hisiling, Windows 11, v0.1.1106, three tries, three detections). The one-liner now reaches `powershell -NoProfile -ExecutionPolicy Bypass -Command -` on stdin, as one typed into PowerShell does, so no command line carries it. Cursor's and Grok's installers go the same way. The installer's output and exit code come back as before, and one that would ask something still reads nothing.

TestWindowsInstallerNotOnCommandLine fails without the change on Windows 11 (PowerShell's command line carries the installer: powershell -NoProfile -ExecutionPolicy Bypass -Command "Write-Output ([Environment]::CommandLine); exit 7") and passes with it. On the same machine, with Defender's real-time protection on, Devin's sign-in started the way the window's button starts it (provider.StartSignIn, from a program with no console) ran the real setup.ps1 with no detection and installed Devin CLI 3000.11.3. go vet ./internal/provider and go test -run 'Install|SignIn' ./internal/provider pass on Windows; go vet -tags nogui ./..., go build -tags nogui ./..., GOOS=windows go build ./... and the windowsgui build pass on Linux.

* provider: Devin's sign-in on Windows goes on once the Devin CLI is in place, where its installer's `devin setup` held it for ten minutes and was left running (#1225)

Devin's setup.ps1 ends in `devin setup`, whose menu asking how to sign in waits for a key on the console. The console an installer gets from magpie has no window (the app has none, so its children get CREATE_NO_WINDOW) and magpie keeps its output, so no one can answer it: the sign-in stayed "installing" until installTimeout ended the installer ten minutes later, and `devin setup` went on running. It waits the same way with stdin from NUL, and CI=true or TERM=dumb don't change it; `devin setup` has no option but --force-manual-token-flow. On Windows, the installer of a CLI marked setup (Devin's) now runs as a proc.Tree. Once the CLI is in place, read with the user PATH the installer wrote, it has installerTail (5s) to end by itself, then it is ended with everything it started, as it is when the sign-in is canceled or times out. magpie's own sign-in follows as before. Cursor's and Grok's installers, and every installer off Windows, run as they did.

TestWindowsDevinSetupDoesNotHoldTheSignIn fails without the change on Windows 11 (the sign-in waited 47s for the installer after the CLI was in place, installTimeout set to 45s) and passes with it in 6s, its setup ended. On the same machine the real Devin sign-in went from installing to Devin's sign-in page in 18s, with no devin.exe or PowerShell left running and setup.ps1's distribution marker and user PATH written; with the first change alone it took ten minutes and left `devin.exe setup` running. go vet ./internal/provider and go test -run 'Install|SignIn|NotOnCommandLine|DevinSetup' ./internal/provider pass on Windows; GOOS=windows go vet ./internal/provider ./internal/proc passes on Linux.

---------

Co-authored-by: Siling <179151647+hisiling@users.noreply.github.com>
2026-10-08 08:58:15 +08:00
yetone 06420a7121 tests: a fake program is a file macOS has already let run (testenv.Program), so a fake's first start no longer eats a test's wait under load
macOS checks a newly written executable before its first exec: 0.27s
alone, 2-5s while other new programs start (a go test ./... starting its
test binaries). The same file again takes 0.009s, and the pass is kept
across a rename and an in-place rewrite. 108852b4 worked round this for one
test with /bin/sh -c; the class was every test that writes a `#!/bin/sh`
fake and times its answer.

testenv.Program(t, path, script) replaces os.WriteFile(path, script, 0o755)
for fakes. On macOS it renames a file that has run once from a pool to path
and writes the script into it in place; at the test's cleanup the file goes
back to the pool (only a path the test created; a stand-in it wrote over
stays). Fakes still end with their tests: nothing about how they are
started or waited on changed. Run (and gateway's TestMain) remove the pool
at the end. TestMain's PATH stand-ins are run once in the background
(testenv.StandIns). Other systems write the file as before.

Converted every `#!/bin/sh` fake written by tests under internal/ (agent,
gateway, gui, library, plugin, proc, provider, update). Windows, binary
and node/bun fakes are unchanged.

Under the same load (3 loops each starting 8 freshly written scripts at a
time), 4 rounds each, before (108852b4 / origin/main) vs after:
- provider TestSavedButSignedOutClaudeServed: 4/4 fail (8.01s) -> 4/4 pass
- provider TestClaudeSignInOverStaleCredentials: 4/4 fail (5.00s) -> 4/4 pass
- provider TestDevinSignedInOnlyInMagpie: 3/4 fail ("CLI's own []") -> 4/4 pass
- gateway TestClaudeRunEndsWhenTheClientLeaves: 4/4 fail -> 4/4 pass
  (and 3/3 fail -> 3/3 pass at a third of that load)
- gateway TestClientGoneRecordedAsCanceled: 4/4 fail -> 4/4 pass
- gui TestProvidersAnswerWhileListsComeIn ("cursor found false" at 3.03s):
  4/4 fail -> 4/4 pass. The same class, not bfe8bcaf's test order.
- proc TestUserPath (login shell's PATH never came, 7.01s): 4/4 fail ->
  4/4 pass
Unloaded, every touched package passes; no pool directory or process is
left after a run.
2026-10-07 03:00:47 +08:00
yetone a2714f7506 claude: a Claude account's usage resets are read in the zone /usage names on Windows too, and the provider tests pass whole on Windows (goal: 插件订阅 provider 跟内置的所有逻辑都要一模一样, run on Windows and Linux) — Windows has no time zone database, so "resets Oct 1 at 3:30pm (Asia/Shanghai)" was read in the machine's own zone, hours off for anyone not in that zone; magpie now carries the database (time/tzdata). The provider tests set HOME but not USERPROFILE, which Windows takes the home from, so on Windows they read the test box's own agent sign-ins (Gemini models in a list, an extra provider, a Cursor version); every test home sets both now. Tests whose fake CLI is a shell script (Claude Code's auth status, codex --version, macOS's security) skip on Windows, as the fake devin did, and file mode bits go unchecked there. TestParseClaudeUsage fails on Windows without the change. On Windows and on Linux (WSL) the provider package passes whole, three times on Windows (15 failed before), the plugin package and the move/plugin/Grok/Devin/usage tests five times over on Linux. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. 2026-10-01 13:51:24 +08:00
yetone e072af501d provider: a subscription used through its vendor's CLI — Devin's, Cursor's, Grok's — installs that CLI when its sign-in starts, if this machine lacks it, rather than leaving the sign-in to fail or, as Devin's did, to say "signed in" and show nothing: Devin's sign-in wrote credentials.toml, but magpie sees the account only through devin auth status, so with no devin CLI no provider ever came and nothing said why. The sign-in is now "installing" while the vendor's own installer runs (curl … | bash, or its PowerShell one on Windows, with magpie's proxy), then opens the vendor's page as before; the window says what it is installing and why, can cancel it, and a failed install says the installer's last line and the command to run by hand. What counts is the CLI being there afterwards — Devin's installer ends in devin setup, whose sign-in gives up without a terminal and fails the script after it installed everything — and on Windows the PATH the installer wrote is taken up so the running app finds it. A Devin sign-in the CLI then can't see fails, where it said done with no one; the tests no longer see this machine's own devin 2026-09-25 16:30:00 +08:00