Files
plugins/packages/window-warmup/tests
zhou.han b4916d4143 window-warmup tests: put XDG_CONFIG_HOME and XDG_CACHE_HOME back after each file (#996, #1001)
window-warmup's tests no longer leave XDG_CONFIG_HOME and XDG_CACHE_HOME set for every later file of the root `bun test` (#996).

What changed (test files only; no runtime code, no version bump, no dist rebuild):
- tests/fake-gateway.ts no longer sets the two XDG variables on import. Its `--serve` demo calls the new pinMagpieDirs() first, so the demo still runs with the temporary dirs.
- tests/test-env.ts: pinMagpieDirsForTest() records the inherited values, pins both to $TMPDIR/window-warmup-test-magpie-{config,cache}, and returns a restore that puts back each inherited value, or deletes one that wasn't set.
- browser, diagnostics, gateway, scheduler and server tests pin at load and restore in afterAll (in a finally after their own cleanup). diagnostics' own override is put back before the file's pin is.
- Every test file that imports fake-gateway.ts, or reaches magpieDirs()' defaults through startService/Scheduler, pins its own; magpie-files and store tests pass env explicitly.

Run at the reviewed head c13d2844 (its parent is origin/main 740e1af2), on magpie-desktop (WSL Ubuntu 24.04, Bun 1.4.2), HOME=$(mktemp -d):
- bun test packages/window-warmup plus a trailing probe file asserting both variables are back: 280 pass, 0 fail with both unset (probe sees null/null), and with both inherited as /tmp/inh-cfg and /tmp/inh-cache (probe sees them exactly).
- bun scripts/check.mjs window-warmup: ok.
- Root bun test (both XDG unset): 8298 pass, 2 skip, 0 fail, 8317 tests in 584 files.

Broken by hand, same probe:
- test-env.ts restore made a no-op: probe red (sees the window-warmup temp dirs).
- only server.test.ts skipping its restore: probe red.
- origin/main's window-warmup tests (740e1af2) with the probe: red, as #996 describes.

Not tried: `bun run typecheck` (CI doesn't run it either), and Windows.
2026-11-11 20:39:49 +08:00
..