Files
magpie/internal/testenv
yetone 500f39886e testenv: a package's own run fails on a package-level regexp it compiles at launch
TestNoEagerPackageRegexps lives in the root package, and a change runs
its own packages, so the guard went red on main on six days: #6020,
#6145, 4847a087f, 10e783080, 7869a454c and today 8f3f7a46a (fixed in
022ffd09e). LESSONS.md asked on 11-12 for the check to run where the
work already runs; writing the rule again hadn't held.

testenv.RunIn (every testenv.Main/Run TestMain, 65 packages, provider,
gui, update, library and catalog among them) now checks the package's
own non-test files after its tests and exits 1 naming each pattern. It
runs on a `-run` of one test too. The parsing moved into
testenv.EagerRegexps, which the root guard now calls, so both read the
same rule. A child test binary (Marker set) doesn't check again.

Run on mote at this tree (origin/main 022ffd09e + this):
- go test -count=1 ./internal/testenv .: ok (TestEagerRegexps new:
  lines 5 and 8 listed; a func's, a func literal's and lazyre.New not)
- Broken by hand: zz_probe.go with `var eagerProbe =
  regexp.MustCompile("x")` in internal/update; `go test -run
  TestNothingMatchesThis ./internal/update` FAIL with "testenv: a
  package-level regexp is compiled at launch; use lazyre.New:
  zz_probe.go:5:18"; removed, ok.
- GOOS=windows go vet and GOOS=linux go vet -tags nogui of
  ./internal/testenv and .: clean
- gofmt -l: clean
Not run: every testenv package; the root guard passing at this tree
says none of them has such a pattern, so none fails on the new check.
2026-11-16 02:42:56 +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