From bfecbb1d480ab9a2c8e7545cdfa04f022f050bcc Mon Sep 17 00:00:00 2001 From: Kaoru0822 Date: Thu, 12 Nov 2026 20:39:31 -0800 Subject: [PATCH] test(native): cover deadlines throughout signature inspection (#10217) --- src/native/NativeCommandDeadline.test.ts | 63 ++++++++++++++++-------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/src/native/NativeCommandDeadline.test.ts b/src/native/NativeCommandDeadline.test.ts index 4224b1e7a4..d4ebb75d88 100644 --- a/src/native/NativeCommandDeadline.test.ts +++ b/src/native/NativeCommandDeadline.test.ts @@ -32,7 +32,7 @@ afterEach(() => { }); class RecordingRunner implements NativeCommandRunner { - readonly timeouts: number[] = []; + readonly calls: { tool: string; timeoutMs: number | undefined }[] = []; readonly #inner = new NativeFixtureRunner(); run( @@ -40,7 +40,7 @@ class RecordingRunner implements NativeCommandRunner { arguments_: readonly string[], options: NativeCommandOptions, ) { - if (options.timeoutMs !== undefined) this.timeouts.push(options.timeoutMs); + this.calls.push({ tool, timeoutMs: options.timeoutMs }); return this.#inner.run(tool, arguments_, options); } } @@ -48,6 +48,7 @@ class RecordingRunner implements NativeCommandRunner { const execute = async ( runner: NativeCommandRunner, parameters: Readonly>, + operation: "list_architectures" | "inspect_signature" = "list_architectures", ) => { const root = await createTestTempDirectory("rea-native-deadline-"); const path = join(root, "app"); @@ -56,29 +57,51 @@ const execute = async ( await nativeMachoTargetForFile(path), ); try { - return await client.execute("list_architectures", parameters); + return await client.execute(operation, parameters); } finally { expect((await client.close()).ok).toBe(true); } }; -describe("native_command_timeout_ms", () => { - it("uses 60000 ms when the caller omits the setting", async () => { - const runner = new RecordingRunner(); - const result = await execute(runner, {}); - expect(result.ok, JSON.stringify(result)).toBe(true); - expect(runner.timeouts.every((timeout) => timeout === 60_000)).toBe(true); - expect(DEFAULT_NATIVE_COMMAND_TIMEOUT_MS).toBe(60_000); - expect(runner.timeouts.length).toBeGreaterThan(0); - }); +// Signature inspection reads display, requirements and entitlements, then both +// architecture states in the authored universal Mach-O fixture. +const commandCases = [ + { operation: "list_architectures", tools: ["lipo"] }, + { + operation: "inspect_signature", + tools: ["codesign", "codesign", "codesign", "codesign", "codesign"], + }, +] as const; - it("passes a selected deadline through to each native command", async () => { - const runner = new RecordingRunner(); - const result = await execute(runner, { native_command_timeout_ms: 1_500 }); - expect(result.ok, JSON.stringify(result)).toBe(true); - expect(runner.timeouts.length).toBeGreaterThan(0); - expect(runner.timeouts.every((timeout) => timeout === 1_500)).toBe(true); - }); +describe("native_command_timeout_ms", () => { + it.each(commandCases)( + "uses 60000 ms for every $operation command when the caller omits the setting", + async ({ operation, tools }) => { + const runner = new RecordingRunner(); + const result = await execute(runner, {}, operation); + expect(result.ok, JSON.stringify(result)).toBe(true); + expect(runner.calls).toEqual( + tools.map((tool) => ({ tool, timeoutMs: 60_000 })), + ); + expect(DEFAULT_NATIVE_COMMAND_TIMEOUT_MS).toBe(60_000); + }, + ); + + it.each(commandCases)( + "passes a selected deadline through every $operation command", + async ({ operation, tools }) => { + const runner = new RecordingRunner(); + const result = await execute( + runner, + { native_command_timeout_ms: 1_500 }, + operation, + ); + expect(result.ok, JSON.stringify(result)).toBe(true); + expect(runner.calls).toEqual( + tools.map((tool) => ({ tool, timeoutMs: 1_500 })), + ); + }, + ); it("passes the selected deadline through production xcrun resolution", async () => { const calls: { @@ -125,7 +148,7 @@ describe("native_command_timeout_ms", () => { const runner = new RecordingRunner(); const result = await execute(runner, { native_command_timeout_ms: 0 }); if (result.ok) throw new Error("expected an invalid deadline"); - expect(runner.timeouts).toEqual([]); + expect(runner.calls).toEqual([]); expect(projectAnalysisError(result.error)).toMatchObject({ code: "invalid_request", details: {