mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 11:43:20 +00:00
Retain unresolved process identity and launch evidence through retryable cleanup. Share capture path normalization and preserve failed filesystem observations. Bound child output and drain Windows pipes without one-chunk throttling. Reviewed fixes include #1628, #2632, #2644, #2784, #2928, #2931, #2965, #2992, and #3011. Validation: 92 focused source tests passed; four platform-specific skips. Real Windows and Hopper lifecycle coverage was not rerun.
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { lstat } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { expect, it } from "vitest";
|
|
|
|
import { HopperApplicationLauncher } from "../../../../src/hopper/BridgeLauncher.js";
|
|
import { createTestTempDirectory } from "../../../fixtures/temporaryDirectory.js";
|
|
|
|
it.each(["failed", "cancelled"] as const)(
|
|
"removes the token-bearing bootstrap and releases the lease after a %s launch",
|
|
async (outcome) => {
|
|
const directory = await createTestTempDirectory("rea-bootstrap-cleanup-");
|
|
const controller = new AbortController();
|
|
if (outcome === "cancelled") controller.abort();
|
|
let releases = 0;
|
|
const launcher = new HopperApplicationLauncher(
|
|
{
|
|
environment: {},
|
|
launcherPath: join(directory, "nonexistent-hopper"),
|
|
targetPath: join(directory, "test-binary"),
|
|
targetKind: "executable",
|
|
loaderArgs: [],
|
|
bridgeScriptPath: join(directory, "bridge.py"),
|
|
launchMode: "native",
|
|
},
|
|
{
|
|
platform: "darwin",
|
|
acquireTargetLease: async () => ({
|
|
acquired: true,
|
|
lease: {
|
|
release: async () => {
|
|
releases++;
|
|
},
|
|
},
|
|
}),
|
|
},
|
|
);
|
|
const result = await launcher.launch(
|
|
{
|
|
directory,
|
|
socketPath: join(directory, "bridge.sock"),
|
|
token: "fixture-token",
|
|
runId: "bootstrap-cleanup",
|
|
},
|
|
{ signal: controller.signal },
|
|
);
|
|
expect(result.ok).toBe(false);
|
|
if (outcome === "cancelled")
|
|
expect(result).toMatchObject({
|
|
ok: false,
|
|
error: { _tag: "HopperCancelledError" },
|
|
});
|
|
await expect(lstat(join(directory, "bootstrap.py"))).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
expect(releases).toBe(1);
|
|
},
|
|
);
|