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-06F/manifest.json"), "utf8")); const report = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-06F/negative-report.json"), "utf8")); const sha256 = (bytes) => crypto.createHash("sha256").update(bytes).digest("hex"); const fileHash = (file) => sha256(fs.readFileSync(file)); assert.deepEqual( { schemaVersion: manifest.schemaVersion, task: manifest.task, parentTask: manifest.parentTask, nextTask: manifest.nextTask }, { schemaVersion: 1, task: "M12-06F", parentTask: "M12-06E", nextTask: "M12-06G" }, ); assert.deepEqual(report, { schemaVersion: 1, task: "M12-06F", operation: "GLB_IMPORT_NEGATIVE_CASES", budget: { maxBytes: 524288, maxJsonBytes: 262144, maxBufferViews: 4096, maxAccessors: 8192 }, cases: [ { id: "sparse", code: "GLB_SPARSE_ACCESSOR_UNSUPPORTED" }, { id: "extension", code: "GLB_EXTENSION_UNSUPPORTED" }, { id: "external-uri", code: "GLB_EXTERNAL_URI_BLOCKED" }, { id: "over-budget", code: "GLB_IMPORT_BUDGET_EXCEEDED" }, ], nextTask: "M12-06G", }); 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(`glb-negative-cases-ok cases=${report.cases.length} budget=${report.budget.maxBytes} deterministic=true next=${manifest.nextTask}\n`);