16 lines
3.4 KiB
JavaScript
16 lines
3.4 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import crypto from "node:crypto";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { execFileSync } from "node:child_process";
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
const generator = path.join(root, "tools/web/generate-blender-next-task-plan.mjs"); const planPath = path.join(root, "tests/golden/M15-03A/next-task-plan.json"); const reportPath = path.join(root, "tests/golden/M15-03A/next-task-plan-check-report.json"); const manifestPath = path.join(root, "tests/golden/M15-03A/manifest.json"); const sha256 = (b) => crypto.createHash("sha256").update(b).digest("hex"); const fileSha256 = (f) => sha256(fs.readFileSync(f)); const relative = (f) => path.relative(root, f).replaceAll(path.sep, "/");
|
|
const plan = JSON.parse(fs.readFileSync(planPath, "utf8")); assert.equal(plan.task, "M15-03A"); assert.equal(plan.operation, "BLENDER_NEXT_TASK_PLAN"); assert.equal(plan.tasks.length, 6900); assert.equal(plan.summary.active, 1); assert.equal(plan.summary.completed + plan.summary.pending + plan.summary.active, 6900); assert.equal(plan.firstTask, plan.tasks.find((task) => task.state === "active").id); assert.equal(plan.closureGate, "M15-03E");
|
|
const ids = plan.tasks.map((task) => task.id); const gaps = plan.tasks.map((task) => task.gapId); assert.equal(new Set(ids).size, ids.length); assert.equal(new Set(gaps).size, gaps.length); assert.ok(plan.tasks.every((task) => /^M(?:1[6-9]|2[0-2])-GAP-\d{5}$/.test(task.id))); assert.ok(plan.tasks.every((task) => task.ownerFamily && !task.id.includes("FAMILY")));
|
|
for (const source of Object.values(plan.sources)) assert.equal(fileSha256(path.join(root, source.path)), source.sha256, source.path);
|
|
const temporary = path.join(root, ".tmp-m15-03a-plan.json"); try { execFileSync(process.execPath, [generator, temporary], { cwd: root, stdio: "pipe", maxBuffer: 32 * 1024 * 1024 }); assert.deepEqual(fs.readFileSync(temporary), fs.readFileSync(planPath), "next-task plan is not deterministic"); } finally { fs.rmSync(temporary, { force: true }); }
|
|
const report = { schemaVersion: 1, task: "M15-03A", operation: "BLENDER_NEXT_TASK_PLAN_CHECK", summary: plan.summary, firstTask: plan.firstTask, planSha256: fileSha256(planPath), nextTask: plan.nextTask };
|
|
if (process.env.UPDATE_M15_03A_MANIFEST === "1") { fs.mkdirSync(path.dirname(reportPath), { recursive: true }); fs.writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`); const paths = { parentManifest: path.join(root, "tests/golden/M15-02F/manifest.json"), generator, checker: path.join(root, "tools/web/check-blender-next-task-plan.mjs"), plan: planPath, report: reportPath, package: path.join(root, "web/package.json") }; const artifacts = Object.fromEntries(Object.entries(paths).map(([name, file]) => [name, { path: relative(file), sha256: fileSha256(file) }])); fs.writeFileSync(manifestPath, `${JSON.stringify({ schemaVersion: 1, task: "M15-03A", parentTask: "M15-02F", enablingTask: false, parityStateChange: false, operation: "BLENDER_NEXT_TASK_PLAN", artifacts, nextTask: "M15-03B" }, null, 2)}\n`); }
|
|
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8")); for (const artifact of Object.values(manifest.artifacts)) assert.equal(fileSha256(path.join(root, artifact.path)), artifact.sha256, artifact.path); process.stdout.write(`blender-next-task-plan-ok tasks=${plan.tasks.length} active=1 first=${plan.firstTask} next=${manifest.nextTask}\n`);
|