mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
Benchmark verdicts could pass with selected workloads or required metrics missing, empty or non-finite, and pnpm perf:rust could accept stale or partial criterion results. Selections and counts are now validated before any work starts, every selected workload must report finite values for its required metrics, and Rust results are collected only for the selected packages from fresh, well-formed criterion artifacts, against a list of the benchmarks each package owns. Co-authored-by: Mr0Bread <55754540+Mr0Bread@users.noreply.github.com>
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { resolve } from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import { countOption } from "./options.ts";
|
|
|
|
const root = resolve(import.meta.dirname, "../..");
|
|
|
|
describe("benchmark CLI validation", () => {
|
|
it.each([
|
|
["runs", "NaN"],
|
|
["runs", "Infinity"],
|
|
["runs", "0"],
|
|
["runs", "1.5"],
|
|
["warmup", "-1"],
|
|
["warmup", "NaN"],
|
|
["warmup", "0.5"],
|
|
["cpu", "NaN"],
|
|
["cpu", "Infinity"],
|
|
["cpu", "0"],
|
|
])("rejects --%s %s before selecting or launching workloads", (option, value) => {
|
|
const result = spawnSync(
|
|
process.execPath,
|
|
["perf/run.ts", "--no-build", "--only", "__unknown__", `--${option}=${value}`],
|
|
{ cwd: root, encoding: "utf8", timeout: 10_000 },
|
|
);
|
|
expect(result.status).toBe(1);
|
|
expect(result.stderr).toContain(`--${option} must be`);
|
|
expect(result.stdout).not.toContain("Building");
|
|
});
|
|
|
|
it.each(["typing,__unknown__", "", "typing,"])("rejects invalid selection %j", (selection) => {
|
|
const result = spawnSync(process.execPath, ["perf/run.ts", "--no-build", "--only", selection], {
|
|
cwd: root,
|
|
encoding: "utf8",
|
|
timeout: 10_000,
|
|
});
|
|
expect(result.status).toBe(1);
|
|
expect(result.stderr).toContain("unknown scenario(s)");
|
|
});
|
|
|
|
it("accepts integral counts and zero warmup without silently clamping", () => {
|
|
expect(countOption("runs", "5", 1)).toBe(5);
|
|
expect(countOption("warmup", "0", 0)).toBe(0);
|
|
expect(() => countOption("warmup", "", 0)).toThrow();
|
|
expect(() => countOption("runs", "9007199254740992", 1)).toThrow();
|
|
});
|
|
});
|