mirror of
https://github.com/morluto/rea.git
synced 2026-11-22 22:45:47 +00:00
* test(providers): own temporary directories through createTestTempDirectory Route provider-boundary fixtures through createTestTempDirectory so each case removes its canonical directory after the test. Process shutdown stays in afterEach, which still runs before that removal. Skip the two Windows Cutter checks with it.skipIf, and compare unknown plugin recovery with cutterBridgeSourceRecovery. * test(providers): keep gated fixture cleanup with its owner createTestTempDirectory always deletes after the test, including when GDB or inferior cleanup fails and when the Rizin MCP harness already owns the directory. Restore mkdtemp removal behind confirmed process cleanup, and leave decoder inputs owned by the harness. Co-authored-by: morluto <morluto@users.noreply.github.com> * test(cutter): keep an independent unknown-source recovery check Comparing discovery recovery with cutterBridgeSourceRecovery follows the formatter, so dropping the unknown-source explanation still passes. Assert that explanation directly, beside bridge_source and the plugin path. Co-authored-by: morluto <morluto@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
116 lines
3.7 KiB
TypeScript
116 lines
3.7 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { spawnSync } from "node:child_process";
|
|
import { existsSync, realpathSync, writeFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
import {
|
|
capturedHomePlan,
|
|
launchCommand,
|
|
} from "../../../src/domain/desktop/appExport.js";
|
|
import { planLaunch } from "../../../src/application/desktop/DesktopExportLaunch.js";
|
|
import type { DesktopApplicationCapture } from "../../../src/domain/desktop/desktopCapture.js";
|
|
|
|
it.skipIf(process.platform === "win32").each([
|
|
["--chdir", false],
|
|
["-iC", true],
|
|
])(
|
|
"replays an empty directory selected by env %s with the expected environment",
|
|
async (option, clean) => {
|
|
const home = await createTestTempDirectory("rea-working-home-");
|
|
const selected = "Projects/Empty workspace";
|
|
const capture = {
|
|
host: { home: "/home/ada" },
|
|
application: {
|
|
argv: [
|
|
"/usr/bin/env",
|
|
option,
|
|
`/home/ada/${selected}`,
|
|
process.execPath,
|
|
"-e",
|
|
"console.log(process.cwd()); console.log(process.env.REA_REPLAY_MARKER)",
|
|
],
|
|
working_directory: "/home/ada/ambient",
|
|
application_working_directory: `/home/ada/${selected}`,
|
|
state_directories: [],
|
|
},
|
|
state: { state_directories: [] },
|
|
} as unknown as DesktopApplicationCapture;
|
|
const {
|
|
command: [program, ...args],
|
|
} = planLaunch(capture, false, new Map(), {
|
|
...capturedHomePlan(capture),
|
|
files: new Map(),
|
|
restoredFiles: [],
|
|
});
|
|
const result = spawnSync(program!, args, {
|
|
encoding: "utf8",
|
|
env: { ...process.env, HOME: home, REA_REPLAY_MARKER: "inherited" },
|
|
});
|
|
expect(result.status, result.stderr).toBe(0);
|
|
expect(result.stdout.trimEnd().split("\n")).toEqual([
|
|
join(realpathSync(home), selected),
|
|
clean ? "undefined" : "inherited",
|
|
]);
|
|
},
|
|
);
|
|
|
|
it.skipIf(process.platform === "win32")(
|
|
"does not import seeded Python modules while encoding a file URL",
|
|
async () => {
|
|
const home = await createTestTempDirectory("rea-url-home-");
|
|
writeFileSync(
|
|
join(home, "urllib.py"),
|
|
'open("seed-ran", "w").write("unexpected")\n',
|
|
);
|
|
const command = launchCommand(
|
|
[
|
|
process.execPath,
|
|
"-e",
|
|
"process.stdout.write(process.argv[1])",
|
|
"file:///home/ada/Documents/report.txt",
|
|
],
|
|
"/home/ada",
|
|
"/home/ada",
|
|
);
|
|
const result = spawnSync(command[0]!, command.slice(1), {
|
|
encoding: "utf8",
|
|
env: { ...process.env, HOME: home },
|
|
});
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout).toBe(
|
|
pathToFileURL(join(home, "Documents/report.txt")).href,
|
|
);
|
|
expect(existsSync(join(home, "seed-ran"))).toBe(false);
|
|
},
|
|
);
|
|
|
|
it.skipIf(process.platform === "win32")(
|
|
"launches captured file URLs under the runtime home with their encoded suffix, query, and fragment",
|
|
() => {
|
|
for (const prefix of ["file://", "file://localhost"]) {
|
|
const captured = `${prefix}/home/ada/Documents/%41%20budget.svg?mode=edit#page`;
|
|
const command = launchCommand(
|
|
[
|
|
process.execPath,
|
|
"-e",
|
|
"process.stdout.write(process.argv[1])",
|
|
captured,
|
|
],
|
|
"/home/ada",
|
|
"/home/ada",
|
|
);
|
|
const result = spawnSync(command[0]!, command.slice(1), {
|
|
encoding: "utf8",
|
|
env: { ...process.env, HOME: "/tmp/Run #测" },
|
|
});
|
|
expect(result.status).toBe(0);
|
|
expect(result.stdout).toBe(
|
|
`${prefix}/tmp/Run%20%23%E6%B5%8B/Documents/%41%20budget.svg?mode=edit#page`,
|
|
);
|
|
}
|
|
},
|
|
);
|