aboutsummaryrefslogtreecommitdiff
path: root/tests/drivers/fuzz_lsp.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/drivers/fuzz_lsp.js')
-rw-r--r--tests/drivers/fuzz_lsp.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/drivers/fuzz_lsp.js b/tests/drivers/fuzz_lsp.js
index e22a44b..f8a1d3b 100644
--- a/tests/drivers/fuzz_lsp.js
+++ b/tests/drivers/fuzz_lsp.js
@@ -1,7 +1,9 @@
// Deterministic source/protocol fuzzing for diagnostics, caching, and recovery.
// Usage: node tests/drivers/fuzz_lsp.js path/to/zclsp
+// interpreted hosts (no jit) are far slower; ZC_TEST_TIMEOUT_SCALE stretches every deadline
+const TIMEOUT_SCALE = Number(process.env.ZC_TEST_TIMEOUT_SCALE) || 1;
const { spawnSync } = require('child_process');
-const server = process.argv[2] || 'bin/zclsp';
+const server = process.argv[2] || 'build/bin/zclsp';
let state = 0x5a17;
function next() { state = (Math.imul(state, 1664525) + 1013904223) >>> 0; return state; }
function frame(m) {
@@ -35,7 +37,7 @@ for (let i = 0; i < 32; i++) {
msgs.push({ jsonrpc: '2.0', method: 'textDocument/didChange', params: { textDocument: { uri, version: 2 }, contentChanges: [{ text: fixed }] } });
}
const stdUri = 'file:///fuzz-std.zc';
-msgs.push({ jsonrpc: '2.0', method: 'textDocument/didOpen', params: { textDocument: { uri: stdUri, languageId: 'zc', version: 1, text: 'include std;\nfn main() { return Text.starts("alpha", "al"); }\n' } } });
+msgs.push({ jsonrpc: '2.0', method: 'textDocument/didOpen', params: { textDocument: { uri: stdUri, languageId: 'zc', version: 1, text: 'include std;\nfn main() { return std.Text.starts("alpha", "al"); }\n' } } });
// Keep one server alive while documents are repeatedly opened, made malformed,
// repaired, closed, and reopened at a new version. This exercises cache
@@ -57,7 +59,7 @@ for (const [uri, text] of churn) {
msgs.push({ jsonrpc: '2.0', method: 'textDocument/didOpen', params: { textDocument: { uri, languageId: 'zc', version: churnVersion++, text } } });
}
msgs.push({ jsonrpc: '2.0', method: 'exit' });
-const run = spawnSync(server, [], { input: Buffer.concat(msgs.map(frame)), timeout: 60000, maxBuffer: 1 << 28 });
+const run = spawnSync(server, [], { input: Buffer.concat(msgs.map(frame)), timeout: 60000 * TIMEOUT_SCALE, maxBuffer: 1 << 28 });
if (run.error || run.status !== 0) throw run.error || new Error(`server exit ${run.status}: ${run.stderr}`);
const out = parse(run.stdout);
const diagnostics = new Map();