test(native): share dispatch environment fixtures (#16357)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-03 13:25:45 +00:00
1 parent d5127d16cb
commit 059f129377
1 file changed
+15 -36
+15 -36
View File
@@ -18,6 +18,17 @@ import { nativeObjcClassImportMachO } from "../fixtures/nativeObjcClassImportMac
import { objcRecordBudgetMacho } from "../fixtures/objcRecordBudgetMacho.js";
import { parseMcpToolError } from "../fixtures/mcpToolError.js";
const nativeDispatchEnvironment = () => ({
PATH: process.env.PATH ?? "",
REA_ANALYSIS_PROVIDER: "auto",
HOPPER_LAUNCHER_PATH: "/rea-unconfigured-deep-provider/hopper",
GHIDRA_INSTALL_DIR: "/rea-unconfigured-deep-provider/ghidra",
JAVA_HOME: "/rea-unconfigured-deep-provider/java",
REA_IDA_MCP_CONFIG: "/rea-unconfigured-deep-provider/ida-mcp.json",
REA_KUNA_COMMAND: "/rea-unconfigured-deep-provider/kuna",
REA_KUNA_CACHE_DIR: "/rea-unconfigured-deep-provider/kuna-cache",
});
cliTest.skipIf(process.platform !== "darwin")(
"restores the exact profileless workflow commitment after a rejected snapshot switch",
async () => {
@@ -29,16 +40,7 @@ cliTest.skipIf(process.platform !== "darwin")(
const after = join(root, "after.json");
const bytes = machoImage({ cpu: CPU.arm64, commands: [] });
await Promise.all([writeFile(first, bytes), writeFile(second, bytes)]);
const { call } = await connectLocalToolsMcp({
PATH: process.env.PATH ?? "",
REA_ANALYSIS_PROVIDER: "auto",
HOPPER_LAUNCHER_PATH: "/rea-unconfigured-deep-provider/hopper",
GHIDRA_INSTALL_DIR: "/rea-unconfigured-deep-provider/ghidra",
JAVA_HOME: "/rea-unconfigured-deep-provider/java",
REA_IDA_MCP_CONFIG: "/rea-unconfigured-deep-provider/ida-mcp.json",
REA_KUNA_COMMAND: "/rea-unconfigured-deep-provider/kuna",
REA_KUNA_CACHE_DIR: "/rea-unconfigured-deep-provider/kuna-cache",
});
const { call } = await connectLocalToolsMcp(nativeDispatchEnvironment());
const good = async (name: string, arguments_: Record<string, unknown>) => {
const result = await call(name, arguments_);
expect(result.isError, JSON.stringify(result)).not.toBe(true);
@@ -127,14 +129,7 @@ cliTest.skipIf(process.platform !== "darwin")(
const bytes = objcRecordBudgetMacho("class", [0x700, 0x720]);
await writeFile(target, bytes);
const environment = {
PATH: process.env.PATH ?? "",
REA_ANALYSIS_PROVIDER: "auto",
HOPPER_LAUNCHER_PATH: "/rea-unconfigured-deep-provider/hopper",
GHIDRA_INSTALL_DIR: "/rea-unconfigured-deep-provider/ghidra",
JAVA_HOME: "/rea-unconfigured-deep-provider/java",
REA_IDA_MCP_CONFIG: "/rea-unconfigured-deep-provider/ida-mcp.json",
REA_KUNA_COMMAND: "/rea-unconfigured-deep-provider/kuna",
REA_KUNA_CACHE_DIR: "/rea-unconfigured-deep-provider/kuna-cache",
...nativeDispatchEnvironment(),
REA_LOG_LEVEL: "silent",
};
const result = await cli.run({
@@ -184,16 +179,7 @@ cliTest.skipIf(process.platform !== "darwin")(
const mcpSnapshot = join(root, "mcp-snapshot.json");
const bytes = machoImage({ cpu: CPU.arm64, commands: [] });
await writeFile(target, bytes);
const isolatedProviderEnvironment = {
PATH: process.env.PATH ?? "",
REA_ANALYSIS_PROVIDER: "auto",
HOPPER_LAUNCHER_PATH: "/rea-unconfigured-deep-provider/hopper",
GHIDRA_INSTALL_DIR: "/rea-unconfigured-deep-provider/ghidra",
JAVA_HOME: "/rea-unconfigured-deep-provider/java",
REA_IDA_MCP_CONFIG: "/rea-unconfigured-deep-provider/ida-mcp.json",
REA_KUNA_COMMAND: "/rea-unconfigured-deep-provider/kuna",
REA_KUNA_CACHE_DIR: "/rea-unconfigured-deep-provider/kuna-cache",
};
const isolatedProviderEnvironment = nativeDispatchEnvironment();
const cliArguments = [
"inspect-native-dispatch-metadata",
@@ -316,14 +302,7 @@ cliTest.skipIf(process.platform !== "darwin")(
const fixture = nativeObjcClassImportMachO();
await writeFile(target, fixture.bytes);
const environment = {
PATH: process.env.PATH ?? "",
REA_ANALYSIS_PROVIDER: "auto",
HOPPER_LAUNCHER_PATH: "/rea-unconfigured-deep-provider/hopper",
GHIDRA_INSTALL_DIR: "/rea-unconfigured-deep-provider/ghidra",
JAVA_HOME: "/rea-unconfigured-deep-provider/java",
REA_IDA_MCP_CONFIG: "/rea-unconfigured-deep-provider/ida-mcp.json",
REA_KUNA_COMMAND: "/rea-unconfigured-deep-provider/kuna",
REA_KUNA_CACHE_DIR: "/rea-unconfigured-deep-provider/kuna-cache",
...nativeDispatchEnvironment(),
REA_LOG_LEVEL: "silent",
};