From 059f12937787933db2b63c4f56da0fd85479b2ab Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 3 Dec 2026 21:25:45 +0800 Subject: [PATCH] test(native): share dispatch environment fixtures (#16357) --- .../acceptance/nativeDispatchSnapshot.test.ts | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/tests/acceptance/nativeDispatchSnapshot.test.ts b/tests/acceptance/nativeDispatchSnapshot.test.ts index 8bd8fd5414f..cf4a49f2e1e 100644 --- a/tests/acceptance/nativeDispatchSnapshot.test.ts +++ b/tests/acceptance/nativeDispatchSnapshot.test.ts @@ -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) => { 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", };