mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
refactor(qa): share artifact write assertion
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import fs from "node:fs/promises";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import { QaSuiteArtifactError } from "./errors.js";
|
||||
|
||||
export async function assertQaSuiteArtifactWritten(
|
||||
kind: "evidence" | "report" | "summary",
|
||||
filePath: string,
|
||||
) {
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
} catch (error) {
|
||||
throw new QaSuiteArtifactError(
|
||||
`${kind}_missing`,
|
||||
`QA suite did not produce ${kind} artifact at ${filePath}: ${formatErrorMessage(error)}`,
|
||||
{ cause: error },
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
type QaReportScenario,
|
||||
} from "openclaw/plugin-sdk/qa-runtime";
|
||||
import { fetchWithSsrFGuard } from "openclaw/plugin-sdk/ssrf-runtime";
|
||||
import { QaSuiteArtifactError } from "./errors.js";
|
||||
import { assertQaSuiteArtifactWritten } from "./artifact-assertion.js";
|
||||
import { buildQaSuiteEvidenceSummary, QA_EVIDENCE_FILENAME } from "./evidence-summary.js";
|
||||
import { startQaGatewayChild, type QaCliBackendAuthMode } from "./gateway-child.js";
|
||||
import type {
|
||||
@@ -884,21 +884,6 @@ async function writeQaSuiteArtifacts(params: {
|
||||
return { evidencePath, report, reportPath, summaryPath };
|
||||
}
|
||||
|
||||
async function assertQaSuiteArtifactWritten(
|
||||
kind: "evidence" | "report" | "summary",
|
||||
filePath: string,
|
||||
) {
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
} catch (error) {
|
||||
throw new QaSuiteArtifactError(
|
||||
`${kind}_missing`,
|
||||
`QA suite did not produce ${kind} artifact at ${filePath}: ${formatErrorMessage(error)}`,
|
||||
{ cause: error },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function buildQaSuiteRuntimeMetrics(params: {
|
||||
startedAt: Date;
|
||||
finishedAt: Date;
|
||||
|
||||
@@ -2,8 +2,8 @@ import { spawn } from "node:child_process";
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
||||
import { assertQaSuiteArtifactWritten } from "./artifact-assertion.js";
|
||||
import { isRepoRootRelativeRef, toRepoRelativePath } from "./cli-paths.js";
|
||||
import { QaSuiteArtifactError } from "./errors.js";
|
||||
import {
|
||||
buildPlaywrightEvidenceSummary,
|
||||
buildScriptEvidenceSummary,
|
||||
@@ -542,22 +542,10 @@ async function writeTestFileEvidenceFile(params: {
|
||||
}): Promise<Pick<QaTestFileScenarioRunResult, "evidencePath">> {
|
||||
const evidencePath = path.join(params.outputDir, QA_EVIDENCE_FILENAME);
|
||||
await fs.writeFile(evidencePath, `${JSON.stringify(params.evidence, null, 2)}\n`, "utf8");
|
||||
await assertQaTestFileArtifactWritten("evidence", evidencePath);
|
||||
await assertQaSuiteArtifactWritten("evidence", evidencePath);
|
||||
return { evidencePath };
|
||||
}
|
||||
|
||||
async function assertQaTestFileArtifactWritten(kind: "evidence", filePath: string) {
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
} catch (error) {
|
||||
throw new QaSuiteArtifactError(
|
||||
`${kind}_missing`,
|
||||
`QA suite did not produce ${kind} artifact at ${filePath}: ${formatErrorMessage(error)}`,
|
||||
{ cause: error },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export async function runQaTestFileScenarios(
|
||||
params: QaTestFileScenarioRunParams,
|
||||
): Promise<QaTestFileScenarioRunResult> {
|
||||
|
||||
Reference in New Issue
Block a user