mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 14:35:45 +00:00
test(sourcemap): repair codec deadline verification (#13057)
test(sourcemap): verify the codec deadline outside the launcher
This commit is contained in:
1 parent
9a388afdfc
commit
dc16719b04
2 files changed
+30
-51
No files matched your search
@@ -7,7 +7,6 @@ import * as processOutput from "../../process/ExecFileOutput.js";
|
||||
import {
|
||||
AnalysisCancelledError,
|
||||
AnalysisResourceConstraintError,
|
||||
AnalysisTimeoutError,
|
||||
} from "../../domain/analysisErrorCore.js";
|
||||
import { PrivateRuntimeRoot } from "../../process/PrivateRuntimeRoot.js";
|
||||
import {
|
||||
@@ -406,31 +405,3 @@ it.each([
|
||||
expect(result.error.secondaryFailures[0]?.cause).toBe(reason);
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps an observed launcher interruption at the codec deadline a timeout", async () => {
|
||||
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] });
|
||||
try {
|
||||
const result = await runSourceMapCommand(
|
||||
"{}",
|
||||
"/probe/source.map",
|
||||
undefined,
|
||||
{
|
||||
prepareOwnership: async () => {},
|
||||
launcher: async ({ signal }) => {
|
||||
await vi.advanceTimersByTimeAsync(1000);
|
||||
assertProcessOwnershipInspectionActive(signal);
|
||||
throw new Error(
|
||||
"expected the codec deadline to interrupt the launcher",
|
||||
);
|
||||
},
|
||||
},
|
||||
unexpectedCleanup,
|
||||
1000,
|
||||
);
|
||||
if (result.ok) throw new Error("expected launch timeout");
|
||||
expect(result.error).toBeInstanceOf(AnalysisTimeoutError);
|
||||
expect(result.error.secondaryFailures).toHaveLength(0);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
@@ -159,39 +159,47 @@ it.each([
|
||||
])(
|
||||
"starts the $name codec deadline after ownership preparation",
|
||||
async ({ selected, expectedMs }) => {
|
||||
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] });
|
||||
const deadlineStates: (boolean | undefined)[] = [];
|
||||
let path: string | undefined;
|
||||
const decoder = realDecoder({
|
||||
prepareOwnership: async () => {
|
||||
await vi.advanceTimersByTimeAsync(20_001);
|
||||
},
|
||||
createRuntime: async () => {
|
||||
const root = await PrivateRuntimeRoot.create();
|
||||
path = root.path;
|
||||
return root;
|
||||
},
|
||||
launcher: async ({ signal }) => {
|
||||
await vi.advanceTimersByTimeAsync(expectedMs - 1);
|
||||
deadlineStates.push(signal?.aborted);
|
||||
await vi.advanceTimersByTimeAsync(1);
|
||||
deadlineStates.push(signal?.aborted);
|
||||
assertProcessOwnershipInspectionActive(signal);
|
||||
throw new Error(
|
||||
"Expected the codec deadline to interrupt the launcher",
|
||||
);
|
||||
},
|
||||
});
|
||||
vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout", "performance"] });
|
||||
try {
|
||||
const response = await realDecoder({
|
||||
prepareOwnership: async () => {
|
||||
await vi.advanceTimersByTimeAsync(20_001);
|
||||
},
|
||||
createRuntime: async () => {
|
||||
const root = await PrivateRuntimeRoot.create();
|
||||
path = root.path;
|
||||
return root;
|
||||
},
|
||||
launcher: async ({ signal }) => {
|
||||
await vi.advanceTimersByTimeAsync(expectedMs - 1);
|
||||
expect(signal?.aborted).toBe(false);
|
||||
await vi.advanceTimersByTimeAsync(1);
|
||||
expect(signal?.aborted).toBe(true);
|
||||
throw new Error("launcher settled after deadline");
|
||||
},
|
||||
}).trace({
|
||||
const response = await decoder.trace({
|
||||
...input,
|
||||
...(selected === undefined ? {} : { decodeTimeoutMs: selected }),
|
||||
});
|
||||
if (response.ok) throw new Error("expected decode deadline");
|
||||
expect(deadlineStates).toEqual([false, true]);
|
||||
if (response.ok) throw new Error("Expected decode deadline");
|
||||
expect(response.error).toMatchObject({
|
||||
_tag: "AnalysisTimeoutError",
|
||||
userMessage: expect.stringContaining(String(expectedMs)),
|
||||
timeoutMs: expectedMs,
|
||||
userMessage: expect.stringContaining("decode_timeout_ms"),
|
||||
secondaryFailures: [],
|
||||
});
|
||||
expect(response.error.userMessage).toContain("decode_timeout_ms");
|
||||
if (path === undefined) throw new Error("runtime not acquired");
|
||||
if (path === undefined) throw new Error("Runtime not acquired");
|
||||
await expect(access(path)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
await decoder.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user