Tests: scope grouped benchmark artifacts

This commit is contained in:
Gustavo Madeira Santana
2026-04-16 23:45:57 -04:00
parent 8e444ac5a6
commit e8ae3901b6
2 changed files with 25 additions and 3 deletions

View File

@@ -220,6 +220,17 @@ function readGroupedReport(reportPath) {
return JSON.parse(fs.readFileSync(reportPath, "utf8"));
}
export function resolveReportArtifactDirs(outputPath) {
const outputDir = path.dirname(outputPath);
const outputExt = path.extname(outputPath);
const outputStem = path.basename(outputPath, outputExt) || "group-report";
const artifactDir = path.join(outputDir, outputStem);
return {
reportDir: path.join(artifactDir, "vitest-json"),
logDir: path.join(artifactDir, "logs"),
};
}
function resolveConfigs(args) {
if (args.reports.length > 0) {
return [];
@@ -267,8 +278,7 @@ async function main() {
return;
}
const reportDir = path.join(path.dirname(output), "vitest-json");
const logDir = path.join(path.dirname(output), "logs");
const { reportDir, logDir } = resolveReportArtifactDirs(output);
const runEntries = [];
const configs = resolveConfigs(args);
let failed = false;

View File

@@ -7,7 +7,10 @@ import {
resolveGroupKey,
resolveTestArea,
} from "../../scripts/lib/test-group-report.mjs";
import { parseTestGroupReportArgs } from "../../scripts/test-group-report.mjs";
import {
parseTestGroupReportArgs,
resolveReportArtifactDirs,
} from "../../scripts/test-group-report.mjs";
describe("scripts/test-group-report grouping", () => {
it("groups repo files by stable product area", () => {
@@ -201,3 +204,12 @@ describe("scripts/test-group-report arg parsing", () => {
});
});
});
describe("scripts/test-group-report artifact paths", () => {
it("keeps raw Vitest reports scoped to the output file stem", () => {
expect(resolveReportArtifactDirs(".artifacts/test-perf/baseline-before.json")).toEqual({
reportDir: path.join(".artifacts", "test-perf", "baseline-before", "vitest-json"),
logDir: path.join(".artifacts", "test-perf", "baseline-before", "logs"),
});
});
});