mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 03:02:56 +00:00
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:
1 parent
054fbc4c26
commit
07e4b700ac
119 files changed
+818
-648
No files matched your search
@@ -32,6 +32,7 @@ import { hashReadable } from "./ArtifactHash.js";
|
||||
import { translateArtifactFailure } from "./ArtifactOperationFailure.js";
|
||||
|
||||
import { analysisErrorUserMessage } from "../domain/analysisErrorPresentation.js";
|
||||
import { waitFor } from "../../tests/support/testWait.js";
|
||||
|
||||
const MINIMUM_ARTIFACT_EXPANDED_BYTES = 256 * 1024 * 1024;
|
||||
|
||||
@@ -398,27 +399,21 @@ describe("ZIP Zstandard member streams", () => {
|
||||
expect(decoders).toHaveLength(1);
|
||||
// A fresh decoder can succeed while an abandoned producer is stuck.
|
||||
// Verify the first actual getData and native close before starting it.
|
||||
await vi.waitFor(
|
||||
() => {
|
||||
expect(producers[0]?.settled).toBe(true);
|
||||
expect(decoders[0]?.closed).toBe(true);
|
||||
expect(decoders[0]?.destroyed).toBe(true);
|
||||
},
|
||||
{ timeout: 5_000 },
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(producers[0]?.settled).toBe(true);
|
||||
expect(decoders[0]?.closed).toBe(true);
|
||||
expect(decoders[0]?.destroyed).toBe(true);
|
||||
});
|
||||
const chunks: Buffer[] = [];
|
||||
for await (const chunk of await reader.open(entry))
|
||||
chunks.push(Buffer.from(chunk));
|
||||
expect(Buffer.concat(chunks).equals(content)).toBe(true);
|
||||
expect(producers).toHaveLength(2);
|
||||
expect(decoders).toHaveLength(2);
|
||||
await vi.waitFor(
|
||||
() => {
|
||||
expect(producers.every(({ settled }) => settled)).toBe(true);
|
||||
expect(decoders.every(({ closed }) => closed)).toBe(true);
|
||||
},
|
||||
{ timeout: 5_000 },
|
||||
);
|
||||
await waitFor(() => {
|
||||
expect(producers.every(({ settled }) => settled)).toBe(true);
|
||||
expect(decoders.every(({ closed }) => closed)).toBe(true);
|
||||
});
|
||||
} finally {
|
||||
controller.abort();
|
||||
await reader.close();
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
analyzeAppleAssetCatalogs,
|
||||
collectInterfaceBuilderResourceKeys,
|
||||
} from "./AppleAssetCatalogAnalysis.js";
|
||||
import { waitFor } from "../../../tests/support/testWait.js";
|
||||
|
||||
describe("Apple asset catalog traversal coverage", () => {
|
||||
it.for([false, true])(
|
||||
@@ -412,7 +413,7 @@ describe("Apple asset catalog and Interface Builder concurrency", () => {
|
||||
settled = true;
|
||||
});
|
||||
analysis.catch(() => undefined);
|
||||
await vi.waitFor(() => expect(catalogStarted).toBe(true));
|
||||
await waitFor(() => expect(catalogStarted).toBe(true));
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
expect(settled).toBe(false);
|
||||
finishCatalog("[]");
|
||||
@@ -452,7 +453,7 @@ describe("Apple asset catalog and Interface Builder concurrency", () => {
|
||||
signal: controller.signal,
|
||||
analyzeInterfaceBuilder: async () => emptyGraph,
|
||||
}).catch((cause: unknown) => cause);
|
||||
await vi.waitFor(() => expect(access(ready)).resolves.toBeUndefined());
|
||||
await waitFor(() => expect(access(ready)).resolves.toBeUndefined());
|
||||
controller.abort("stop asset inspection");
|
||||
expect(await settled).toMatchObject({ reason: "cancelled" });
|
||||
await expect(access(exited)).resolves.toBeUndefined();
|
||||
@@ -746,7 +747,7 @@ it.skipIf(process.platform === "win32")(
|
||||
settled = true;
|
||||
});
|
||||
try {
|
||||
await vi.waitFor(() => expect(access(exited)).resolves.toBeUndefined());
|
||||
await waitFor(() => expect(access(exited)).resolves.toBeUndefined());
|
||||
expect(settled).toBe(false);
|
||||
controller.abort("late cancellation");
|
||||
expect(settled).toBe(false);
|
||||
|
||||
Reference in new issue
Block a user