дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
Xcode projects had no way to clean a scheme's build or clear its DerivedData. Clean Build Folder runs xcodebuild clean in the Run tool window with the same flags as an xcode run. Delete DerivedData resolves the project's <Name>-<hash> folder from xcodebuild -showBuildSettings (never a guessed hash) plus the IDE's own run builds, asks, moves them to the Trash and restarts sourcekit-lsp. Both are in a new Build › Xcode submenu, Find Action and the .xcodeproj / .xcworkspace context menu; Flutter's and Xcode's build submenus now come from one dynamic_submenu table in both menu renderers. Closes #6897 Co-authored-by: wildcatDownstairs <[email protected]> Co-authored-by: wildcatDownstairs <[email protected]>
66 рядки
2.3 KiB
TypeScript
66 рядки
2.3 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
||
import type { RunConfig } from "@/platform/ipc";
|
||
import { useMenuSlotItems } from "@/workbench/contributions";
|
||
import { useRun } from "./store";
|
||
import { cleanConfig, registerXcodeCleanActions, xcodeConfigFor } from "./xcodeClean";
|
||
|
||
const config = (id: string, kind: string, container: string, scheme = id): RunConfig => ({
|
||
id,
|
||
name: scheme,
|
||
kind,
|
||
command: "xcodebuild",
|
||
args: ["-project", container, "-scheme", scheme],
|
||
cwd: null,
|
||
env: { A: "1" },
|
||
params: { container, scheme, configuration: "Debug" },
|
||
detected: true,
|
||
isTest: false,
|
||
debugAdapter: null,
|
||
});
|
||
|
||
describe("xcode clean", () => {
|
||
const configs = [
|
||
config("node", "node", ""),
|
||
config("a", "xcode", "App.xcodeproj"),
|
||
config("b", "xcode", "App.xcodeproj"),
|
||
config("w", "xcode", "Other.xcworkspace"),
|
||
];
|
||
|
||
it("acts on the selected Xcode configuration, else the first", () => {
|
||
expect(xcodeConfigFor(configs, "b")?.id).toBe("b");
|
||
expect(xcodeConfigFor(configs, "node")?.id).toBe("a");
|
||
expect(xcodeConfigFor([configs[0]!], "node")).toBeNull();
|
||
});
|
||
|
||
it("acts on a scheme of the right-clicked container", () => {
|
||
expect(xcodeConfigFor(configs, "b", "/p/Other.xcworkspace")?.id).toBe("w");
|
||
expect(xcodeConfigFor(configs, "w", "/p/App.xcodeproj/")?.id).toBe("a");
|
||
expect(xcodeConfigFor(configs, "a", "/p/Missing.xcodeproj")).toBeNull();
|
||
});
|
||
|
||
it("cleans with the configuration's params on the chosen simulator", () => {
|
||
const clean = cleanConfig(configs[1]!, "UDID");
|
||
expect(clean).toMatchObject({
|
||
id: "xcode:clean:App.xcodeproj:a",
|
||
kind: "xcode-clean",
|
||
args: [],
|
||
env: {},
|
||
params: { container: "App.xcodeproj", scheme: "a", configuration: "Debug", simulator: "UDID" },
|
||
});
|
||
});
|
||
|
||
it("lists Build › Xcode only while the project has an Xcode configuration", () => {
|
||
const listed = () => (useMenuSlotItems.getState().slots.xcodeBuild ?? []).map((i) => i.label);
|
||
useRun.setState({ configs: [configs[0]!] });
|
||
const dispose = registerXcodeCleanActions();
|
||
expect(listed()).toEqual([]);
|
||
useRun.setState({ configs });
|
||
expect(listed()).toEqual(["Clean Build Folder", "Delete DerivedData"]);
|
||
useRun.setState({ configs: [configs[0]!] });
|
||
expect(listed()).toEqual([]);
|
||
useRun.setState({ configs });
|
||
dispose();
|
||
expect(listed()).toEqual([]);
|
||
});
|
||
});
|