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>
59 lines
2.8 KiB
TypeScript
59 lines
2.8 KiB
TypeScript
// @vitest-environment node
|
|
import { spawnSync } from "node:child_process";
|
|
import { cpSync, mkdirSync, mkdtempSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join, resolve } from "node:path";
|
|
import { expect, test } from "vitest";
|
|
|
|
const repo = resolve(import.meta.dirname, "../..");
|
|
|
|
test.each([
|
|
{ family: "perf", args: ["--only", "typing", "--no-build"], kind: "missing bundle" },
|
|
{ family: "perf", args: ["--only", "typing"], kind: "build failure" },
|
|
{ family: "perf", args: ["--only", "typing", "--no-build", "--channel", "not-a-browser"], kind: "browser failure" },
|
|
{ family: "evals", args: ["--only", "java.app", "--no-build"], kind: "missing server" },
|
|
])("$kind replaces old passing reports with structured failure", { timeout: 30_000 }, ({ family, args, kind }) => {
|
|
const root = mkdtempSync(join(tmpdir(), "openidea-runner-failure-"));
|
|
try {
|
|
for (const dir of ["perf", "evals", "smoke"]) cpSync(join(repo, dir), join(root, dir), { recursive: true });
|
|
cpSync(join(repo, "package.json"), join(root, "package.json"));
|
|
symlinkSync(join(repo, "node_modules"), join(root, "node_modules"), "junction");
|
|
const output = join(root, "target", family === "perf" ? "perf" : "eval");
|
|
mkdirSync(output, { recursive: true });
|
|
writeFileSync(join(output, "report.json"), '{"pass":true,"sentinel":"old success"}');
|
|
writeFileSync(join(output, "report.md"), "old success");
|
|
if (kind === "browser failure") {
|
|
mkdirSync(join(output, "dist"));
|
|
writeFileSync(join(output, "dist", "index.html"), "<!doctype html><title>launch boundary</title>");
|
|
}
|
|
const result = spawnSync(
|
|
process.execPath,
|
|
[join(root, family, "run.ts"), ...args, "--runs", "1", "--warmup", "0"],
|
|
{
|
|
encoding: "utf8",
|
|
timeout: 20_000,
|
|
env: {
|
|
...process.env,
|
|
PATH: kind === "build failure" ? "" : process.env.PATH,
|
|
OPENIDEA_SERVER: join(root, "nonexistent-server"),
|
|
},
|
|
},
|
|
);
|
|
expect(result.error).toBeUndefined();
|
|
expect(result.status, result.stderr).toBe(1);
|
|
const report = JSON.parse(readFileSync(join(output, "report.json"), "utf8"));
|
|
expect(report.status).toBe("failed");
|
|
expect(report.infrastructure.length).toBeGreaterThan(0);
|
|
expect(report.expected.length).toBeGreaterThan(0);
|
|
expect(report.trials).toEqual({});
|
|
expect(report.sentinel).toBeUndefined();
|
|
if (family === "evals") expect(report.pass).toBe(false);
|
|
else expect(report.failures).toBeGreaterThan(0);
|
|
const markdown = readFileSync(join(output, "report.md"), "utf8");
|
|
expect(markdown).not.toContain("old success");
|
|
expect(markdown).toMatch(/Infrastructure|infrastructure/);
|
|
} finally {
|
|
rmSync(root, { recursive: true, force: true });
|
|
}
|
|
});
|