Files
workinf_Blender_Wasm/tools/web/check-render-reference.mjs
mes123456 0fe8d2bb56
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions
Advance M8-M11 parity workflows
2026-08-17 04:37:07 -04:00

51 lines
2.2 KiB
JavaScript

import assert from "node:assert/strict";
import crypto from "node:crypto";
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { execFileSync } from "node:child_process";
import { fileURLToPath } from "node:url";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const manifestPath = path.join(root, "tests/golden/M11-04/manifest.json");
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
const fixture = path.join(root, manifest.source.fixture);
const reference = path.join(path.dirname(manifestPath), manifest.reference.file);
const generator = path.join(root, manifest.source.generator);
const blender = process.env.BLENDER_BIN ?? path.join(root, "build_blender_5.2.0/bin/blender");
assert.equal(manifest.schemaVersion, 1);
assert.equal(manifest.task, "M11-04");
assert.equal(manifest.reference.colorSpace, "SRGB8");
assert.equal(manifest.reference.alphaMode, "STRAIGHT");
assert.equal(manifest.reference.width, 256);
assert.equal(manifest.reference.height, 256);
assert.equal(sha256(fixture), manifest.source.fixtureSha256);
assert.equal(sha256(generator), manifest.source.generatorSha256);
assert.equal(sha256(reference), manifest.reference.sha256);
assert.match(execFileSync(blender, ["--version"], { encoding: "utf8" }), /^Blender 5\.2\.0 LTS/m);
const temporaryRoot = fs.mkdtempSync(path.join(os.tmpdir(), "m11-render-reference-"));
try {
const generatedFixture = path.join(temporaryRoot, "reference.blend");
const generatedReference = path.join(temporaryRoot, "reference.png");
execFileSync(blender, [
"--background",
"--factory-startup",
"--python",
generator,
"--",
generatedFixture,
generatedReference,
reference,
], { cwd: root, stdio: "pipe" });
assert.ok(fs.statSync(generatedFixture).size > 0, "desktop reference fixture was not generated");
assert.ok(fs.statSync(generatedReference).size > 0, "desktop reference render was not generated");
}
finally {
fs.rmSync(temporaryRoot, { recursive: true, force: true });
}
console.log(`render-reference-ok blender=5.2.0 fixture=${manifest.source.fixtureSha256} image=${manifest.reference.sha256}`);