pi-lens 3.6.2 → 3.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -2
- package/package.json +4 -4
- package/tsconfig.json +1 -1
- package/clients/__tests__/file-time.test.js +0 -216
- package/clients/__tests__/file-time.test.ts +0 -276
- package/clients/__tests__/format-service.test.js +0 -245
- package/clients/__tests__/format-service.test.ts +0 -339
- package/clients/__tests__/formatters.test.js +0 -271
- package/clients/__tests__/formatters.test.ts +0 -401
- package/clients/agent-behavior-client.js +0 -110
- package/clients/agent-behavior-client.test.js +0 -94
- package/clients/agent-behavior-client.test.ts +0 -116
- package/clients/amain-types.js +0 -164
- package/clients/architect-client.js +0 -291
- package/clients/ast-grep-client.js +0 -253
- package/clients/ast-grep-parser.js +0 -84
- package/clients/ast-grep-rule-manager.js +0 -89
- package/clients/ast-grep-types.js +0 -9
- package/clients/auto-loop.js +0 -131
- package/clients/biome-client.js +0 -420
- package/clients/biome-client.test.js +0 -144
- package/clients/biome-client.test.ts +0 -163
- package/clients/cache/rule-cache.js +0 -72
- package/clients/cache-manager.js +0 -245
- package/clients/cache-manager.test.js +0 -197
- package/clients/cache-manager.test.ts +0 -299
- package/clients/complexity-client.js +0 -675
- package/clients/complexity-client.test.js +0 -234
- package/clients/complexity-client.test.ts +0 -255
- package/clients/config-validator.js +0 -465
- package/clients/dependency-checker.js +0 -325
- package/clients/dependency-checker.test.js +0 -60
- package/clients/dependency-checker.test.ts +0 -71
- package/clients/dispatch/__tests__/autofix-integration.test.js +0 -245
- package/clients/dispatch/__tests__/autofix-integration.test.ts +0 -300
- package/clients/dispatch/__tests__/runner-registration.test.js +0 -234
- package/clients/dispatch/__tests__/runner-registration.test.ts +0 -286
- package/clients/dispatch/debug.log +0 -1
- package/clients/dispatch/dispatcher.edge.test.js +0 -82
- package/clients/dispatch/dispatcher.edge.test.ts +0 -100
- package/clients/dispatch/dispatcher.format.test.js +0 -46
- package/clients/dispatch/dispatcher.format.test.ts +0 -58
- package/clients/dispatch/dispatcher.inline.test.js +0 -74
- package/clients/dispatch/dispatcher.inline.test.ts +0 -93
- package/clients/dispatch/dispatcher.js +0 -381
- package/clients/dispatch/dispatcher.test.js +0 -116
- package/clients/dispatch/dispatcher.test.ts +0 -149
- package/clients/dispatch/integration.js +0 -108
- package/clients/dispatch/plan.js +0 -183
- package/clients/dispatch/runners/architect.js +0 -83
- package/clients/dispatch/runners/architect.test.js +0 -138
- package/clients/dispatch/runners/architect.test.ts +0 -162
- package/clients/dispatch/runners/ast-grep-napi.js +0 -405
- package/clients/dispatch/runners/ast-grep-napi.test.js +0 -107
- package/clients/dispatch/runners/ast-grep-napi.test.ts +0 -129
- package/clients/dispatch/runners/ast-grep.js +0 -157
- package/clients/dispatch/runners/biome.js +0 -55
- package/clients/dispatch/runners/config-validation.js +0 -67
- package/clients/dispatch/runners/go-vet.js +0 -48
- package/clients/dispatch/runners/index.js +0 -47
- package/clients/dispatch/runners/lsp.js +0 -102
- package/clients/dispatch/runners/oxlint.js +0 -67
- package/clients/dispatch/runners/oxlint.test.js +0 -230
- package/clients/dispatch/runners/oxlint.test.ts +0 -303
- package/clients/dispatch/runners/pyright.js +0 -100
- package/clients/dispatch/runners/pyright.test.js +0 -98
- package/clients/dispatch/runners/pyright.test.ts +0 -121
- package/clients/dispatch/runners/python-slop.js +0 -97
- package/clients/dispatch/runners/python-slop.test.js +0 -203
- package/clients/dispatch/runners/python-slop.test.ts +0 -298
- package/clients/dispatch/runners/ruff.js +0 -48
- package/clients/dispatch/runners/rust-clippy.js +0 -102
- package/clients/dispatch/runners/scan_codebase.test.js +0 -89
- package/clients/dispatch/runners/scan_codebase.test.ts +0 -105
- package/clients/dispatch/runners/shellcheck.js +0 -147
- package/clients/dispatch/runners/shellcheck.test.js +0 -98
- package/clients/dispatch/runners/shellcheck.test.ts +0 -129
- package/clients/dispatch/runners/similarity.js +0 -230
- package/clients/dispatch/runners/spellcheck.js +0 -106
- package/clients/dispatch/runners/spellcheck.test.js +0 -158
- package/clients/dispatch/runners/spellcheck.test.ts +0 -214
- package/clients/dispatch/runners/tree-sitter.js +0 -246
- package/clients/dispatch/runners/ts-lsp.js +0 -125
- package/clients/dispatch/runners/ts-slop.js +0 -113
- package/clients/dispatch/runners/type-safety.js +0 -142
- package/clients/dispatch/runners/utils/diagnostic-parsers.js +0 -134
- package/clients/dispatch/runners/utils/runner-helpers.js +0 -115
- package/clients/dispatch/runners/utils.js +0 -51
- package/clients/dispatch/runners/yaml-rule-parser.js +0 -360
- package/clients/dispatch/types.js +0 -16
- package/clients/dispatch/utils/format-utils.js +0 -44
- package/clients/dogfood.test.js +0 -201
- package/clients/dogfood.test.ts +0 -269
- package/clients/file-kinds.js +0 -177
- package/clients/file-kinds.test.js +0 -169
- package/clients/file-kinds.test.ts +0 -210
- package/clients/file-time.js +0 -152
- package/clients/file-utils.js +0 -40
- package/clients/fix-scanners.js +0 -204
- package/clients/format-service.js +0 -184
- package/clients/formatters.js +0 -488
- package/clients/go-client.js +0 -203
- package/clients/go-client.test.js +0 -127
- package/clients/go-client.test.ts +0 -143
- package/clients/installer/index.js +0 -403
- package/clients/interviewer-templates.js +0 -75
- package/clients/interviewer.js +0 -173
- package/clients/jscpd-client.js +0 -196
- package/clients/jscpd-client.test.js +0 -127
- package/clients/jscpd-client.test.ts +0 -145
- package/clients/knip-client.js +0 -239
- package/clients/knip-client.test.js +0 -112
- package/clients/knip-client.test.ts +0 -128
- package/clients/latency-logger.js +0 -40
- package/clients/lsp/__tests__/client.test.js +0 -310
- package/clients/lsp/__tests__/client.test.ts +0 -412
- package/clients/lsp/__tests__/config.test.js +0 -167
- package/clients/lsp/__tests__/config.test.ts +0 -217
- package/clients/lsp/__tests__/error-recovery.test.js +0 -213
- package/clients/lsp/__tests__/error-recovery.test.ts +0 -279
- package/clients/lsp/__tests__/integration.test.js +0 -127
- package/clients/lsp/__tests__/integration.test.ts +0 -160
- package/clients/lsp/__tests__/launch.test.js +0 -313
- package/clients/lsp/__tests__/launch.test.ts +0 -394
- package/clients/lsp/__tests__/server.test.js +0 -259
- package/clients/lsp/__tests__/server.test.ts +0 -332
- package/clients/lsp/__tests__/service.test.js +0 -438
- package/clients/lsp/__tests__/service.test.ts +0 -530
- package/clients/lsp/client.js +0 -350
- package/clients/lsp/config.js +0 -112
- package/clients/lsp/index.js +0 -318
- package/clients/lsp/installer/index.js +0 -391
- package/clients/lsp/interactive-install.js +0 -221
- package/clients/lsp/language.js +0 -170
- package/clients/lsp/launch.js +0 -329
- package/clients/lsp/lsp/launch.js +0 -116
- package/clients/lsp/lsp/server.js +0 -532
- package/clients/lsp/lsp-index.js +0 -10
- package/clients/lsp/path-utils.js +0 -5
- package/clients/lsp/server.js +0 -725
- package/clients/lsp/test-py-spawn/requirements.txt +0 -1
- package/clients/lsp/test-py-spawn/test.py +0 -3
- package/clients/lsp/test-py-svc/requirements.txt +0 -1
- package/clients/lsp/test-py-svc/test.py +0 -3
- package/clients/lsp/test-python-project/requirements.txt +0 -1
- package/clients/lsp/test-python-project/test.py +0 -5
- package/clients/metrics-client.js +0 -107
- package/clients/metrics-client.test.js +0 -128
- package/clients/metrics-client.test.ts +0 -163
- package/clients/metrics-history.js +0 -367
- package/clients/path-utils.js +0 -142
- package/clients/pipeline.js +0 -272
- package/clients/production-readiness.js +0 -522
- package/clients/project-index.js +0 -255
- package/clients/project-metadata.js +0 -531
- package/clients/ruff-client.js +0 -325
- package/clients/ruff-client.test.js +0 -132
- package/clients/ruff-client.test.ts +0 -153
- package/clients/rules-scanner.js +0 -97
- package/clients/runner-tracker.js +0 -152
- package/clients/rust-client.js +0 -205
- package/clients/rust-client.test.js +0 -108
- package/clients/rust-client.test.ts +0 -130
- package/clients/safe-spawn-async.js +0 -163
- package/clients/safe-spawn.js +0 -241
- package/clients/sanitize.js +0 -291
- package/clients/sanitize.test.js +0 -177
- package/clients/sanitize.test.ts +0 -223
- package/clients/scan-architectural-debt.js +0 -167
- package/clients/scan-utils.js +0 -83
- package/clients/secrets-scanner.js +0 -119
- package/clients/secrets-scanner.test.js +0 -100
- package/clients/secrets-scanner.test.ts +0 -113
- package/clients/sg-runner.js +0 -292
- package/clients/state-matrix.js +0 -160
- package/clients/subprocess-client.js +0 -65
- package/clients/symbol-types.js +0 -5
- package/clients/test-runner-client.js +0 -523
- package/clients/test-runner-client.test.js +0 -192
- package/clients/test-runner-client.test.ts +0 -253
- package/clients/test-utils.js +0 -27
- package/clients/test-utils.ts +0 -36
- package/clients/todo-scanner.js +0 -200
- package/clients/todo-scanner.test.js +0 -301
- package/clients/todo-scanner.test.ts +0 -352
- package/clients/tool-availability.js +0 -207
- package/clients/tree-sitter-client.js +0 -601
- package/clients/tree-sitter-query-loader.js +0 -355
- package/clients/tree-sitter-symbol-extractor.js +0 -289
- package/clients/ts-service.js +0 -129
- package/clients/type-coverage-client.js +0 -127
- package/clients/type-coverage-client.test.js +0 -105
- package/clients/type-coverage-client.test.ts +0 -125
- package/clients/type-safety-client.js +0 -138
- package/clients/types.js +0 -11
- package/clients/typescript-client.codefix.test.js +0 -157
- package/clients/typescript-client.codefix.test.ts +0 -186
- package/clients/typescript-client.js +0 -509
- package/clients/typescript-client.test.js +0 -105
- package/clients/typescript-client.test.ts +0 -126
- package/commands/booboo.js +0 -1007
- package/commands/fix-from-booboo.js +0 -398
- package/commands/fix-simplified.js +0 -618
- package/commands/rate.js +0 -281
- package/commands/rate.test.js +0 -119
- package/commands/rate.test.ts +0 -131
- package/commands/refactor.js +0 -130
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LSP Launch Utilities Test Suite
|
|
3
|
-
*
|
|
4
|
-
* Tests for launching LSP servers including:
|
|
5
|
-
* - Direct binary execution
|
|
6
|
-
* - Package manager execution (npx/bun)
|
|
7
|
-
* - Node.js script execution
|
|
8
|
-
* - Python module execution
|
|
9
|
-
* - Process cleanup
|
|
10
|
-
*/
|
|
11
|
-
import { spawn } from "node:child_process";
|
|
12
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
13
|
-
import { launchLSP, launchViaNode, launchViaPackageManager, launchViaPython, stopLSP, } from "../launch.js";
|
|
14
|
-
// Mock child_process
|
|
15
|
-
vi.mock("child_process", () => ({
|
|
16
|
-
spawn: vi.fn(),
|
|
17
|
-
}));
|
|
18
|
-
const mockSpawn = vi.mocked(spawn);
|
|
19
|
-
// Helper to create mock child process
|
|
20
|
-
function createMockChildProcess(pid = 123) {
|
|
21
|
-
const handlers = new Map();
|
|
22
|
-
const mockObj = {
|
|
23
|
-
pid,
|
|
24
|
-
stdin: { write: vi.fn() },
|
|
25
|
-
stdout: { on: vi.fn(), pipe: vi.fn() },
|
|
26
|
-
stderr: { on: vi.fn(), pipe: vi.fn() },
|
|
27
|
-
kill: vi.fn(),
|
|
28
|
-
exitCode: null,
|
|
29
|
-
killed: false,
|
|
30
|
-
on(event, handler) {
|
|
31
|
-
if (!handlers.has(event)) {
|
|
32
|
-
handlers.set(event, []);
|
|
33
|
-
}
|
|
34
|
-
handlers.get(event)?.push(handler);
|
|
35
|
-
return mockObj;
|
|
36
|
-
},
|
|
37
|
-
_emit(event, ...args) {
|
|
38
|
-
handlers.get(event)?.forEach((h) => h(...args));
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
return mockObj;
|
|
42
|
-
}
|
|
43
|
-
describe("launchLSP", () => {
|
|
44
|
-
beforeEach(() => {
|
|
45
|
-
vi.clearAllMocks();
|
|
46
|
-
});
|
|
47
|
-
it("should spawn process with correct parameters", async () => {
|
|
48
|
-
const mockProcess = createMockChildProcess();
|
|
49
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
50
|
-
// Start the async operation
|
|
51
|
-
const launchPromise = launchLSP("typescript-language-server", ["--stdio"], {
|
|
52
|
-
cwd: "/test",
|
|
53
|
-
});
|
|
54
|
-
// Let the 50ms timeout pass
|
|
55
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
56
|
-
// Now complete by resolving
|
|
57
|
-
const _result = await launchPromise;
|
|
58
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
59
|
-
const [cmd, _args, options] = mockSpawn.mock.calls[0];
|
|
60
|
-
// Command should be provided (format depends on platform)
|
|
61
|
-
expect(cmd).toBeTruthy();
|
|
62
|
-
expect(options).toMatchObject({
|
|
63
|
-
cwd: "/test",
|
|
64
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
65
|
-
detached: false,
|
|
66
|
-
windowsHide: true,
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
it("should merge environment variables", async () => {
|
|
70
|
-
const mockProcess = createMockChildProcess();
|
|
71
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
72
|
-
const customEnv = { CUSTOM_VAR: "value" };
|
|
73
|
-
const launchPromise = launchLSP("server", [], { env: customEnv });
|
|
74
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
75
|
-
await launchPromise;
|
|
76
|
-
const [, , options] = mockSpawn.mock.calls[0];
|
|
77
|
-
expect(options?.env).toMatchObject({
|
|
78
|
-
CUSTOM_VAR: "value",
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
it("should return LSPProcess with all streams", async () => {
|
|
82
|
-
const mockProcess = createMockChildProcess(456);
|
|
83
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
84
|
-
const launchPromise = launchLSP("server", [], {});
|
|
85
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
86
|
-
const result = await launchPromise;
|
|
87
|
-
expect(result.pid).toBe(456);
|
|
88
|
-
expect(result.stdin).toBeDefined();
|
|
89
|
-
expect(result.stdout).toBeDefined();
|
|
90
|
-
expect(result.stderr).toBeDefined();
|
|
91
|
-
});
|
|
92
|
-
it("should throw if stdin is not available", async () => {
|
|
93
|
-
const baseMock = createMockChildProcess();
|
|
94
|
-
const mockProcess = {
|
|
95
|
-
...baseMock,
|
|
96
|
-
stdin: null,
|
|
97
|
-
on: baseMock.on,
|
|
98
|
-
_emit: baseMock._emit,
|
|
99
|
-
};
|
|
100
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
101
|
-
// Use wrapper function for proper async error catching
|
|
102
|
-
const launchFn = async () => launchLSP("server", [], {});
|
|
103
|
-
await expect(launchFn()).rejects.toThrow("Failed to spawn LSP server");
|
|
104
|
-
});
|
|
105
|
-
it("should throw if stdout is not available", async () => {
|
|
106
|
-
const baseMock = createMockChildProcess();
|
|
107
|
-
const mockProcess = {
|
|
108
|
-
...baseMock,
|
|
109
|
-
stdout: null,
|
|
110
|
-
on: baseMock.on,
|
|
111
|
-
_emit: baseMock._emit,
|
|
112
|
-
};
|
|
113
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
114
|
-
const launchFn = async () => launchLSP("server", [], {});
|
|
115
|
-
await expect(launchFn()).rejects.toThrow("Failed to spawn LSP server");
|
|
116
|
-
});
|
|
117
|
-
it("should throw if stderr is not available", async () => {
|
|
118
|
-
const baseMock = createMockChildProcess();
|
|
119
|
-
const mockProcess = {
|
|
120
|
-
...baseMock,
|
|
121
|
-
stderr: null,
|
|
122
|
-
on: baseMock.on,
|
|
123
|
-
_emit: baseMock._emit,
|
|
124
|
-
};
|
|
125
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
126
|
-
const launchFn = async () => launchLSP("server", [], {});
|
|
127
|
-
await expect(launchFn()).rejects.toThrow("Failed to spawn LSP server");
|
|
128
|
-
});
|
|
129
|
-
it("should default to process.cwd() when cwd not provided", async () => {
|
|
130
|
-
const mockProcess = createMockChildProcess();
|
|
131
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
132
|
-
const launchPromise = launchLSP("server", [], {});
|
|
133
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
134
|
-
await launchPromise;
|
|
135
|
-
const [, , options] = mockSpawn.mock.calls[0];
|
|
136
|
-
expect(options?.cwd).toBe(process.cwd());
|
|
137
|
-
});
|
|
138
|
-
it("should use shell mode on Windows for .cmd files", async () => {
|
|
139
|
-
const mockProcess = createMockChildProcess();
|
|
140
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
141
|
-
// Save original platform
|
|
142
|
-
const originalPlatform = Object.getOwnPropertyDescriptor(process, "platform");
|
|
143
|
-
Object.defineProperty(process, "platform", { value: "win32" });
|
|
144
|
-
try {
|
|
145
|
-
const launchPromise = launchLSP("server.cmd", ["--arg"], {});
|
|
146
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
147
|
-
await launchPromise;
|
|
148
|
-
const [, , options] = mockSpawn.mock.calls[0];
|
|
149
|
-
expect(options?.shell).toBe(true);
|
|
150
|
-
}
|
|
151
|
-
finally {
|
|
152
|
-
// Restore original platform
|
|
153
|
-
if (originalPlatform) {
|
|
154
|
-
Object.defineProperty(process, "platform", originalPlatform);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
describe("launchViaPackageManager", () => {
|
|
160
|
-
beforeEach(() => {
|
|
161
|
-
vi.clearAllMocks();
|
|
162
|
-
// Clear BUN_INSTALL env var
|
|
163
|
-
delete process.env.BUN_INSTALL;
|
|
164
|
-
});
|
|
165
|
-
it("should spawn via package manager", async () => {
|
|
166
|
-
const mockProcess = createMockChildProcess();
|
|
167
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
168
|
-
launchViaPackageManager("typescript-language-server", ["--stdio"], {});
|
|
169
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
170
|
-
const [cmd] = mockSpawn.mock.calls[0];
|
|
171
|
-
// Command should contain npx or bun
|
|
172
|
-
expect(String(cmd)).toMatch(/npx|bun/);
|
|
173
|
-
});
|
|
174
|
-
it("should use bun when BUN_INSTALL is set", async () => {
|
|
175
|
-
const mockProcess = createMockChildProcess();
|
|
176
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
177
|
-
process.env.BUN_INSTALL = "/path/to/bun";
|
|
178
|
-
launchViaPackageManager("typescript-language-server", ["--stdio"], {});
|
|
179
|
-
const [cmd, args] = mockSpawn.mock.calls[0];
|
|
180
|
-
// On Windows with shell mode, args may be concatenated into cmd
|
|
181
|
-
const cmdStr = String(cmd);
|
|
182
|
-
const hasBun = cmdStr.includes("bun") || args?.some((a) => a?.includes("bun"));
|
|
183
|
-
const _hasX = cmdStr.includes(" x ") || args?.includes("x");
|
|
184
|
-
expect(hasBun).toBe(true);
|
|
185
|
-
// Note: 'x' arg may be in command string on Windows
|
|
186
|
-
});
|
|
187
|
-
it("should pass through options", async () => {
|
|
188
|
-
const mockProcess = createMockChildProcess();
|
|
189
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
190
|
-
launchViaPackageManager("server", ["--flag"], { cwd: "/test" });
|
|
191
|
-
const [, , options] = mockSpawn.mock.calls[0];
|
|
192
|
-
expect(options?.cwd).toBe("/test");
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
describe("launchViaNode", () => {
|
|
196
|
-
beforeEach(() => {
|
|
197
|
-
vi.clearAllMocks();
|
|
198
|
-
});
|
|
199
|
-
it("should spawn node with script path", async () => {
|
|
200
|
-
const mockProcess = createMockChildProcess();
|
|
201
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
202
|
-
launchViaNode("/path/to/script.js", ["--arg"], { cwd: "/test" });
|
|
203
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
204
|
-
const [cmd, _args, options] = mockSpawn.mock.calls[0];
|
|
205
|
-
// On Windows, command is combined; on Unix, it's separate
|
|
206
|
-
expect(String(cmd)).toContain("node");
|
|
207
|
-
expect(options?.cwd).toBe("/test");
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
describe("launchViaPython", () => {
|
|
211
|
-
beforeEach(() => {
|
|
212
|
-
vi.clearAllMocks();
|
|
213
|
-
});
|
|
214
|
-
it("should spawn Python module", async () => {
|
|
215
|
-
const mockProcess = createMockChildProcess();
|
|
216
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
217
|
-
launchViaPython("pylsp", [], {});
|
|
218
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
219
|
-
const [cmd] = mockSpawn.mock.calls[0];
|
|
220
|
-
expect(String(cmd)).toMatch(/python|py/);
|
|
221
|
-
});
|
|
222
|
-
it("should pass args to module", async () => {
|
|
223
|
-
const mockProcess = createMockChildProcess();
|
|
224
|
-
mockSpawn.mockReturnValue(mockProcess);
|
|
225
|
-
await launchViaPython("pylsp", ["--verbose", "--log-file", "/tmp/log"], {});
|
|
226
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
227
|
-
const [cmd, args] = mockSpawn.mock.calls[0];
|
|
228
|
-
// On Windows with shell mode, args may be combined into cmd string
|
|
229
|
-
// Check that the command contains all expected parts
|
|
230
|
-
const fullCommand = typeof cmd === "string" && Array.isArray(args) && args.length === 0
|
|
231
|
-
? cmd // shell mode: everything in cmd
|
|
232
|
-
: `${cmd} ${args.join(" ")}`; // normal mode
|
|
233
|
-
expect(fullCommand).toContain("-m");
|
|
234
|
-
expect(fullCommand).toContain("pylsp");
|
|
235
|
-
expect(fullCommand).toContain("--verbose");
|
|
236
|
-
});
|
|
237
|
-
});
|
|
238
|
-
describe("stopLSP", () => {
|
|
239
|
-
beforeEach(() => {
|
|
240
|
-
vi.clearAllMocks();
|
|
241
|
-
vi.useFakeTimers({ shouldAdvanceTime: true });
|
|
242
|
-
});
|
|
243
|
-
afterEach(() => {
|
|
244
|
-
vi.useRealTimers();
|
|
245
|
-
});
|
|
246
|
-
it("should send SIGTERM first", async () => {
|
|
247
|
-
const mockKill = vi.fn();
|
|
248
|
-
const exitHandlers = [];
|
|
249
|
-
const mockProcess = {
|
|
250
|
-
...createMockChildProcess(),
|
|
251
|
-
kill: mockKill,
|
|
252
|
-
on: vi.fn((event, handler) => {
|
|
253
|
-
if (event === "exit") {
|
|
254
|
-
exitHandlers.push(handler);
|
|
255
|
-
// Simulate immediate exit
|
|
256
|
-
setTimeout(() => handler(), 10);
|
|
257
|
-
}
|
|
258
|
-
}),
|
|
259
|
-
};
|
|
260
|
-
const _stopPromise = stopLSP({
|
|
261
|
-
process: mockProcess,
|
|
262
|
-
stdin: {},
|
|
263
|
-
stdout: {},
|
|
264
|
-
stderr: {},
|
|
265
|
-
pid: 123,
|
|
266
|
-
});
|
|
267
|
-
// Let the exit handler fire
|
|
268
|
-
await new Promise((r) => setTimeout(r, 20));
|
|
269
|
-
expect(mockKill).toHaveBeenCalledWith("SIGTERM");
|
|
270
|
-
});
|
|
271
|
-
it.skip("should send SIGKILL if process doesn't exit in time", async () => {
|
|
272
|
-
// This test is flaky with fake timers - skipping for now
|
|
273
|
-
// The actual implementation works correctly in production
|
|
274
|
-
}, 15000);
|
|
275
|
-
it("should resolve immediately on exit", async () => {
|
|
276
|
-
const mockProcess = {
|
|
277
|
-
...createMockChildProcess(),
|
|
278
|
-
on: vi.fn((event, handler) => {
|
|
279
|
-
if (event === "exit") {
|
|
280
|
-
// Call handler immediately
|
|
281
|
-
handler();
|
|
282
|
-
}
|
|
283
|
-
}),
|
|
284
|
-
};
|
|
285
|
-
await expect(stopLSP({
|
|
286
|
-
process: mockProcess,
|
|
287
|
-
stdin: {},
|
|
288
|
-
stdout: {},
|
|
289
|
-
stderr: {},
|
|
290
|
-
pid: 123,
|
|
291
|
-
})).resolves.toBeUndefined();
|
|
292
|
-
});
|
|
293
|
-
it("should resolve on error event", async () => {
|
|
294
|
-
const mockProcess = {
|
|
295
|
-
...createMockChildProcess(),
|
|
296
|
-
on: vi.fn((event, handler) => {
|
|
297
|
-
if (event === "error") {
|
|
298
|
-
setTimeout(handler, 10);
|
|
299
|
-
}
|
|
300
|
-
}),
|
|
301
|
-
};
|
|
302
|
-
const stopPromise = stopLSP({
|
|
303
|
-
process: mockProcess,
|
|
304
|
-
stdin: {},
|
|
305
|
-
stdout: {},
|
|
306
|
-
stderr: {},
|
|
307
|
-
pid: 123,
|
|
308
|
-
});
|
|
309
|
-
// Let the error handler fire
|
|
310
|
-
await new Promise((r) => setTimeout(r, 20));
|
|
311
|
-
await expect(stopPromise).resolves.toBeUndefined();
|
|
312
|
-
});
|
|
313
|
-
});
|
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LSP Launch Utilities Test Suite
|
|
3
|
-
*
|
|
4
|
-
* Tests for launching LSP servers including:
|
|
5
|
-
* - Direct binary execution
|
|
6
|
-
* - Package manager execution (npx/bun)
|
|
7
|
-
* - Node.js script execution
|
|
8
|
-
* - Python module execution
|
|
9
|
-
* - Process cleanup
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { type ChildProcess, spawn } from "node:child_process";
|
|
13
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
14
|
-
import {
|
|
15
|
-
launchLSP,
|
|
16
|
-
launchViaNode,
|
|
17
|
-
launchViaPackageManager,
|
|
18
|
-
launchViaPython,
|
|
19
|
-
stopLSP,
|
|
20
|
-
} from "../launch.js";
|
|
21
|
-
|
|
22
|
-
// Mock child_process
|
|
23
|
-
vi.mock("child_process", () => ({
|
|
24
|
-
spawn: vi.fn(),
|
|
25
|
-
}));
|
|
26
|
-
|
|
27
|
-
const mockSpawn = vi.mocked(spawn);
|
|
28
|
-
|
|
29
|
-
// Helper to create mock child process
|
|
30
|
-
function createMockChildProcess(
|
|
31
|
-
pid: number = 123,
|
|
32
|
-
): Partial<ChildProcess> & { _emit: (event: string, ...args: any[]) => void } {
|
|
33
|
-
const handlers = new Map<string, Array<(...args: any[]) => void>>();
|
|
34
|
-
const mockObj: any = {
|
|
35
|
-
pid,
|
|
36
|
-
stdin: { write: vi.fn() } as any,
|
|
37
|
-
stdout: { on: vi.fn(), pipe: vi.fn() } as any,
|
|
38
|
-
stderr: { on: vi.fn(), pipe: vi.fn() } as any,
|
|
39
|
-
kill: vi.fn(),
|
|
40
|
-
exitCode: null,
|
|
41
|
-
killed: false,
|
|
42
|
-
on(event: string, handler: (...args: any[]) => void) {
|
|
43
|
-
if (!handlers.has(event)) {
|
|
44
|
-
handlers.set(event, []);
|
|
45
|
-
}
|
|
46
|
-
handlers.get(event)?.push(handler);
|
|
47
|
-
return mockObj;
|
|
48
|
-
},
|
|
49
|
-
_emit(event: string, ...args: any[]) {
|
|
50
|
-
handlers.get(event)?.forEach((h) => h(...args));
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
return mockObj;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
describe("launchLSP", () => {
|
|
57
|
-
beforeEach(() => {
|
|
58
|
-
vi.clearAllMocks();
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("should spawn process with correct parameters", async () => {
|
|
62
|
-
const mockProcess = createMockChildProcess();
|
|
63
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
64
|
-
|
|
65
|
-
// Start the async operation
|
|
66
|
-
const launchPromise = launchLSP("typescript-language-server", ["--stdio"], {
|
|
67
|
-
cwd: "/test",
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Let the 50ms timeout pass
|
|
71
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
72
|
-
|
|
73
|
-
// Now complete by resolving
|
|
74
|
-
const _result = await launchPromise;
|
|
75
|
-
|
|
76
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
77
|
-
const [cmd, _args, options] = mockSpawn.mock.calls[0];
|
|
78
|
-
|
|
79
|
-
// Command should be provided (format depends on platform)
|
|
80
|
-
expect(cmd).toBeTruthy();
|
|
81
|
-
expect(options).toMatchObject({
|
|
82
|
-
cwd: "/test",
|
|
83
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
84
|
-
detached: false,
|
|
85
|
-
windowsHide: true,
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("should merge environment variables", async () => {
|
|
90
|
-
const mockProcess = createMockChildProcess();
|
|
91
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
92
|
-
|
|
93
|
-
const customEnv = { CUSTOM_VAR: "value" };
|
|
94
|
-
const launchPromise = launchLSP("server", [], { env: customEnv });
|
|
95
|
-
|
|
96
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
97
|
-
await launchPromise;
|
|
98
|
-
|
|
99
|
-
const [, , options] = mockSpawn.mock.calls[0];
|
|
100
|
-
expect(options?.env).toMatchObject({
|
|
101
|
-
CUSTOM_VAR: "value",
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it("should return LSPProcess with all streams", async () => {
|
|
106
|
-
const mockProcess = createMockChildProcess(456);
|
|
107
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
108
|
-
|
|
109
|
-
const launchPromise = launchLSP("server", [], {});
|
|
110
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
111
|
-
const result = await launchPromise;
|
|
112
|
-
|
|
113
|
-
expect(result.pid).toBe(456);
|
|
114
|
-
expect(result.stdin).toBeDefined();
|
|
115
|
-
expect(result.stdout).toBeDefined();
|
|
116
|
-
expect(result.stderr).toBeDefined();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it("should throw if stdin is not available", async () => {
|
|
120
|
-
const baseMock = createMockChildProcess();
|
|
121
|
-
const mockProcess = {
|
|
122
|
-
...baseMock,
|
|
123
|
-
stdin: null,
|
|
124
|
-
on: baseMock.on,
|
|
125
|
-
_emit: baseMock._emit,
|
|
126
|
-
};
|
|
127
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
128
|
-
|
|
129
|
-
// Use wrapper function for proper async error catching
|
|
130
|
-
const launchFn = async () => launchLSP("server", [], {});
|
|
131
|
-
await expect(launchFn()).rejects.toThrow("Failed to spawn LSP server");
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("should throw if stdout is not available", async () => {
|
|
135
|
-
const baseMock = createMockChildProcess();
|
|
136
|
-
const mockProcess = {
|
|
137
|
-
...baseMock,
|
|
138
|
-
stdout: null,
|
|
139
|
-
on: baseMock.on,
|
|
140
|
-
_emit: baseMock._emit,
|
|
141
|
-
};
|
|
142
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
143
|
-
|
|
144
|
-
const launchFn = async () => launchLSP("server", [], {});
|
|
145
|
-
await expect(launchFn()).rejects.toThrow("Failed to spawn LSP server");
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("should throw if stderr is not available", async () => {
|
|
149
|
-
const baseMock = createMockChildProcess();
|
|
150
|
-
const mockProcess = {
|
|
151
|
-
...baseMock,
|
|
152
|
-
stderr: null,
|
|
153
|
-
on: baseMock.on,
|
|
154
|
-
_emit: baseMock._emit,
|
|
155
|
-
};
|
|
156
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
157
|
-
|
|
158
|
-
const launchFn = async () => launchLSP("server", [], {});
|
|
159
|
-
await expect(launchFn()).rejects.toThrow("Failed to spawn LSP server");
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("should default to process.cwd() when cwd not provided", async () => {
|
|
163
|
-
const mockProcess = createMockChildProcess();
|
|
164
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
165
|
-
|
|
166
|
-
const launchPromise = launchLSP("server", [], {});
|
|
167
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
168
|
-
await launchPromise;
|
|
169
|
-
|
|
170
|
-
const [, , options] = mockSpawn.mock.calls[0];
|
|
171
|
-
expect(options?.cwd).toBe(process.cwd());
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it("should use shell mode on Windows for .cmd files", async () => {
|
|
175
|
-
const mockProcess = createMockChildProcess();
|
|
176
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
177
|
-
|
|
178
|
-
// Save original platform
|
|
179
|
-
const originalPlatform = Object.getOwnPropertyDescriptor(
|
|
180
|
-
process,
|
|
181
|
-
"platform",
|
|
182
|
-
);
|
|
183
|
-
Object.defineProperty(process, "platform", { value: "win32" });
|
|
184
|
-
|
|
185
|
-
try {
|
|
186
|
-
const launchPromise = launchLSP("server.cmd", ["--arg"], {});
|
|
187
|
-
await new Promise((r) => setTimeout(r, 60));
|
|
188
|
-
await launchPromise;
|
|
189
|
-
|
|
190
|
-
const [, , options] = mockSpawn.mock.calls[0];
|
|
191
|
-
expect(options?.shell).toBe(true);
|
|
192
|
-
} finally {
|
|
193
|
-
// Restore original platform
|
|
194
|
-
if (originalPlatform) {
|
|
195
|
-
Object.defineProperty(process, "platform", originalPlatform);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
describe("launchViaPackageManager", () => {
|
|
202
|
-
beforeEach(() => {
|
|
203
|
-
vi.clearAllMocks();
|
|
204
|
-
// Clear BUN_INSTALL env var
|
|
205
|
-
delete process.env.BUN_INSTALL;
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it("should spawn via package manager", async () => {
|
|
209
|
-
const mockProcess = createMockChildProcess();
|
|
210
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
211
|
-
|
|
212
|
-
launchViaPackageManager("typescript-language-server", ["--stdio"], {});
|
|
213
|
-
|
|
214
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
215
|
-
const [cmd] = mockSpawn.mock.calls[0];
|
|
216
|
-
// Command should contain npx or bun
|
|
217
|
-
expect(String(cmd)).toMatch(/npx|bun/);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
it("should use bun when BUN_INSTALL is set", async () => {
|
|
221
|
-
const mockProcess = createMockChildProcess();
|
|
222
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
223
|
-
|
|
224
|
-
process.env.BUN_INSTALL = "/path/to/bun";
|
|
225
|
-
|
|
226
|
-
launchViaPackageManager("typescript-language-server", ["--stdio"], {});
|
|
227
|
-
|
|
228
|
-
const [cmd, args] = mockSpawn.mock.calls[0];
|
|
229
|
-
// On Windows with shell mode, args may be concatenated into cmd
|
|
230
|
-
const cmdStr = String(cmd);
|
|
231
|
-
const hasBun =
|
|
232
|
-
cmdStr.includes("bun") || args?.some((a: string) => a?.includes("bun"));
|
|
233
|
-
const _hasX = cmdStr.includes(" x ") || args?.includes("x");
|
|
234
|
-
expect(hasBun).toBe(true);
|
|
235
|
-
// Note: 'x' arg may be in command string on Windows
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
it("should pass through options", async () => {
|
|
239
|
-
const mockProcess = createMockChildProcess();
|
|
240
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
241
|
-
|
|
242
|
-
launchViaPackageManager("server", ["--flag"], { cwd: "/test" });
|
|
243
|
-
|
|
244
|
-
const [, , options] = mockSpawn.mock.calls[0];
|
|
245
|
-
expect(options?.cwd).toBe("/test");
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
|
|
249
|
-
describe("launchViaNode", () => {
|
|
250
|
-
beforeEach(() => {
|
|
251
|
-
vi.clearAllMocks();
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it("should spawn node with script path", async () => {
|
|
255
|
-
const mockProcess = createMockChildProcess();
|
|
256
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
257
|
-
|
|
258
|
-
launchViaNode("/path/to/script.js", ["--arg"], { cwd: "/test" });
|
|
259
|
-
|
|
260
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
261
|
-
const [cmd, _args, options] = mockSpawn.mock.calls[0];
|
|
262
|
-
|
|
263
|
-
// On Windows, command is combined; on Unix, it's separate
|
|
264
|
-
expect(String(cmd)).toContain("node");
|
|
265
|
-
expect(options?.cwd).toBe("/test");
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
describe("launchViaPython", () => {
|
|
270
|
-
beforeEach(() => {
|
|
271
|
-
vi.clearAllMocks();
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
it("should spawn Python module", async () => {
|
|
275
|
-
const mockProcess = createMockChildProcess();
|
|
276
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
277
|
-
|
|
278
|
-
launchViaPython("pylsp", [], {});
|
|
279
|
-
|
|
280
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
281
|
-
const [cmd] = mockSpawn.mock.calls[0];
|
|
282
|
-
expect(String(cmd)).toMatch(/python|py/);
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
it("should pass args to module", async () => {
|
|
286
|
-
const mockProcess = createMockChildProcess();
|
|
287
|
-
mockSpawn.mockReturnValue(mockProcess as ChildProcess);
|
|
288
|
-
|
|
289
|
-
await launchViaPython("pylsp", ["--verbose", "--log-file", "/tmp/log"], {});
|
|
290
|
-
|
|
291
|
-
expect(mockSpawn).toHaveBeenCalled();
|
|
292
|
-
const [cmd, args] = mockSpawn.mock.calls[0];
|
|
293
|
-
// On Windows with shell mode, args may be combined into cmd string
|
|
294
|
-
// Check that the command contains all expected parts
|
|
295
|
-
const fullCommand =
|
|
296
|
-
typeof cmd === "string" && Array.isArray(args) && args.length === 0
|
|
297
|
-
? cmd // shell mode: everything in cmd
|
|
298
|
-
: `${cmd} ${args.join(" ")}`; // normal mode
|
|
299
|
-
expect(fullCommand).toContain("-m");
|
|
300
|
-
expect(fullCommand).toContain("pylsp");
|
|
301
|
-
expect(fullCommand).toContain("--verbose");
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
describe("stopLSP", () => {
|
|
306
|
-
beforeEach(() => {
|
|
307
|
-
vi.clearAllMocks();
|
|
308
|
-
vi.useFakeTimers({ shouldAdvanceTime: true });
|
|
309
|
-
});
|
|
310
|
-
|
|
311
|
-
afterEach(() => {
|
|
312
|
-
vi.useRealTimers();
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it("should send SIGTERM first", async () => {
|
|
316
|
-
const mockKill = vi.fn();
|
|
317
|
-
const exitHandlers: Array<() => void> = [];
|
|
318
|
-
|
|
319
|
-
const mockProcess = {
|
|
320
|
-
...createMockChildProcess(),
|
|
321
|
-
kill: mockKill,
|
|
322
|
-
on: vi.fn((event: string, handler: () => void) => {
|
|
323
|
-
if (event === "exit") {
|
|
324
|
-
exitHandlers.push(handler);
|
|
325
|
-
// Simulate immediate exit
|
|
326
|
-
setTimeout(() => handler(), 10);
|
|
327
|
-
}
|
|
328
|
-
}),
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
const _stopPromise = stopLSP({
|
|
332
|
-
process: mockProcess as any,
|
|
333
|
-
stdin: {} as any,
|
|
334
|
-
stdout: {} as any,
|
|
335
|
-
stderr: {} as any,
|
|
336
|
-
pid: 123,
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// Let the exit handler fire
|
|
340
|
-
await new Promise((r) => setTimeout(r, 20));
|
|
341
|
-
|
|
342
|
-
expect(mockKill).toHaveBeenCalledWith("SIGTERM");
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
it.skip("should send SIGKILL if process doesn't exit in time", async () => {
|
|
346
|
-
// This test is flaky with fake timers - skipping for now
|
|
347
|
-
// The actual implementation works correctly in production
|
|
348
|
-
}, 15000);
|
|
349
|
-
|
|
350
|
-
it("should resolve immediately on exit", async () => {
|
|
351
|
-
const mockProcess = {
|
|
352
|
-
...createMockChildProcess(),
|
|
353
|
-
on: vi.fn((event: string, handler: () => void) => {
|
|
354
|
-
if (event === "exit") {
|
|
355
|
-
// Call handler immediately
|
|
356
|
-
handler();
|
|
357
|
-
}
|
|
358
|
-
}),
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
await expect(
|
|
362
|
-
stopLSP({
|
|
363
|
-
process: mockProcess as any,
|
|
364
|
-
stdin: {} as any,
|
|
365
|
-
stdout: {} as any,
|
|
366
|
-
stderr: {} as any,
|
|
367
|
-
pid: 123,
|
|
368
|
-
}),
|
|
369
|
-
).resolves.toBeUndefined();
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
it("should resolve on error event", async () => {
|
|
373
|
-
const mockProcess = {
|
|
374
|
-
...createMockChildProcess(),
|
|
375
|
-
on: vi.fn((event: string, handler: () => void) => {
|
|
376
|
-
if (event === "error") {
|
|
377
|
-
setTimeout(handler, 10);
|
|
378
|
-
}
|
|
379
|
-
}),
|
|
380
|
-
};
|
|
381
|
-
|
|
382
|
-
const stopPromise = stopLSP({
|
|
383
|
-
process: mockProcess as any,
|
|
384
|
-
stdin: {} as any,
|
|
385
|
-
stdout: {} as any,
|
|
386
|
-
stderr: {} as any,
|
|
387
|
-
pid: 123,
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
// Let the error handler fire
|
|
391
|
-
await new Promise((r) => setTimeout(r, 20));
|
|
392
|
-
await expect(stopPromise).resolves.toBeUndefined();
|
|
393
|
-
});
|
|
394
|
-
});
|