test: reduce brittle assertions and test-only runtime paths (#9289)

* test: focus assertions on behavioral evidence

Prune redundant and wording-coupled checks while retaining diagnostic, parser, recovery, and cleanup coverage.

* refactor: remove test-only wrappers and duplicate checks

Exercise production operations through test fixtures, remove unused adapters, and keep managed-member uncertainty guidance under its existing owner.

* test: focus process validation on diagnostic facts

* refactor: remove test-only runtime helpers

Move semantic evidence fixture setup out of runtime and remove unused Windows settle recovery helpers while checking configured defaults independently.

* test: focus artifact diagnostics on format facts

* test: verify retained cleanup guidance delivery
This commit is contained in:
morluto authored and GitHub committed 2026-11-08 02:02:31 +08:00
1 parent 5679ed66f4
commit 352a846127
268 files changed
+586 -1141

No files matched your search

@@ -6,7 +6,6 @@ import { projectAnalysisError } from "../../domain/analysisErrorProjection.js";
import {
javaScriptForwardedTransferRemediation,
javaScriptTransferByteBudget,
javaScriptTransferCeilingRemediation,
measureJavaScriptModuleTransfer,
} from "./JavaScriptAnalysisTransfer.js";
@@ -35,9 +34,15 @@ it("distinguishes the adjustable transfer file ceiling from the fixed record and
},
},
});
expect(projected.remediation.action).toBe(
javaScriptTransferCeilingRemediation(measured.bytes - 1),
expect(projected.remediation.action).toContain(String(measured.bytes - 1));
expect(projected.remediation.action).toMatch(
/8388608.byte.*2147483648.byte.*no runtime override/iu,
);
expect(projected.remediation.action).toMatch(
/source_paths.*effective file allowance/iu,
);
expect(projected.remediation.action).toMatch(/max_heap_mb does not raise/iu);
expect(projected.remediation.action).toMatch(/repeated unchanged/iu);
const forwarded = javaScriptForwardedTransferRemediation(
caught.reportedLimits,
);
@@ -45,7 +50,10 @@ it("distinguishes the adjustable transfer file ceiling from the fixed record and
const recordOnly = javaScriptForwardedTransferRemediation({
transfer_record_bytes: 8_388_608,
});
expect(recordOnly).toBe(javaScriptTransferCeilingRemediation(undefined));
expect(recordOnly).toMatch(
/effective transfer file ceiling follows.*parent.*heap/iu,
);
expect(recordOnly).toMatch(/record ceiling.*maximum.*no runtime override/iu);
expect(javaScriptForwardedTransferRemediation(null)).toBeUndefined();
});
@@ -53,7 +61,9 @@ it("keeps the 2 GiB transfer file maximum fixed", () => {
const maximum = 2_147_483_648;
expect(javaScriptTransferByteBudget(maximum * 8)).toBe(maximum);
expect(javaScriptTransferByteBudget(maximum * 16)).toBe(maximum);
expect(
javaScriptForwardedTransferRemediation({ transfer_file_bytes: maximum }),
).toBe(javaScriptTransferCeilingRemediation(maximum));
const recovery = javaScriptForwardedTransferRemediation({
transfer_file_bytes: maximum,
});
expect(recovery).toMatch(/2147483648.byte.*maximum.*no runtime override/iu);
expect(recovery).toMatch(/fewer source_paths does not raise.*maximum/iu);
});
@@ -99,7 +99,6 @@ it("preserves the exact object reason for an already-aborted caller", async () =
},
unexpectedCleanup,
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected cancellation");
expect(result.error).toBeInstanceOf(AnalysisCancelledError);
expect(result.error.cause).toBe(reason);
@@ -178,7 +177,6 @@ it("preserves exact caller reason when cancellation precedes process exit", asyn
},
() => setTimeout(() => controller.abort(reason), 0),
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected cancellation");
expect(result.error).toBeInstanceOf(AnalysisCancelledError);
expect(result.error.cause).toBe(reason);
@@ -222,7 +220,6 @@ it("preserves an observed nonzero exit before caller cancellation during output
waitSpy.mockRestore();
}
expect(observedBeforeAbort).toEqual({ code: 7, signal: null });
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected physical failure");
expect(result.error._tag).toBe("ProviderAdapterError");
expect(result.error.diagnostics).toMatchObject({
@@ -236,7 +233,6 @@ it("preserves an observed nonzero exit before caller cancellation during output
it("classifies the same nonzero exit without cancellation", async () => {
const result = await runChild(undefined, exitsAfterHoldingOutput);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected physical failure");
expect(result.error).toMatchObject({
_tag: "ProviderAdapterError",
@@ -255,7 +251,6 @@ it("stops a held drain after late output exceeds budget but keeps the exit prima
exitsThenDescendantExceedsStderrBudget,
);
const elapsedMs = performance.now() - startedAt;
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected physical failure");
expect(result.error._tag).toBe("ProviderAdapterError");
expect(result.error.diagnostics).toMatchObject({
@@ -322,7 +317,6 @@ it("preserves an observed process-memory limit over the codec exit status", asyn
waitSpy.mockRestore();
}
expect(observedBeforeAbort).toEqual({ code: 3, signal: null });
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected memory-limit failure");
expect(result.error).toBeInstanceOf(AnalysisResourceConstraintError);
expect(result.error).toMatchObject({
@@ -363,7 +357,6 @@ it("keeps a timeout distinct from caller cancellation", async () => {
},
unexpectedCleanup,
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected timeout");
expect(result.error).toBeInstanceOf(AnalysisTimeoutError);
if (runtimePath === undefined) throw new Error("runtime was not acquired");
@@ -400,7 +393,6 @@ it("applies a non-default decode deadline and releases its runtime", async () =>
unexpectedCleanup,
250,
);
expect(result.ok).toBe(false);
if (result.ok) throw new Error("expected timeout");
expect(result.error).toBeInstanceOf(AnalysisTimeoutError);
expect(result.error.userMessage).toContain("250");
@@ -30,7 +30,6 @@ it("preserves the exact caller reason before source-map admission", async () =>
const response = await new SourceMapDecoder().trace(input, {
signal: controller.signal,
});
expect(response.ok).toBe(false);
if (response.ok) throw new Error("expected cancellation");
expect(response.error).toBeInstanceOf(AnalysisCancelledError);
expect(response.error.cause).toBe(reason);