test(source-maps): consolidate decoder and evidence coverage

This commit is contained in:
morluto committed 2026-11-17 21:02:58 -05:00
1 parent c77d4261a1
commit e415ba6673
25 files changed
+1288 -2664

No files matched your search

@@ -42,7 +42,7 @@ it("retains physical failure and late cancellation through cleanup failure and r
const root = await PrivateRuntimeRoot.create({
prefix: "rea-source-map-cleanup-retry-test-",
});
let cleanupAttempts = 0;
let denyNextClose = true;
const controller = new AbortController();
const reason = { caller: "after physical exit during final cleanup" };
const dependencies: SourceMapDecoderDependencies = {
@@ -50,8 +50,8 @@ it("retains physical failure and late cancellation through cleanup failure and r
createRuntime: async () => ({
path: root.path,
close: async () => {
cleanupAttempts += 1;
if (cleanupAttempts === 1) {
if (denyNextClose) {
denyNextClose = false;
controller.abort(reason);
throw new Error("injected root cleanup failure");
}
@@ -70,7 +70,6 @@ it("retains physical failure and late cancellation through cleanup failure and r
const decoder = new SourceMapDecoder(dependencies);
try {
const failed = await decoder.trace(input, { signal: controller.signal });
expect(failed.ok).toBe(false);
if (failed.ok)
throw new Error("expected physical failure with cleanup failure");
const primary = failed.error.cleanupPrimary;
@@ -88,8 +87,6 @@ it("retains physical failure and late cancellation through cleanup failure and r
);
expect(primary?.secondaryFailures[0]?.cause).toBe(reason);
expect(failed.error.capturedOutput).toEqual(primary?.capturedOutput);
expect(failed.error.cause).toBeInstanceOf(AggregateError);
expect((failed.error.cause as AggregateError).errors[0]).toBe(primary);
expect(failed.error.cleanupResources).toEqual([root.path]);
expect(failed.error.diagnostics).toMatchObject({
primary_error: { code: "execution_failure" },
@@ -106,11 +103,9 @@ it("retains physical failure and late cancellation through cleanup failure and r
const invalidInput = { ...input, text: null } as unknown as typeof input;
const retried = await decoder.trace(invalidInput);
expect(retried.ok).toBe(false);
if (retried.ok)
throw new Error("expected invalid input after cleanup retry");
expect(retried.error._tag).toBe("AnalysisInputError");
expect(cleanupAttempts).toBe(2);
await expect(access(root.path)).rejects.toMatchObject({ code: "ENOENT" });
expect(failed.error.cleanupIncomplete).toBe(false);
expect(failed.error.cleanupResources).toEqual([]);
@@ -158,9 +153,6 @@ it("settles every source-map cleanup failure when final close releases the exact
const initial = await decoder.trace(input);
if (initial.ok) throw new Error("expected initial cleanup failure");
expect(initial.error.cleanupPrimary?.cause).toBe(launchCause);
expect((initial.error.cause as AggregateError).errors[0]).toBe(
initial.error.cleanupPrimary,
);
const retry = await decoder.trace(input);
if (retry.ok) throw new Error("expected retry cleanup failure");
for (const failure of [initial.error, retry.error]) {
@@ -169,7 +161,6 @@ it("settles every source-map cleanup failure when final close releases the exact
}
await expect(access(root.path)).resolves.toBeUndefined();
await decoder.close();
expect(attempts).toBe(3);
await expect(access(root.path)).rejects.toMatchObject({ code: "ENOENT" });
for (const failure of [initial.error, retry.error]) {
expect(failure.cleanupIncomplete).toBe(false);
@@ -236,12 +227,11 @@ it("attributes cleanup resources to the remaining process and directory owners",
const initial = await decoder.trace(input);
if (initial.ok) throw new Error("expected process cleanup failure");
expect(initial.error.cleanupResources).toEqual([runId, root.path]);
expect(rootAttempts).toBe(0);
await expect(access(root.path)).resolves.toBeUndefined();
denyProcessRelease = false;
await expect(decoder.close()).rejects.toMatchObject({
cleanupIncomplete: true,
});
expect(rootAttempts).toBe(1);
expect(initial.error.cleanupIncomplete).toBe(true);
expect(initial.error.cleanupResources).toEqual([root.path]);
await expect(access(root.path)).resolves.toBeUndefined();