test: let the deadline policy own test waits

Vitest's expect.poll and vi.waitFor stop after one second by default, a
host-speed guess that the project's deadline policy does not see. Under
hosted-CI load, kunaProjectConcurrency failed that way twice on unrelated
PRs. Another 256 waits relied on the default, and 97 passed literals
picked to fit some host.

Waits now take as long as their test may run, less the reporting reserve
that children already keep. Each Vitest project sets expect.poll's
default, and the new waitFor in tests/support/testWait.ts replaces
vi.waitFor. Fixture readiness waits (awaitAcknowledgement and the provider
process waits) default to the same deadline, and their host-speed literal
arguments are removed. One remainingTestDeadline owns the arithmetic for
both children and waits.

Ten waits whose short timeout was the real check now assert it directly
(Kuna version probe, Cutter discovery, doctor and Inspector cancellation,
apktool fixture teardown, JADX disconnect): settlement before the
production deadline that would otherwise also satisfy the wait, or a
deadline pinned beyond every test deadline.

The rea/project-wait-deadline lint rule rejects vi.waitFor and explicit
expect.poll timeouts. The testing guide and the CI tests audit skill now
document the policy.

Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
gensokyo-devandgensokyo-dev authored and gensokyo-dev committed 2026-11-14 19:28:38 +08:00
1 parent 054fbc4c26
commit 07e4b700ac
119 files changed
+818 -648

No files matched your search

+13
View File
@@ -186,6 +186,9 @@ the caller's reason. Keep focused boundary and lifecycle tests for those facts.
operation names, schemas or types; display-only selection remains allowed.
`rea/no-fixture-root-cleanup` follows `const` fixture-root aliases into teardown
deletion; mutable bindings and mixed root arrays remain outside its scope.
`rea/project-wait-deadline` resolves Vitest's `vi` and `expect` bindings,
including aliases and namespace imports; a shadowed local or a fixture method
with the same name is not reported.
`rea/no-shared-module-mock` resolves Vitest import bindings before rejecting
module mocks in projects without per-file isolation. The test-project definitions
@@ -316,6 +319,16 @@ child fails with its captured output. Pass `timeoutMs` only when the child's dea
behavior under test. Derive an explicit deadline only when a test must outlive
an operation deadline whose diagnostics it checks.
Waits follow the same policy; Vitest's one-second `expect.poll` and
`vi.waitFor` defaults assume a host's speed. A wait may take as long as its
test may run, less the reporting reserve: projects configure `expect.poll`
that way, and `waitFor` from `tests/support/testWait.ts` replaces `vi.waitFor`.
Fixture waits such as `awaitAcknowledgement` default to the same deadline.
`rea/project-wait-deadline` rejects `vi.waitFor` and explicit poll timeouts. When promptness is the behavior under test, such as
cancellation that must preempt a slower production deadline, a wait timeout is
not its oracle: order the condition before releasing the gate that would
otherwise satisfy it, or compare elapsed time with the deadline it must beat.
Keep capacity fixtures intact when diagnosing a test failure. For byte equality
of large buffers, use `Buffer.equals` or `Buffer.compare`; a generic structural
diff can allocate far more than the production operation.