mirror of
https://github.com/morluto/rea.git
synced 2026-11-21 14:05:49 +00:00
* test(native): expect artifact_changed when a bound metadata target is lost41e10b240made a bound metadata target that fails the source boundary (`path`) or disappears (`ENOENT`) report AnalysisArtifactChangedError, as its comment and docs/testing.md state, but left the module test expecting AnalysisInputError. The test now asserts the shipped contract, so main's Test shard and Portable tests lanes pass again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(package): ship the CLI process environment owner in launcher fixturesc2caae88fmoved launcher environment preparation into scripts/lib/cli-process-environment.mjs, made scripts/rea.mjs import it and made verifyPackagePack require it in the packed listing, and updated the dispatcher fixtures, but two other fixtures still omit it: - packageTarListing's fake tar listing, so every case stops at "package omitted the CLI process environment owner" before its own assertion; - deferredRuntime's copied compiled package, so the copied launcher fails to resolve its import instead of reporting the corrupted catalog. Both fixtures now include the module, as the package ships it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(native): expect XML plist validation in typed-value provenance9f5dd56e2records a successful `plutil -lint` of an XML plist source in provenance, as docs/native-investigation.md states, but the macOS typed-value CLI test still expected only the `file` step for both formats. XML sources now expect the lint step; binary sources are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
101 lines
4.2 KiB
TypeScript
101 lines
4.2 KiB
TypeScript
import { execFile } from "node:child_process";
|
|
import { join, resolve } from "node:path";
|
|
import { promisify } from "node:util";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
import { expect, it } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
|
|
const execFileAsync = promisify(execFile);
|
|
const packerUrl = pathToFileURL(
|
|
resolve("scripts/verify-package-pack.mjs"),
|
|
).href;
|
|
const catalogUrl = pathToFileURL(resolve("dist/catalogIdentity.js")).href;
|
|
const bridge = "package/bridge/hopper_bridge.py";
|
|
const members = [
|
|
bridge,
|
|
"package/bridge/cutter/rea_bridge.py",
|
|
"package/bridge/ghidra/ReaGhidraBridge.java",
|
|
"package/bridge/ghidra/ReaGhidraBundleActivator.java",
|
|
"package/bridge/ghidra/ReaGhidraExtensions.java",
|
|
"package/bridge/ghidra/ReaGhidraPrepareCom.java",
|
|
"package/bridge/ghidra/ReaGhidraPrepareRaw.java",
|
|
"package/bridge/ghidra/ReaGhidraApplySeeds.java",
|
|
"package/bridge/ghidra/ReaGhidraAnalysisOptions.java",
|
|
"package/bridge/ghidra/ReaGhidraNoReturnFix.java",
|
|
"package/bridge/ghidra/ReaGhidraMipsSoftFloat.java",
|
|
"package/scripts/lib/cli-process-environment.mjs",
|
|
];
|
|
|
|
async function verifyListing(listing: string) {
|
|
const workspace = await createTestTempDirectory("rea-tar-listing-");
|
|
const { stdout } = await execFileAsync(process.execPath, [
|
|
"--input-type=module",
|
|
"--eval",
|
|
`import childProcess from "node:child_process";
|
|
import { syncBuiltinESMExports } from "node:module";
|
|
import { promisify } from "node:util";
|
|
import { FULL_CATALOG_IDENTITY } from ${JSON.stringify(catalogUrl)};
|
|
let bridgeParsed = false;
|
|
childProcess.execFile = () => { throw new Error("Expected promisified execution"); };
|
|
childProcess.execFile[promisify.custom] = async (command, args) => {
|
|
let stdout;
|
|
if ((command === "npm" && args[0] === "pack") || (command === process.execPath && args[1] === "pack")) stdout = "fixture.tgz\\n";
|
|
else if (command === "tar" && args[0] === "-tf") stdout = ${JSON.stringify(listing)};
|
|
else if (command === "tar" && args[0] === "-xOf" && args[2] === "package/package.json")
|
|
stdout = JSON.stringify({ bin: { rea: "scripts/rea.mjs", "rea-agents": "scripts/rea.mjs" }, mcpName: "io.github.morluto/rea", dependencies: { "@lydell/node-pty": "1.1.0" } });
|
|
else if (command === "tar" && args[0] === "-xOf" && args[2] === "package/skills/reverse-engineer-anything/SKILL.md")
|
|
stdout = " tool_count: " + FULL_CATALOG_IDENTITY.counts.mcp_tools + "\\n";
|
|
else if (command === "tar" && args[0] === "-xf") stdout = "";
|
|
else if (command === "python3") { bridgeParsed = true; stdout = ""; }
|
|
else throw new Error("Unexpected command: " + command + " " + JSON.stringify(args));
|
|
return { stdout, stderr: "" };
|
|
};
|
|
syncBuiltinESMExports();
|
|
const { verifyPackagePack } = await import(${JSON.stringify(packerUrl)});
|
|
try {
|
|
const result = await verifyPackagePack({ root: process.cwd(), workspace: ${JSON.stringify(workspace)} });
|
|
process.stdout.write(JSON.stringify({ ...result, bridgeParsed }));
|
|
} catch (cause) {
|
|
process.stdout.write(JSON.stringify({ error: cause.message, bridgeParsed }));
|
|
}`,
|
|
]);
|
|
return { result: JSON.parse(stdout), workspace };
|
|
}
|
|
|
|
it("preserves a literal trailing CR in an LF-listed member", async () => {
|
|
const listing =
|
|
members.map((path) => (path === bridge ? `${path}\r` : path)).join("\n") +
|
|
"\n";
|
|
const { result } = await verifyListing(listing);
|
|
expect(result).toEqual({
|
|
error: `package omitted ${bridge}`,
|
|
bridgeParsed: false,
|
|
});
|
|
});
|
|
|
|
it("accepts exact bridge entries from a CRLF tar listing and still rejects generated bytecode", async () => {
|
|
const ending = "\r\n";
|
|
const { result, workspace } = await verifyListing(
|
|
members.join(ending) + ending,
|
|
);
|
|
expect(result).toEqual({
|
|
tarball: join(workspace, "pack/fixture.tgz"),
|
|
bridgeParsed: true,
|
|
});
|
|
|
|
const rejected = await verifyListing(
|
|
[...members, "package/bridge/stale.pyc"].join(ending) + ending,
|
|
);
|
|
expect(rejected.result).toEqual({
|
|
error: "package contained generated Python bytecode",
|
|
bridgeParsed: false,
|
|
});
|
|
});
|
|
|
|
it("accepts exact bridge entries from an LF tar listing", async () => {
|
|
const { result } = await verifyListing(members.join("\n") + "\n");
|
|
expect(result.bridgeParsed).toBe(true);
|
|
});
|