Commit e61ee68
test(plugin-dev): pay the plugin-security transform at module load, out of every clocked window (#10120)
* test(plugin-dev): warm the plugin-security import out of the enforcement-warning test bodies
bail #1 of dev-plugin-security-enforcement-warning.test.ts paid the cold vite
transform of the deliberately-unmocked real `@objectstack/plugin-security` chain
inside its own measured window, via `DevPlugin.start()`'s dynamic import. On an
idle 4-vCPU container that cost 3110/3351/3360 ms — ~70% of vitest's 5000ms
default testTimeout — while the file's other three tests cost 3-5 ms each. Under
four concurrent tsup DTS builds of plugin-dev dependents it crossed the budget on
every run (5006/5007/5006 ms, "Test timed out in 5000ms"), and bail #2 inherited
the still-cold import (2203-2931 ms) and went red with it on the busier CI shard.
Pay the import once in a `beforeAll` instead, so it lands on vitest's separate
hookTimeout (default 10000ms) and each `it` measures only the behaviour it is
about. After, same machine and same load: bail #1 is 22-26 ms idle and 29-54 ms
under the four-build load, all four tests green.
No assertion is skipped, weakened or mocked, and no timeout is raised — the four
tests remain the pins for the "nothing is enforced" warning.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PnJHU45vPJj5UQrxe946Bx
* test(plugin-dev): pay the plugin-security transform at module load, not in a clocked window
The `beforeAll` warm-up only moved the one-off `@objectstack/plugin-security`
transform from the 5000ms `testTimeout` onto the 10000ms `hookTimeout`. The
merge queue runs the FULL suite where PR-side CI runs only the affected subset,
and on that heavier shard the hook itself blew its budget — ejecting the PR four
times with `Error: Hook timed out in 10000ms.` at this file's `beforeAll`.
Replace the hook with a top-level side-effect import. Collection is the one
phase vitest 4.1.10 clocks against nothing: `@vitest/runner` wraps only hooks
and test bodies in `withTimeout(...)`, `collectTests()` awaits
`runner.importFile(filepath, 'collect')` bare and merely records
`collectDuration`, and the runner exposes exactly three timeout knobs
(`testTimeout`, `hookTimeout`, `teardownTimeout`), none covering module load.
Under an identical single-core load the file's `tests` phase drops from 7.22s to
67ms and the suite stays green even with `--hookTimeout=1`. All four #10036
assertions are untouched, and the real plugin is still imported for real.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PnJHU45vPJj5UQrxe946Bx
---------
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>1 parent 1800ffa commit e61ee68
1 file changed
Lines changed: 49 additions & 0 deletions
Lines changed: 49 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
4 | 53 | | |
5 | 54 | | |
6 | 55 | | |
| |||
0 commit comments