Checkpoint web parity through Chromium input tasks
This commit is contained in:
46
tools/web/check-ply-mapping-fixtures.mjs
Normal file
46
tools/web/check-ply-mapping-fixtures.mjs
Normal file
@@ -0,0 +1,46 @@
|
||||
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 { spawnSync } 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/M12-07H/manifest.json");
|
||||
const reportPath = path.join(root, "tests/golden/M12-07H/mapping-report.json");
|
||||
const fixtureRoot = path.join(root, "tests/files/web/m12_ply_mapping_v1");
|
||||
const generator = path.join(root, "tools/web/generate-ply-mapping-fixtures.py");
|
||||
const blender = process.env.BLENDER_BIN ?? path.join(root, "build_blender_5.2.0/bin/blender");
|
||||
const sha256 = (bytes) => crypto.createHash("sha256").update(bytes).digest("hex");
|
||||
const fileHash = (file) => sha256(fs.readFileSync(file));
|
||||
const readJson = (file) => JSON.parse(fs.readFileSync(file, "utf8"));
|
||||
|
||||
const manifest = readJson(manifestPath);
|
||||
const report = readJson(reportPath);
|
||||
assert.deepEqual({ schemaVersion: manifest.schemaVersion, task: manifest.task, parentTask: manifest.parentTask, nextTask: manifest.nextTask }, { schemaVersion: 1, task: "M12-07H", parentTask: "M12-07G", nextTask: "M12-07I" });
|
||||
assert.deepEqual({ schemaVersion: report.schemaVersion, task: report.task, operation: report.operation, nextTask: report.nextTask }, { schemaVersion: 1, task: "M12-07H", operation: "PLY_VERTEX_FACE_COLOR_CUSTOM_MAPPING", nextTask: "M12-07I" });
|
||||
assert.deepEqual(report.variants.map((variant) => variant.semantic.vertexCount), [4, 4]);
|
||||
assert.deepEqual(report.variants.map((variant) => variant.semantic.faceCount), [2, 2]);
|
||||
assert.deepEqual(report.variants[0].semantic.vertices[0].color, [254, 0, 0, 255]);
|
||||
assert.deepEqual(report.variants[0].semantic.vertices[0].customProperties, { label: 1, temperature: 10 });
|
||||
assert.deepEqual(report.unknownProperty, { file: "unknown-property-ascii.ply", property: "unknown_values", expectedCode: "PLY_UNKNOWN_PROPERTY" });
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
const absolute = path.join(root, artifact.path);
|
||||
assert.ok(fs.existsSync(absolute), `missing artifact ${artifact.path}`);
|
||||
assert.equal(fileHash(absolute), artifact.sha256, `hash mismatch ${artifact.path}`);
|
||||
}
|
||||
for (const file of report.files) assert.equal(fileHash(path.join(fixtureRoot, file.name)), file.sha256, `fixture hash mismatch ${file.name}`);
|
||||
const inventory = readJson(path.join(root, "tests/golden/M12-05A/format-inventory.json"));
|
||||
for (const key of ["blenderVersion", "versionTuple", "buildDate", "buildTime", "buildHash", "buildBranch", "buildPlatform", "buildType", "binarySha256"]) assert.deepEqual(report.runtime[key], inventory.runtime[key], `runtime drift in ${key}`);
|
||||
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "m12-07h-ply-"));
|
||||
try {
|
||||
const regeneratedReport = path.join(temporary, "mapping-report.json");
|
||||
const result = spawnSync(blender, ["-b", "--factory-startup", "--python", generator, "--", temporary, regeneratedReport], { cwd: root, encoding: "utf8", maxBuffer: 20 * 1024 * 1024 });
|
||||
assert.equal(result.status, 0, `${result.stdout}\n${result.stderr}`);
|
||||
assert.deepEqual(readJson(regeneratedReport), report, "PLY mapping report is not deterministic");
|
||||
for (const file of report.files) assert.deepEqual(fs.readFileSync(path.join(temporary, file.name)), fs.readFileSync(path.join(fixtureRoot, file.name)), `${file.name} bytes are not deterministic`);
|
||||
}
|
||||
finally { fs.rmSync(temporary, { recursive: true, force: true }); }
|
||||
process.stdout.write(`ply-mapping-fixtures-ok vertices=4 faces=2 colors=rgba custom=2 unknown=PLY_UNKNOWN_PROPERTY deterministic=true next=${manifest.nextTask}\n`);
|
||||
Reference in New Issue
Block a user