fix(test): clean qa report cli errors

This commit is contained in:
Vincent Koc
2026-06-20 01:58:54 +02:00
parent 3c3f1010aa
commit 1f1c434ede
3 changed files with 114 additions and 32 deletions

View File

@@ -45,12 +45,17 @@ Options:
) as Options;
}
const opts = parseArgs(process.argv.slice(2));
await runQaCoverageReportCommand({
...(opts.json ? { json: true } : {}),
...(opts.match ? { match: opts.match } : {}),
...(opts.output ? { output: opts.output } : {}),
...(opts.repoRoot ? { repoRoot: opts.repoRoot } : {}),
...(opts.summary ? { summary: opts.summary } : {}),
...(opts.tools ? { tools: true } : {}),
});
try {
const opts = parseArgs(process.argv.slice(2));
await runQaCoverageReportCommand({
...(opts.json ? { json: true } : {}),
...(opts.match ? { match: opts.match } : {}),
...(opts.output ? { output: opts.output } : {}),
...(opts.repoRoot ? { repoRoot: opts.repoRoot } : {}),
...(opts.summary ? { summary: opts.summary } : {}),
...(opts.tools ? { tools: true } : {}),
});
} catch (error) {
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
process.exitCode = 1;
}

View File

@@ -54,28 +54,33 @@ Options:
) as Options;
}
const opts = parseArgs(process.argv.slice(2));
if (opts.runtimeAxis) {
if (!opts.summary) {
throw new Error("--summary is required when --runtime-axis is set.");
try {
const opts = parseArgs(process.argv.slice(2));
if (opts.runtimeAxis) {
if (!opts.summary) {
throw new Error("--summary is required when --runtime-axis is set.");
}
} else {
if (!opts.candidateSummary) {
throw new Error("--candidate-summary is required.");
}
if (!opts.baselineSummary) {
throw new Error("--baseline-summary is required.");
}
}
} else {
if (!opts.candidateSummary) {
throw new Error("--candidate-summary is required.");
}
if (!opts.baselineSummary) {
throw new Error("--baseline-summary is required.");
}
}
await runQaParityReportCommand({
...(opts.baselineSummary ? { baselineSummary: opts.baselineSummary } : {}),
...(opts.candidateSummary ? { candidateSummary: opts.candidateSummary } : {}),
...(opts.baselineLabel ? { baselineLabel: opts.baselineLabel } : {}),
...(opts.candidateLabel ? { candidateLabel: opts.candidateLabel } : {}),
...(opts.outputDir ? { outputDir: opts.outputDir } : {}),
...(opts.repoRoot ? { repoRoot: opts.repoRoot } : {}),
...(opts.runtimeAxis ? { runtimeAxis: opts.runtimeAxis } : {}),
...(opts.summary ? { summary: opts.summary } : {}),
...(opts.tokenEfficiency ? { tokenEfficiency: opts.tokenEfficiency } : {}),
});
await runQaParityReportCommand({
...(opts.baselineSummary ? { baselineSummary: opts.baselineSummary } : {}),
...(opts.candidateSummary ? { candidateSummary: opts.candidateSummary } : {}),
...(opts.baselineLabel ? { baselineLabel: opts.baselineLabel } : {}),
...(opts.candidateLabel ? { candidateLabel: opts.candidateLabel } : {}),
...(opts.outputDir ? { outputDir: opts.outputDir } : {}),
...(opts.repoRoot ? { repoRoot: opts.repoRoot } : {}),
...(opts.runtimeAxis ? { runtimeAxis: opts.runtimeAxis } : {}),
...(opts.summary ? { summary: opts.summary } : {}),
...(opts.tokenEfficiency ? { tokenEfficiency: opts.tokenEfficiency } : {}),
});
} catch (error) {
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
process.exitCode = 1;
}

View File

@@ -0,0 +1,72 @@
// Qa report cli tests cover source entrypoint operator errors.
import { spawnSync } from "node:child_process";
import path from "node:path";
import { describe, expect, it } from "vitest";
const repoRoot = path.resolve(__dirname, "../..");
function runSourceScript(scriptPath: string, ...args: string[]) {
return spawnSync(process.execPath, ["--import", "tsx", scriptPath, ...args], {
cwd: repoRoot,
encoding: "utf8",
});
}
function expectNoNodeStack(stderr: string) {
expect(stderr).not.toContain("Node.js");
expect(stderr).not.toContain("\n at ");
}
describe("QA report source CLIs", () => {
it("prints QA coverage help without an error", () => {
const result = runSourceScript("scripts/qa-coverage-report.ts", "--help");
expect(result.status).toBe(0);
expect(result.stdout).toContain("Usage: openclaw qa coverage");
expect(result.stderr).toBe("");
});
it("prints QA parity help without an error", () => {
const result = runSourceScript("scripts/qa-parity-report.ts", "--help");
expect(result.status).toBe(0);
expect(result.stdout).toContain("Usage: openclaw qa parity-report");
expect(result.stderr).toBe("");
});
it("reports unknown QA coverage options without a Node stack trace", () => {
const result = runSourceScript("scripts/qa-coverage-report.ts", "--wat");
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe("Unknown qa coverage option: --wat");
expectNoNodeStack(result.stderr);
});
it("reports unknown QA parity options without a Node stack trace", () => {
const result = runSourceScript("scripts/qa-parity-report.ts", "--wat");
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe("Unknown qa parity-report option: --wat");
expectNoNodeStack(result.stderr);
});
it("reports missing QA parity inputs without a Node stack trace", () => {
const result = runSourceScript("scripts/qa-parity-report.ts");
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe("--candidate-summary is required.");
expectNoNodeStack(result.stderr);
});
it("reports missing runtime-axis QA parity summary without a Node stack trace", () => {
const result = runSourceScript("scripts/qa-parity-report.ts", "--runtime-axis");
expect(result.status).toBe(1);
expect(result.stdout).toBe("");
expect(result.stderr.trim()).toBe("--summary is required when --runtime-axis is set.");
expectNoNodeStack(result.stderr);
});
});