mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
Failed warmups and repetitions were dropped from benchmark summaries, a failed startup, build or cleanup could leave an earlier success report in place, and a hung renderer or child process could block a run. Every attempt now keeps its status, metrics and error so summaries have the complete denominator; failures replace stale reports; browser and child-process lifecycles are bounded with cleanup of owned resources; and each criterion execution gets its own artifact directory. Co-authored-by: Mr0Bread <55754540+Mr0Bread@users.noreply.github.com>
55 lines
2.0 KiB
JavaScript
Executable File
55 lines
2.0 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
const { spawn } = require("node:child_process");
|
|
const { writeFileSync } = require("node:fs");
|
|
const { join } = require("node:path");
|
|
const home = process.env.OPENIDEA_SERVER_HOME;
|
|
const mode = process.env.SMOKE_SERVER_MODE;
|
|
const tool = spawn(process.execPath, ["-e", "setInterval(() => {}, 1000)"], {
|
|
detached: mode !== "hang-inherited",
|
|
stdio: "ignore",
|
|
});
|
|
const second =
|
|
mode === "signal-multiple"
|
|
? spawn(process.execPath, ["-e", "setInterval(() => {}, 1000)"], {
|
|
detached: true,
|
|
stdio: "ignore",
|
|
})
|
|
: undefined;
|
|
writeFileSync(join(home, "pids.json"), JSON.stringify({ server: process.pid, tool: tool.pid, second: second?.pid }));
|
|
let buffer = Buffer.alloc(0);
|
|
process.stdin.on("data", (chunk) => {
|
|
buffer = Buffer.concat([buffer, chunk]);
|
|
for (;;) {
|
|
const end = buffer.indexOf("\r\n\r\n");
|
|
if (end < 0) return;
|
|
const length = Number(/Content-Length: (\d+)/i.exec(buffer.subarray(0, end).toString())[1]);
|
|
if (buffer.length < end + 4 + length) return;
|
|
const request = JSON.parse(buffer.subarray(end + 4, end + 4 + length));
|
|
buffer = buffer.subarray(end + 4 + length);
|
|
if (mode === "no-initialize" && request.method === "initialize") continue;
|
|
if (mode === "bad-header") {
|
|
process.stdout.write("Not-a-length: 0\r\n\r\n");
|
|
continue;
|
|
}
|
|
const body = JSON.stringify({
|
|
jsonrpc: "2.0",
|
|
id: request.id,
|
|
...(mode === "reject" ? { error: { message: "initialize failed" } } : { result: {} }),
|
|
});
|
|
process.stdout.write(`Content-Length: ${Buffer.byteLength(body)}\r\n\r\n${body}`);
|
|
}
|
|
});
|
|
process.stdin.on("end", () => {
|
|
writeFileSync(join(home, "eof"), "received");
|
|
if (mode.startsWith("hang")) return;
|
|
if (mode.startsWith("signal")) return process.kill(process.pid, "SIGTERM");
|
|
setTimeout(() => {
|
|
tool.once("exit", () => {
|
|
writeFileSync(join(home, "shutdown"), "tool reaped");
|
|
process.exit(0);
|
|
});
|
|
tool.kill("SIGKILL");
|
|
}, 150);
|
|
});
|
|
setInterval(() => {}, 1000);
|