mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-07 10:34:44 +00:00
fix(scripts): fail missing test group reports
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user