fix(scripts): fail missing test group reports

This commit is contained in:
Vincent Koc
2026-06-06 16:38:25 +02:00
parent 4ff0aa9969
commit 205d00bf82
2 changed files with 46 additions and 3 deletions

View File

@@ -414,6 +414,19 @@ function readReportInput(entry) {
};
}
export function readReportInputs(entries) {
const missing = [];
const reports = [];
for (const entry of entries) {
if (!fs.existsSync(entry.reportPath)) {
missing.push(entry);
continue;
}
reports.push(readReportInput(entry));
}
return { missing, reports };
}
function readGroupedReport(reportPath) {
return JSON.parse(fs.readFileSync(reportPath, "utf8"));
}
@@ -666,9 +679,16 @@ async function main() {
process.exit(exitCode);
}
const reportInputs = runEntries
.filter((entry) => fs.existsSync(entry.reportPath))
.map(readReportInput);
const reportInputsResult = readReportInputs(runEntries);
if (reportInputsResult.missing.length > 0) {
for (const entry of reportInputsResult.missing) {
console.error(
`[test-group-report] missing JSON report for ${entry.config}: ${entry.reportPath}`,
);
}
process.exit(1);
}
const reportInputs = reportInputsResult.reports;
const report = buildGroupedTestReport({
groupBy: args.groupBy,
maxTestMs: args.maxTestMs,

View File

@@ -1,4 +1,5 @@
// Test Group Report tests cover test group report script behavior.
import { spawnSync } from "node:child_process";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
@@ -94,6 +95,28 @@ describe("scripts/test-group-report aggregation", () => {
},
]);
});
it("fails missing report inputs instead of writing an empty green report", () => {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-test-group-report-"));
const missingReport = path.join(tempDir, "missing.json");
const output = path.join(tempDir, "group-report.json");
try {
const result = spawnSync(
process.execPath,
["scripts/test-group-report.mjs", "--report", missingReport, "--output", output],
{
cwd: process.cwd(),
encoding: "utf8",
},
);
expect(result.status).toBe(1);
expect(result.stderr).toContain(`[test-group-report] missing JSON report for missing`);
expect(fs.existsSync(output)).toBe(false);
} finally {
fs.rmSync(tempDir, { recursive: true, force: true });
}
});
});
describe("scripts/test-group-report comparison", () => {