дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
Opening an Xcode project with no build log builds its first scheme once in the background, so xcode-build-server has compiler arguments and sourcekit-lsp gives cross-target insight before the first Run. The build is cancellable, waits for Xcode's own build database, restarts sourcekit-lsp when it ends, and foreground builds cancel and reap it first. Xcode process execution lives in ide-run. Closes #7337 Co-authored-by: wildcatDownstairs <[email protected]>
226 рядки
9.9 KiB
TypeScript
226 рядки
9.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { splitCommandLine } from "./commandLine";
|
|
import { usePlatform } from "./platformInfo";
|
|
import { DEFAULT_WORKFLOW, validateVcs, validateWorkflow } from "./workflowSettings";
|
|
|
|
describe("validateWorkflow", () => {
|
|
it("keeps Subversion's interactive mode on unless switched off", () => {
|
|
expect(validateVcs({}).svn).toEqual({
|
|
executable: "",
|
|
interactive: true,
|
|
useCustomConfigDir: false,
|
|
configDir: "",
|
|
});
|
|
const svn = { executable: "/opt/svn", interactive: false, useCustomConfigDir: true, configDir: "/tmp/svn" };
|
|
expect(validateVcs({ svn }).svn).toEqual(svn);
|
|
expect(validateVcs({ svn: { interactive: "no" } }).svn.interactive).toBe(true);
|
|
});
|
|
|
|
it("starts Subversion non-interactive on Windows, where svn would ask on a hidden console", () => {
|
|
const os = usePlatform.getState().os;
|
|
try {
|
|
usePlatform.setState({ os: "windows" });
|
|
expect(validateVcs({}).svn.interactive).toBe(false);
|
|
expect(validateVcs({ svn: { interactive: true } }).svn.interactive).toBe(true);
|
|
} finally {
|
|
usePlatform.setState({ os });
|
|
}
|
|
});
|
|
|
|
it("keeps Git enabled unless switched off", () => {
|
|
const enabled = (value: unknown) => validateWorkflow({ vcs: { git: { enabled: value } } }).vcs.git.enabled;
|
|
expect(enabled(undefined)).toBe(true);
|
|
expect(enabled(false)).toBe(false);
|
|
expect(enabled("off")).toBe(true);
|
|
});
|
|
|
|
it("recurses into submodules when cloning unless switched off", () => {
|
|
const recurse = (cloneSubmodules: unknown) =>
|
|
validateWorkflow({ vcs: { git: { cloneSubmodules } } }).vcs.git.cloneSubmodules;
|
|
expect(recurse(undefined)).toBe(true);
|
|
expect(recurse(false)).toBe(false);
|
|
expect(recurse("off")).toBe(true);
|
|
});
|
|
|
|
it("keeps all four Git fetch tag modes and uses Auto for older projects", () => {
|
|
const mode = (fetchTagsMode: unknown) =>
|
|
validateWorkflow({ vcs: { git: { fetchTagsMode } } }).vcs.git.fetchTagsMode;
|
|
expect(["auto", "sync", "always", "never"].map(mode)).toEqual(["auto", "sync", "always", "never"]);
|
|
expect(mode(undefined)).toBe("auto");
|
|
expect(mode("prune")).toBe("auto");
|
|
});
|
|
|
|
it("defaults inline blame off and accepts only boolean values", () => {
|
|
expect(DEFAULT_WORKFLOW.vcs.git.inlineBlame).toBe(false);
|
|
expect(validateWorkflow({ vcs: { git: { inlineBlame: true } } }).vcs.git.inlineBlame).toBe(true);
|
|
expect(validateWorkflow({ vcs: { git: { inlineBlame: "true" } } }).vcs.git.inlineBlame).toBe(false);
|
|
});
|
|
|
|
it("keeps the inline blame label clickable unless switched off", () => {
|
|
const clickable = (inlineBlameClickable: unknown) =>
|
|
validateWorkflow({ vcs: { git: { inlineBlameClickable } } }).vcs.git.inlineBlameClickable;
|
|
expect(DEFAULT_WORKFLOW.vcs.git.inlineBlameClickable).toBe(true);
|
|
expect(clickable(false)).toBe(false);
|
|
expect(clickable("no")).toBe(true);
|
|
});
|
|
|
|
it("executes branch operations on all repositories unless switched off", () => {
|
|
const sync = (syncBranchOperations: unknown) =>
|
|
validateWorkflow({ vcs: { git: { syncBranchOperations } } }).vcs.git.syncBranchOperations;
|
|
expect(DEFAULT_WORKFLOW.vcs.git.syncBranchOperations).toBe(true);
|
|
expect(sync(false)).toBe(false);
|
|
expect(sync("off")).toBe(true);
|
|
});
|
|
|
|
it("records the cherry-pick origin unless explicitly turned off", () => {
|
|
const origin = (addCherryPickOrigin: unknown) =>
|
|
validateWorkflow({ vcs: { git: { addCherryPickOrigin } } }).vcs.git.addCherryPickOrigin;
|
|
expect(origin(undefined)).toBe(true);
|
|
expect(origin(false)).toBe(false);
|
|
expect(origin("false")).toBe(true);
|
|
});
|
|
|
|
it("skips empty picks by default and accepts the create-empty choice", () => {
|
|
const action = (emptyCherryPick: unknown) =>
|
|
validateWorkflow({ vcs: { git: { emptyCherryPick } } }).vcs.git.emptyCherryPick;
|
|
expect(action(undefined)).toBe("skip");
|
|
expect(action("createEmpty")).toBe("createEmpty");
|
|
expect(action("other")).toBe("skip");
|
|
});
|
|
|
|
it("compares stashed files against the working copy unless the parent is selected", () => {
|
|
const target = (stashDiffTarget: unknown) =>
|
|
validateWorkflow({ vcs: { git: { stashDiffTarget } } }).vcs.git.stashDiffTarget;
|
|
expect(target(undefined)).toBe("local");
|
|
expect(target("parent")).toBe("parent");
|
|
expect(target("other")).toBe("local");
|
|
});
|
|
|
|
it("shelves automatically saved changes by default and accepts Stash", () => {
|
|
const policy = (saveChangesPolicy: unknown) =>
|
|
validateWorkflow({ vcs: { git: { saveChangesPolicy } } }).vcs.git.saveChangesPolicy;
|
|
expect(policy(undefined)).toBe("shelve");
|
|
expect(policy("stash")).toBe("stash");
|
|
expect(policy("other")).toBe("shelve");
|
|
});
|
|
|
|
it("includes commit changes by default unless explicitly switched off", () => {
|
|
const inclusion = (includeChangesByDefault: unknown) =>
|
|
validateWorkflow({ vcs: { commit: { includeChangesByDefault } } }).vcs.commit.includeChangesByDefault;
|
|
expect(inclusion(undefined)).toBe(true);
|
|
expect(inclusion(true)).toBe(true);
|
|
expect(inclusion(false)).toBe(false);
|
|
expect(inclusion("false")).toBe(true);
|
|
});
|
|
|
|
it("keeps Ruff safe fixes on commit opt-in and separate from reformatting", () => {
|
|
expect(DEFAULT_WORKFLOW.vcs.commit.fixOnCommit).toBe(false);
|
|
expect(validateWorkflow({ vcs: { commit: { reformat: true } } }).vcs.commit.fixOnCommit).toBe(false);
|
|
expect(validateWorkflow({ vcs: { commit: { fixOnCommit: true } } }).vcs.commit).toMatchObject({
|
|
fixOnCommit: true,
|
|
reformat: false,
|
|
optimizeImports: false,
|
|
});
|
|
expect(validateWorkflow({ vcs: { commit: { fixOnCommit: "true" } } }).vcs.commit.fixOnCommit).toBe(false);
|
|
});
|
|
|
|
it("keeps the double-click choice unset until it is made", () => {
|
|
expect(DEFAULT_WORKFLOW.vcs.commit.doubleClickOpensDiff).toBeNull();
|
|
expect(validateWorkflow(undefined).vcs.commit.doubleClickOpensDiff).toBeNull();
|
|
const commit = (doubleClickOpensDiff: unknown) =>
|
|
validateWorkflow({ vcs: { commit: { doubleClickOpensDiff } } }).vcs.commit.doubleClickOpensDiff;
|
|
expect(commit(true)).toBe(true);
|
|
expect(commit(false)).toBe(false);
|
|
expect(commit("yes")).toBeNull();
|
|
});
|
|
|
|
it("defaults Build tool window open/focus and rejects unknown values", () => {
|
|
expect(DEFAULT_WORKFLOW.build).toEqual({
|
|
openToolWindow: "always",
|
|
focusToolWindow: "never",
|
|
xcodeIndexBuild: true,
|
|
});
|
|
expect(
|
|
validateWorkflow({ build: { openToolWindow: "onError", focusToolWindow: "always", xcodeIndexBuild: false } })
|
|
.build,
|
|
).toEqual({
|
|
openToolWindow: "onError",
|
|
focusToolWindow: "always",
|
|
xcodeIndexBuild: false,
|
|
});
|
|
expect(
|
|
validateWorkflow({ build: { openToolWindow: "sometimes", focusToolWindow: 1, xcodeIndexBuild: "no" } }).build,
|
|
).toEqual(DEFAULT_WORKFLOW.build);
|
|
});
|
|
|
|
it("defaults debugger hotSwapAfterCompile to ask and validates enum options", () => {
|
|
expect(DEFAULT_WORKFLOW.debugger.hotSwapAfterCompile).toBe("ask");
|
|
expect(validateWorkflow({ debugger: { hotSwapAfterCompile: "always" } }).debugger.hotSwapAfterCompile).toBe(
|
|
"always",
|
|
);
|
|
expect(validateWorkflow({ debugger: { hotSwapAfterCompile: "never" } }).debugger.hotSwapAfterCompile).toBe("never");
|
|
expect(validateWorkflow({ debugger: { hotSwapAfterCompile: "invalid" } }).debugger.hotSwapAfterCompile).toBe("ask");
|
|
});
|
|
|
|
it("defaults C/C++ debugger paths to empty and accepts absolute and relative paths", () => {
|
|
const defaults = { gdbExecutable: "", lldbDapExecutable: "" };
|
|
expect(validateWorkflow({}).debugger.cpp).toEqual(defaults);
|
|
expect(
|
|
validateWorkflow({ debugger: { cpp: { gdbExecutable: 14, lldbDapExecutable: null } } }).debugger.cpp,
|
|
).toEqual(defaults);
|
|
const cpp = { gdbExecutable: "tools/gdb-16", lldbDapExecutable: "/opt/LLVM Tools/lldb-dap" };
|
|
expect(validateWorkflow({ debugger: { cpp } }).debugger.cpp).toEqual(cpp);
|
|
});
|
|
|
|
it("falls back to defaults for missing or malformed values", () => {
|
|
expect(validateWorkflow(undefined)).toEqual(DEFAULT_WORKFLOW);
|
|
const v = validateWorkflow({
|
|
vcs: {
|
|
historyLimit: -5,
|
|
git: { updateMethod: "squash", incomingCheck: "never", incomingCheckInterval: 0, largeFileMb: 0 },
|
|
confirmation: { onPatchCreated: "always" },
|
|
issueNavigation: [{ pattern: "" }, { pattern: "#(\\d+)", link: "x/$1" }],
|
|
},
|
|
console: {
|
|
bufferKb: 1e12,
|
|
foldPatterns: ["a", 3, ""],
|
|
logColors: { enabled: false, error: "#ff0000", warn: 123 },
|
|
},
|
|
terminal: { cursorShape: "bar", env: { A: "1", B: 2 }, tabName: " " },
|
|
externalTools: [{ name: "Lint", id: "x" }, { name: "" }, { name: "Again", id: "x" }],
|
|
});
|
|
expect(v.vcs.historyLimit).toBe(10);
|
|
expect(v.vcs.git.updateMethod).toBe("merge");
|
|
expect(v.vcs.git.incomingCheck).toBe("never");
|
|
expect(v.vcs.git.incomingCheckInterval).toBe(1);
|
|
expect(v.vcs.git.largeFileMb).toBe(1);
|
|
expect(v.vcs.issueNavigation).toEqual([{ pattern: "#(\\d+)", link: "x/$1" }]);
|
|
expect(v.vcs.commit.nonModal).toBe(true);
|
|
expect(v.vcs.confirmation.onPatchCreated).toBe("ask");
|
|
expect(v.vcs.shelf.removeApplied).toBe(false);
|
|
expect(v.console.bufferKb).toBe(1_048_576);
|
|
expect(v.console.foldPatterns).toEqual(["a"]);
|
|
expect(v.console.logColors).toEqual({
|
|
enabled: false,
|
|
error: "#ff0000",
|
|
warn: "var(--ansi-yellow)",
|
|
info: "var(--ansi-green)",
|
|
debug: "var(--ansi-cyan)",
|
|
trace: "var(--ansi-magenta)",
|
|
});
|
|
expect(v.terminal).toMatchObject({ cursorShape: "bar", env: { A: "1" }, tabName: "Local" });
|
|
expect(v.externalTools.map((t) => [t.id, t.name])).toEqual([
|
|
["x", "Lint"],
|
|
["x_", "Again"],
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe("splitCommandLine", () => {
|
|
it("honours quotes and escapes", () => {
|
|
expect(splitCommandLine(`/bin/zsh --login`)).toEqual(["/bin/zsh", "--login"]);
|
|
expect(splitCommandLine(`sh -c "echo 'a b'" x\\ y ''`)).toEqual(["sh", "-c", "echo 'a b'", "x y", ""]);
|
|
expect(splitCommandLine(" ")).toEqual([]);
|
|
});
|
|
});
|