дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
Debug on an Xcode run configuration builds and installs the app as Run does, launches it suspended on the iOS Simulator (simctl launch --wait-for-debugger) and attaches lldb-dap to its pid, so breakpoints in the app's Swift sources hit while its output stays in the Run console; stopping the debug session stops the run. simctl holds back its <bundle id>: <pid> line when stdout is a pipe, so the launch script prints it once the suspended process under the installed bundle appears. Detected and new Xcode configurations get debugAdapter lldb-dap. Closes #6885. Co-authored-by: wildcatDownstairs <[email protected]>
56 рядки
1.8 KiB
TypeScript
56 рядки
1.8 KiB
TypeScript
import { beforeEach, expect, test, vi } from "vitest";
|
|
import type { RunConfig } from "@/platform/ipc";
|
|
|
|
const { startRun, executeAction } = vi.hoisted(() => ({ startRun: vi.fn(), executeAction: vi.fn() }));
|
|
vi.mock("./store", () => ({ startRun }));
|
|
vi.mock("@/platform/actions", () => ({ executeAction }));
|
|
|
|
import { debugXcodeApp, launchedPid } from "./xcodeDebug";
|
|
|
|
const config = {
|
|
id: "xcode:run:App.xcodeproj:App",
|
|
name: "App",
|
|
kind: "xcode",
|
|
params: { container: "App.xcodeproj", scheme: "App" },
|
|
} as unknown as RunConfig;
|
|
|
|
beforeEach(() => {
|
|
startRun.mockReset();
|
|
executeAction.mockReset();
|
|
});
|
|
|
|
test("simctl's launch line gives the pid", () => {
|
|
expect(launchedPid("dev.example.App: 4321")).toBe(4321);
|
|
expect(launchedPid("dev.example.App: 4321\r\n")).toBe(4321);
|
|
expect(launchedPid("note: 12")).toBeNull();
|
|
expect(launchedPid("** BUILD SUCCEEDED **")).toBeNull();
|
|
});
|
|
|
|
test("Debug launches the app suspended and attaches lldb-dap to its pid once", async () => {
|
|
startRun.mockImplementation(async (_c, _r, _b, options) => {
|
|
// The launch line can arrive before startRun returns the run's id.
|
|
options.onLine("Build succeeded");
|
|
options.onLine("dev.example.App: 4321");
|
|
options.onLine("dev.example.App: 9999");
|
|
return { runId: 7 };
|
|
});
|
|
await debugXcodeApp(config, false);
|
|
const [, , , options] = startRun.mock.calls[0]!;
|
|
expect(options.launch.params).toEqual({ container: "App.xcodeproj", scheme: "App", waitForDebugger: "1" });
|
|
expect(executeAction).toHaveBeenCalledTimes(1);
|
|
expect(executeAction).toHaveBeenCalledWith("debug.attach", {
|
|
attachable: {
|
|
pid: 4321,
|
|
name: "App",
|
|
commandLine: "",
|
|
kind: "native",
|
|
adapter: "lldb-dap",
|
|
host: null,
|
|
port: null,
|
|
},
|
|
process: 7,
|
|
runConfig: config,
|
|
show: false,
|
|
});
|
|
});
|