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 abs = (file) => path.join(root, file); const sha = (file) => crypto.createHash("sha256").update(fs.readFileSync(abs(file))).digest("hex"); const out = "tests/golden/WBV2-P27-002"; const source = "blender-5.2.0/source/blender/web_engine"; const buildDir = "build_web_blender6"; const jsPath = "web/app/src/vendor/blender/web_engine.js"; const wasmPath = "web/app/src/vendor/blender/web_engine.wasm"; const logPath = `${out}/source-build.log`; const distAssets = fs.readdirSync(abs("web/dist/assets")); const distWorker = distAssets.find((file) => /^web-engine\.worker-.*\.js$/u.test(file)); const distWasm = distAssets.find((file) => /^web_engine-.*\.wasm$/u.test(file)); assert.ok(fs.existsSync(abs(`${buildDir}/bin/web_engine.js`))); assert.ok(fs.existsSync(abs(`${buildDir}/bin/web_engine.wasm`))); assert.equal(sha(`${buildDir}/bin/web_engine.js`), sha(jsPath)); assert.equal(sha(`${buildDir}/bin/web_engine.wasm`), sha(wasmPath)); assert.ok(distWorker); assert.ok(distWasm); const report = { schemaVersion: 1, task: "WBV2-P27-002", operation: "COMPILE_SOURCE_BACKED_WEBENGINE_PREREQUISITE", status: "PASS", implementationPrerequisite: { sourceRoot: "blender-5.2.0", buildDirectory: buildDir, target: "web_engine", cmakeToolchain: ".emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake", emscriptenVersion: "3.1.69", hostNode: ".emsdk/node/24.19.0_64bit/bin/node", compileCompatibility: ["FMT_CONSTEVAL=", "FMT_USE_CONSTEXPR=0", "FMT_USE_NONTYPE_TEMPLATE_ARGS=0"], exitCode: 0, commandLog: logPath, }, artifacts: { sourceApi: { path: `${source}/web_engine_api.cpp`, sha256: sha(`${source}/web_engine_api.cpp`) }, sourceMainState: { path: `${source}/web_engine_main_state.cpp`, sha256: sha(`${source}/web_engine_main_state.cpp`) }, sourceMainHeader: { path: `${source}/web_engine_main_state.h`, sha256: sha(`${source}/web_engine_main_state.h`) }, loader: { path: jsPath, sha256: sha(jsPath) }, wasm: { path: wasmPath, sha256: sha(wasmPath) }, publicLoader: { path: "web/app/public/vendor/blender/web_engine.js", sha256: sha("web/app/public/vendor/blender/web_engine.js") }, publicWasm: { path: "web/app/public/vendor/blender/web_engine.wasm", sha256: sha("web/app/public/vendor/blender/web_engine.wasm") }, webDistIndex: { path: "web/dist/index.html", sha256: sha("web/dist/index.html") }, webDistWorker: { path: `web/dist/assets/${distWorker}`, sha256: sha(`web/dist/assets/${distWorker}`) }, webDistWasm: { path: `web/dist/assets/${distWasm}`, sha256: sha(`web/dist/assets/${distWasm}`) }, }, verification: { chromium: "DEFERRED", productionReceipts: false, malformedBoundary: false, undoRedo: false, saveReopen: false, deterministicSecondRun: false, completionOverlay: false }, inventory: { total: 6900, legacyCompleted: 281, legacyPending: 6618, effectiveCompleted: 290, effectivePending: 6609 }, }; fs.writeFileSync(abs(`${out}/source-build-report.json`), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(abs("docs/status/WBV2-P27-002.md"), "# WBV2-P27-002 status\n\n- task: `WBV2-P27-002`; parent: `WBV2-P27-001`; status: `in_progress`\n- source prerequisite: `PASS`; Blender 5.2.0 `web_engine` compiled from `blender-5.2.0` with local Emscripten 3.1.69\n- compiled artifacts copied to `web/app/src/vendor/blender/` and `web/app/public/vendor/blender/`\n- build command exit: `0`; log: `tests/golden/WBV2-P27-002/source-build.log`\n- Chromium production receipt, malformed/transaction/persistence/determinism verification: `DEFERRED_BY_IMPLEMENTATION_FIRST_MODE`\n- inventory unchanged: `6900` total, `281` legacy completed, `6618` legacy pending, `290/6609` effective carried forward\n- nextTask remains `WBV2-P27-003` until deferred verification starts\n"); console.log(`wbv2-source-build-recorded task=WBV2-P27-002 wasm=${sha(wasmPath)} js=${sha(jsPath)} verification=DEFERRED`);