Files
magpie/internal/testenv
yetone ce13984567 testenv: a stand-in codex is found before the installed one on Windows, so the gateway's tests don't read the user's Codex version (#1827, EdwinDigital)
Windows finds a program through PATHEXT and skips a file with no
extension. testenv.inertTools wrote a .bat beside each #!/bin/sh stand-in.
The gateway's TestMain calls StandIns directly, though, and StandIns wrote
only the extensionless file. On a box with Codex installed, LookPath went
past the stand-in to the user's codex.cmd.
TestCodexPoolSaysTheClientsVersion then saw the installed 0.162.0 instead
of its fixture's 0.161.0, which is exactly what EdwinDigital reported. The
.bat is now written in StandIns, so every caller gets it.

TestStandInsComeBeforeTheInstalled puts StandIns("codex") on PATH first
and an "installed" codex (codex.cmd on Windows) that prints 0.162.0
further down. LookPath must pick the stand-in, and running it must fail
with no output.

Run:
- gofmt -l is clean.
- go vet passes for darwin, linux -tags nogui and windows (testenv and
  gateway).
- go test ./internal/testenv/ passes on macOS.
- Windows 11 x64 box (ssh), test binaries cross-built with Go 1.26.8.
  A fake codex.cmd printing "codex-cli 0.162.0" was on PATH.
  - The gateway binary before this change fails
    TestCodexPoolSaysTheClientsVersion with EdwinDigital's error (UA
    codex_cli_rs/0.162.0). The binary after it passes.
  - The testenv binary before this change fails the new test, and the one
    after it passes.
- Full gateway binary on that box, with its testdata copied (no source
  tree): the same failures before and after. They are source-reading tests
  that need the checkout, and TestClaudeAsRootEnv (#1827). The one
  exception is TestQueuedStreamKeptAliveForASlot, which failed once in the
  run after this change. It passes 5 of 5 alone on both binaries. Its cause
  is Windows' ~0.5ms clock tick in a strict Before (filed as #2249).
2026-10-15 02:36:26 +08:00
..
gateway, provider tests: the tests stay off the network (testenv.Offline in their TestMains) — after 555f5706 (#1016) routing reads a plan key's quota windows, and a test whose provider has a vendor's real base URL and a made-up key would ask the vendor in the background. Routing's own read (keyAllowance, allowances) was already stubbed in routing_test.go's init, and a survey with a dial guard found no plan-key dial, but it found others: every plugin host's first start fetched models.dev's catalog (65 dials in the gateway's plugin tests), and provider tests asked api.github.com (TestSubscriptionUsageEachAccount, TestSubscriptionUsageServesStale), chatgpt.com (TestCopilotQuotaWithoutEditorsSignIn), server.codeium.com (TestDevinSignedInOnlyInMagpie) and decide.test (TestModelTest) with made-up accounts; each passed whether the vendor answered or not. internal/testenv's Offline wraps http.DefaultTransport's DialContext (so http.DefaultClient and every transport cloned from it later): localhost, *.localhost, loopback and unspecified addresses are dialled, anything else is refused before it is looked up, said once per address on stderr ("testenv: a test asked models.dev:443, refused: tests stay off the network"). internal/gateway's TestMain and internal/provider's (kiro_main_test.go, in RunIn's setup) call it before the tests run. TestLocal (the address table) and TestOffline (a loopback httptest server answers through DefaultClient; models.dev is refused through it and through a Clone made after the call) pass -race -count=3. go test -race -tags nogui -timeout 30m ./internal/testenv ./internal/provider ./internal/gateway passes under a temp HOME (gateway 516 s). The gateway and provider test binaries were then run under sandbox-exec with every non-loopback network-outbound denied, with the kernel's Sandbox reports streamed: both PASS, Offline refused only the six addresses above, and the kernel reported no denial, so no transport outside DefaultTransport reaches the network either. go vet, gofmt -l, linux and windows (nogui) builds pass. Tests only.
2026-10-06 21:08:57 +08:00
gateway, provider tests: the tests stay off the network (testenv.Offline in their TestMains) — after 555f5706 (#1016) routing reads a plan key's quota windows, and a test whose provider has a vendor's real base URL and a made-up key would ask the vendor in the background. Routing's own read (keyAllowance, allowances) was already stubbed in routing_test.go's init, and a survey with a dial guard found no plan-key dial, but it found others: every plugin host's first start fetched models.dev's catalog (65 dials in the gateway's plugin tests), and provider tests asked api.github.com (TestSubscriptionUsageEachAccount, TestSubscriptionUsageServesStale), chatgpt.com (TestCopilotQuotaWithoutEditorsSignIn), server.codeium.com (TestDevinSignedInOnlyInMagpie) and decide.test (TestModelTest) with made-up accounts; each passed whether the vendor answered or not. internal/testenv's Offline wraps http.DefaultTransport's DialContext (so http.DefaultClient and every transport cloned from it later): localhost, *.localhost, loopback and unspecified addresses are dialled, anything else is refused before it is looked up, said once per address on stderr ("testenv: a test asked models.dev:443, refused: tests stay off the network"). internal/gateway's TestMain and internal/provider's (kiro_main_test.go, in RunIn's setup) call it before the tests run. TestLocal (the address table) and TestOffline (a loopback httptest server answers through DefaultClient; models.dev is refused through it and through a Clone made after the call) pass -race -count=3. go test -race -tags nogui -timeout 30m ./internal/testenv ./internal/provider ./internal/gateway passes under a temp HOME (gateway 516 s). The gateway and provider test binaries were then run under sandbox-exec with every non-loopback network-outbound denied, with the kernel's Sandbox reports streamed: both PASS, Offline refused only the six addresses above, and the kernel reported no denial, so no transport outside DefaultTransport reaches the network either. go vet, gofmt -l, linux and windows (nogui) builds pass. Tests only.
2026-10-06 21:08:57 +08:00