Files
workinf_Blender_Wasm/tools/web/check-stl-edge-parity.mjs
mes123456 380cbed4ff
Some checks failed
M6 deployable RC / quick (push) Has been cancelled
M6 deployable RC / chromium (push) Has been cancelled
M6 deployable RC / release (push) Has been cancelled
Checkpoint web parity through Chromium input tasks
2026-08-19 10:39:03 -04:00

48 lines
3.0 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";
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-07E/manifest.json"), "utf8"));
const fixtures = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-07E/edge-fixtures.json"), "utf8"));
const desktop = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-07E/desktop-edge-report.json"), "utf8"));
const web = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-07E/web-edge-report.json"), "utf8"));
const fileHash = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
assert.deepEqual(
{ schemaVersion: manifest.schemaVersion, task: manifest.task, parentTask: manifest.parentTask, nextTask: manifest.nextTask },
{ schemaVersion: 1, task: "M12-07E", parentTask: "M12-07D", nextTask: "M12-07F" },
);
assert.deepEqual(
{ schemaVersion: fixtures.schemaVersion, task: fixtures.task, operation: fixtures.operation, nextTask: fixtures.nextTask },
{ schemaVersion: 1, task: "M12-07E", operation: "STL_EDGE_FIXTURE_GENERATION", nextTask: "M12-07F" },
);
assert.deepEqual(fixtures.fixtures.map((fixture) => [fixture.id, fixture.expectedCode]), [["DEGENERATE_TRIANGLE", "STL_DEGENERATE_TRIANGLE"], ["TRAILING_BYTES", "STL_TRAILING_BYTES"]]);
assert.equal(desktop.operation, "BLENDER_STL_EDGE_PROBE");
assert.equal(desktop.cases.length, 4);
assert.equal(desktop.cases.find((item) => item.id === "DEGENERATE_TRIANGLE").result.triangleCount, 1);
assert.equal(desktop.cases.find((item) => item.id === "TRAILING_BYTES").result.triangleCount, 0);
assert.equal(web.operation, "STL_NORMAL_UNIT_EDGE_PARITY");
assert.deepEqual(web.comparisons, {
binaryAsciiNormalExact: true,
desktopNormalExact: true,
webUnitRatio: 1000,
desktopUnitRatio: 999.999952502551,
unitRatioExactWithinFloat32: true,
degenerateTriangleExact: true,
trailingBytes: { web: "BLOCKED/STL_TRAILING_BYTES", desktop: "ACCEPTED_EMPTY", parity: "STRICTER_WEB_BLOCK" },
});
const webById = Object.fromEntries(web.browser.map((item) => [item.id, item]));
assert.equal(webById.BINARY_UNIT_1.result.triangleCount, 2);
assert.equal(webById.ASCII_UNIT_1.result.triangleCount, 2);
assert.equal(webById.DEGENERATE_TRIANGLE.result.removedDegenerateTriangles, 1);
assert.deepEqual(webById.TRAILING_BYTES, { id: "TRAILING_BYTES", status: "BLOCKED", code: "STL_TRAILING_BYTES" });
for (const artifact of Object.values(manifest.artifacts)) {
const file = path.join(root, artifact.path);
assert.ok(fs.existsSync(file), `missing artifact ${artifact.path}`);
assert.equal(fileHash(file), artifact.sha256, `hash mismatch ${artifact.path}`);
}
process.stdout.write(`stl-edge-parity-ok normals=exact unitRatio=${web.comparisons.webUnitRatio} degenerate=removed trailing=${web.comparisons.trailingBytes.parity} next=${manifest.nextTask}\n`);