diff --git a/README.md b/README.md index 3a31430..da8ec37 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ node scripts/language-import/test.mjs <托管JD 后端脚本测试覆盖成功抑制、真实失败唯一性、可选文件缺失及损坏/超大属性文件,也覆盖主动中止与异常大报文后的进程清理。 驱动限制帧 16 MiB、stderr 尾部 64 KiB、诊断 1000 条;Windows 用系统进程树终止,避免对负 PID 的 Unix 操作失效后留下 JVM。 这些生命周期回归已在实际 Java 8 和原生 Windows 的 Java 8 后端运行。 -既有测试驱动的未使用 Maven 分支另见 [#1880](https://github.com/1lck/Lithe-IDEA/issues/1880)。 +`scripts/backend-client.mjs` 直接启动 Gradle JAR,默认协商 `litheFunctions` 0;当前文件运行测试显式选择 `litheBuild` 1。 同一迁移后 JAR、同一 Java 8、六对交错测量,仅改变 JVM 堆选项:初始化并执行八次真实配置查询后的 RSS 中位数从 45.98 MiB 变为 43.80 MiB(-4.72%,benchstat p=0.002);初始化加八次查询的时间为 78.39/78.44 ms,无显著差异(p=0.485)。 这是配置后端的单点 RSS,不是峰值或整套 Java 支持的内存;128 MiB 是 Java 堆上限,不是进程总内存上限。 diff --git a/scripts/backend-client.mjs b/scripts/backend-client.mjs index d3e1307..07ae75d 100644 --- a/scripts/backend-client.mjs +++ b/scripts/backend-client.mjs @@ -1,7 +1,7 @@ -// Talks to lib/lithe-maven-backend.jar the way Lithe does: LSP base-protocol -// frames over the process's stdio, `initialize` offering litheBuild 1, then -// lithe/build/* requests. Every wait is bounded, and the backend runs in its -// own process group so a test can always end whatever it left behind. +// Drives the Gradle settings backend and current-file run provider over LSP +// stdio frames. Settings tests offer litheFunctions 0 by default; the run +// provider test explicitly offers litheBuild 1. Every wait is bounded, and +// the backend runs in its own process group for cleanup after a failure. import { execFileSync, spawn } from "node:child_process"; import { pathToFileURL } from "node:url"; @@ -18,12 +18,12 @@ export class BackendClient { stderr = ""; diagnostics = []; - /** Starts `java -jar --state ` (or `args`); `javaOptions` go before `-jar`. */ - constructor({ java = "java", jar, state, env = process.env, javaOptions = [], timeoutMs = WAIT_MS, args, hostRequests = {} }) { + /** Starts `java -jar `; `javaOptions` go before `-jar`. */ + constructor({ java = "java", jar, env = process.env, javaOptions = [], timeoutMs = WAIT_MS, hostRequests = {} }) { this.timeoutMs = timeoutMs; // Answers to requests the backend sends to the host, keyed by method. this.hostRequests = hostRequests; - this.child = spawn(java, [...javaOptions, "-jar", jar, ...(args ?? ["--state", state])], { + this.child = spawn(java, [...javaOptions, "-jar", jar], { env, stdio: ["pipe", "pipe", "pipe"], detached: process.platform !== "win32", windowsHide: true, }); this.exited = new Promise((resolve) => this.child.once("exit", (code, signal) => { @@ -75,12 +75,12 @@ export class BackendClient { this.notify("$/cancelRequest", { id }); } - async initialize(root, { functions = false, buildVersion = 0 } = {}) { + async initialize(root, { buildVersion } = {}) { const result = await this.request("initialize", { processId: process.pid, rootUri: pathToFileURL(root).href, capabilities: { experimental: { - ...(functions ? { litheFunctions: { versions: [0] } } : { litheBuild: { versions: [buildVersion] } }), + ...(buildVersion === undefined ? { litheFunctions: { versions: [0] } } : { litheBuild: { versions: [buildVersion] } }), litheLogging: { versions: [0] }, } }, }); diff --git a/scripts/test-backend.mjs b/scripts/test-backend.mjs index ae18573..db357e0 100644 --- a/scripts/test-backend.mjs +++ b/scripts/test-backend.mjs @@ -54,7 +54,7 @@ const step = async (name, body) => { }; try { client = new BackendClient({ - java, jar, args: [], + java, jar, // The Java tool definition owns the JAR entry switch. This SDK probe // exercises the packaged JVM options; Viva integration tests additionally // verify Core's tool-template instantiation and the real entry path. @@ -87,7 +87,7 @@ try { }, }, }); - const initialized = await client.initialize(workspace, { functions: true }); + const initialized = await client.initialize(workspace); assert.deepEqual(initialized.capabilities.experimental.litheFunctions.functions, [{ id: "compiler.prepareSettings" }, { id: "compiler.settings" }, { id: "languageImport.settings" }, { id: "libraries.settings" }]); const invoke = (workspaceRoot, context = { contextID: "ctx", generation: 1 }, caller) => client.send("lithe/function/invoke", { functionID: "languageImport.settings", operationID: `op-${Math.random()}`, params: { workspaceRoot }, ...(context ? { context } : {}), ...(caller ? { caller } : {}), @@ -190,9 +190,9 @@ try { }); for (const fault of ["abort", "oversized frame"]) { await step(`the driver reaps a backend after ${fault}`, async () => { - const peer = new BackendClient({java, jar, args: [], javaOptions: [`-Duser.home=${home}`]}); + const peer = new BackendClient({java, jar, javaOptions: [`-Duser.home=${home}`]}); try { - await peer.initialize(workspace, {functions: true}); + await peer.initialize(workspace); if (fault === "abort") peer.kill(); else peer.child.stdout.emit("data", Buffer.from("Content-Length: 1000000000\r\n\r\n")); await bounded(peer.exited, "faulted backend disposal", 2000); diff --git a/scripts/test.mjs b/scripts/test.mjs index f65d23d..7260d99 100644 --- a/scripts/test.mjs +++ b/scripts/test.mjs @@ -268,7 +268,7 @@ try { "Gradle must handle current-file Run and Debug through its build provider"); const client = new BackendClient({ jar: join(pluginDir, "lib", "lithe-gradle-run-provider.jar"), - args: [], timeoutMs: COMMAND_TIMEOUT_MS, + timeoutMs: COMMAND_TIMEOUT_MS, }); try { const initialized = await client.initialize(realpathSync(root), { buildVersion: 1 });