mirror of
https://github.com/apmantza/pi-lens.git
synced 2026-11-23 15:21:07 +08:00
Merge pull request #5647 from apmantza/fix/5645-flaky-time-budgets
test: fix two flaky time-budget cells (closes #5645)
This commit is contained in:
4 files changed
+77
-52
No files matched your search
@@ -0,0 +1,6 @@
|
||||
---
|
||||
section: Fixed
|
||||
audience: internal
|
||||
---
|
||||
|
||||
- Stopped two required-lane test flakes: the tool-cwd language-root cell now runs under the lane-scaled timeout, and the `lsp_diagnostics` abort cell asserts the abort (not the per-file deadline) released the in-flight file from the outcome's reason instead of a 500 ms elapsed margin. (refs #5645)
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
} from "../../clients/lsp/server.js";
|
||||
import { LSPService } from "../../clients/lsp/index.js";
|
||||
import { withPlatform } from "../support/platform-stub.js";
|
||||
import { scaledTestTimeout } from "../support/test-timeout-scale.js";
|
||||
import { setupTestEnvironment, useTrackedTempDirs } from "./test-utils.js";
|
||||
|
||||
let home: string;
|
||||
@@ -513,54 +514,68 @@ describe("resolveToolCwd (#2777)", () => {
|
||||
).toEqual({ cwd: workspace, marker: "Cargo.toml" });
|
||||
});
|
||||
|
||||
it("preserves every registry language root through the shared seam", async () => {
|
||||
// #4864: this project used to live at `process.cwd()`, the repository root,
|
||||
// where a repo-walking scan on a sibling worker could list it and then
|
||||
// ENOENT when this cell removed it mid-walk. The per-test temp home is the
|
||||
// seam every other cell in this file uses, and the markerless-root cells
|
||||
// keep it out of any project-root walk.
|
||||
const project = path.join(home, "language-roots");
|
||||
try {
|
||||
// #2846 H1: a workspace-priority wrapper must retain its marker metadata;
|
||||
// otherwise Go silently falls back from a nested go.mod to the dispatch cwd.
|
||||
const goServer = LSP_SERVERS.find((entry) => entry.id === "go");
|
||||
expect(goServer?.root.rootMarkers).toEqual(
|
||||
expect.arrayContaining(["go.mod"]),
|
||||
);
|
||||
const languageServers = LANGUAGES.map((language) => {
|
||||
const serverId = language.lspId ?? language.id;
|
||||
const server = LSP_SERVERS.find((entry) => entry.id === serverId);
|
||||
return { language, server };
|
||||
}).filter(
|
||||
(
|
||||
entry,
|
||||
): entry is {
|
||||
language: (typeof LANGUAGES)[number];
|
||||
server: LSPServerInfo;
|
||||
} => Boolean(entry.server?.root.rootMarkers?.length),
|
||||
);
|
||||
const table: string[] = [];
|
||||
// #5645: a population cell, one nested project per registry language, each
|
||||
// resolved twice through the marker walk: 814 normalizePathForm calls in
|
||||
// all, ~130 filesystem syscalls per language (native realpath on Windows). It
|
||||
// takes ~150 ms on Linux and 5608 ms on `Unit tests Windows`, past Vitest's
|
||||
// 5 s default, twice on 2026-11-15. The budget is a ceiling only: 10 s on
|
||||
// Linux, widened by the lane's own scale (3 on Windows, so 30 s).
|
||||
it(
|
||||
"preserves every registry language root through the shared seam",
|
||||
async () => {
|
||||
// #4864: this project used to live at `process.cwd()`, the repository root,
|
||||
// where a repo-walking scan on a sibling worker could list it and then
|
||||
// ENOENT when this cell removed it mid-walk. The per-test temp home is the
|
||||
// seam every other cell in this file uses, and the markerless-root cells
|
||||
// keep it out of any project-root walk.
|
||||
const project = path.join(home, "language-roots");
|
||||
try {
|
||||
// #2846 H1: a workspace-priority wrapper must retain its marker metadata;
|
||||
// otherwise Go silently falls back from a nested go.mod to the dispatch cwd.
|
||||
const goServer = LSP_SERVERS.find((entry) => entry.id === "go");
|
||||
expect(goServer?.root.rootMarkers).toEqual(
|
||||
expect.arrayContaining(["go.mod"]),
|
||||
);
|
||||
const languageServers = LANGUAGES.map((language) => {
|
||||
const serverId = language.lspId ?? language.id;
|
||||
const server = LSP_SERVERS.find((entry) => entry.id === serverId);
|
||||
return { language, server };
|
||||
}).filter(
|
||||
(
|
||||
entry,
|
||||
): entry is {
|
||||
language: (typeof LANGUAGES)[number];
|
||||
server: LSPServerInfo;
|
||||
} => Boolean(entry.server?.root.rootMarkers?.length),
|
||||
);
|
||||
const table: string[] = [];
|
||||
|
||||
for (const { language, server } of languageServers) {
|
||||
const nested = path.join(project, "packages", language.id);
|
||||
const file = path.join(nested, "src", `main${language.extensions[0]}`);
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
for (const marker of server.root.rootMarkers ?? []) {
|
||||
const markerName = marker.replaceAll("*", "project");
|
||||
const markerPath = path.join(nested, markerName);
|
||||
fs.mkdirSync(path.dirname(markerPath), { recursive: true });
|
||||
fs.writeFileSync(markerPath, "");
|
||||
for (const { language, server } of languageServers) {
|
||||
const nested = path.join(project, "packages", language.id);
|
||||
const file = path.join(
|
||||
nested,
|
||||
"src",
|
||||
`main${language.extensions[0]}`,
|
||||
);
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
for (const marker of server.root.rootMarkers ?? []) {
|
||||
const markerName = marker.replaceAll("*", "project");
|
||||
const markerPath = path.join(nested, markerName);
|
||||
fs.mkdirSync(path.dirname(markerPath), { recursive: true });
|
||||
fs.writeFileSync(markerPath, "");
|
||||
}
|
||||
const before = await server.root(file);
|
||||
const after = await resolveLspServerCwd(server, file, project);
|
||||
table.push(`${language.id}: ${before} === ${after}`);
|
||||
expect(after, table.at(-1)).toBe(before);
|
||||
}
|
||||
const before = await server.root(file);
|
||||
const after = await resolveLspServerCwd(server, file, project);
|
||||
table.push(`${language.id}: ${before} === ${after}`);
|
||||
expect(after, table.at(-1)).toBe(before);
|
||||
console.log(table.join("\n"));
|
||||
} finally {
|
||||
fs.rmSync(project, { recursive: true, force: true });
|
||||
}
|
||||
console.log(table.join("\n"));
|
||||
} finally {
|
||||
fs.rmSync(project, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
},
|
||||
scaledTestTimeout(10_000),
|
||||
);
|
||||
|
||||
it("routes built-in language marker tables through the same seam", () => {
|
||||
const project = path.join(home, "repo");
|
||||
|
||||
@@ -256,8 +256,7 @@
|
||||
"scripts/playground-verify-rule-bounded-wait.test.ts": 2,
|
||||
"scripts/prune-agent-worktrees.test.ts": 1,
|
||||
"scripts/suite-lock.test.ts": 1,
|
||||
"support/fault-injection.test.ts": 1,
|
||||
"tools/lsp-diagnostics.test.ts": 1
|
||||
"support/fault-injection.test.ts": 1
|
||||
},
|
||||
"raw-timer-wait": {
|
||||
"clients/actionable-warnings-bounds.test.ts": 2,
|
||||
|
||||
@@ -529,7 +529,11 @@ describe("lsp_diagnostics tool", () => {
|
||||
|
||||
it("bounds an in-flight file and the whole batch on abort (#837)", async () => {
|
||||
const previous = process.env.PI_LENS_LSP_BATCH_FILE_MS;
|
||||
process.env.PI_LENS_LSP_BATCH_FILE_MS = "1000";
|
||||
// #5645: far past the test's own 5 s budget, so only the abort can release
|
||||
// the in-flight file. The bound is read from the outcome's reason below,
|
||||
// not from elapsed time: a wall-clock `< 500` margin read 512 on a loaded
|
||||
// shard because the abort was released correctly but late.
|
||||
process.env.PI_LENS_LSP_BATCH_FILE_MS = "30000";
|
||||
const tool = createLspDiagnosticsTool();
|
||||
const controller = new AbortController();
|
||||
const tmpDir = fs.mkdtempSync(
|
||||
@@ -546,7 +550,6 @@ describe("lsp_diagnostics tool", () => {
|
||||
setTimeout(() => controller.abort(), 0);
|
||||
return new Promise(() => {});
|
||||
});
|
||||
const started = Date.now();
|
||||
const pending = tool.execute(
|
||||
"diag-abort-contract",
|
||||
{ paths: files, concurrency: 1, waitMs: 1 },
|
||||
@@ -556,9 +559,11 @@ describe("lsp_diagnostics tool", () => {
|
||||
);
|
||||
try {
|
||||
const result = (await pending) as any;
|
||||
// Below the 1000 ms per-file deadline, so the abort is what released the
|
||||
// in-flight file rather than the deadline expiring.
|
||||
expect(Date.now() - started).toBeLessThan(500);
|
||||
// The abort, not the per-file deadline, released the in-flight file: the
|
||||
// deadline path words its reason `File check exceeded <n>ms.`.
|
||||
expect(result.details?.outcomes?.[0]?.reason).toBe(
|
||||
"Batch aborted before this file completed.",
|
||||
);
|
||||
expect(result.details?.outcomeCounts?.inconclusive).toBe(1);
|
||||
expect(result.details?.incompleteFiles).toBe(1);
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user