mirror of
https://github.com/morluto/rea.git
synced 2026-11-09 08:17:02 +00:00
Keep failed stable-read handles and WABT runtime roots under retryable resource scopes. Preserve cancellation causes and primary errors, close the same service instances bound to MCP tools, and consolidate CLI operation/cleanup projection. Validation: fast typecheck and lint, cached runtime build, docs checks, SDK schema validation, focused service and real-file cleanup tests, CLI cleanup regressions, and MCP lifecycle/shutdown workflows. Provider process fixtures simulate engine output; real WABT and Linux EVM execution are not established by this pass.
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import { access } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { expect, it, onTestFinished } from "vitest";
|
|
import { AnalysisCancelledError } from "../../../src/domain/analysisErrorCore.js";
|
|
import { ArtifactResourceScope } from "../../../src/artifacts/ArtifactResourceScope.js";
|
|
import {
|
|
createTestWorkspace,
|
|
removeTestWorkspace,
|
|
} from "../../../tests/support/workspace/workspaceFixture.js";
|
|
import { inspectPwndbgCore } from "../../../src/native/pwndbg/PwndbgCoreContext.js";
|
|
|
|
const diagnostics = { stdout: "", stderr: "", truncated: false };
|
|
|
|
it.each(["pre-aborted", "aborted-during-probe"] as const)(
|
|
"cancellation wins over debugger path failures: %s",
|
|
async (scenario) => {
|
|
const workspace = await createTestWorkspace("rea-pwndbg-cancel-");
|
|
onTestFinished(() => removeTestWorkspace(workspace.root));
|
|
const controller = new AbortController();
|
|
const gdb = join(workspace.root, "missing-gdb");
|
|
let probes = 0;
|
|
const probePath = async () => {
|
|
probes++;
|
|
if (scenario === "aborted-during-probe") {
|
|
await new Promise<void>((resolve) => {
|
|
setImmediate(() => {
|
|
controller.abort();
|
|
resolve();
|
|
});
|
|
});
|
|
throw new Error("path became unavailable");
|
|
}
|
|
throw new Error("path is unavailable");
|
|
};
|
|
if (scenario === "pre-aborted") controller.abort();
|
|
await expect(
|
|
inspectPwndbgCore({
|
|
environment: {
|
|
REA_PWNDBG_GDB: gdb,
|
|
REA_PWNDBG_GDBINIT: join(workspace.root, "missing-init"),
|
|
REA_PWNDBG_VENV_PATH: join(workspace.root, "missing-venv"),
|
|
},
|
|
rootPath: workspace.root,
|
|
resources: new ArtifactResourceScope(),
|
|
diagnostics,
|
|
options: { signal: controller.signal },
|
|
probePath,
|
|
runCommand: () => {
|
|
throw new Error("No process should exist before cancellation");
|
|
},
|
|
}),
|
|
).rejects.toBeInstanceOf(AnalysisCancelledError);
|
|
expect(probes).toBe(scenario === "pre-aborted" ? 0 : 1);
|
|
await expect(
|
|
access(join(workspace.root, "debugger")),
|
|
).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
},
|
|
);
|