4 lines
3.4 KiB
JavaScript
4 lines
3.4 KiB
JavaScript
#!/usr/bin/env node
|
|
import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; import { createRequire } from "node:module"; import { pathToFileURL } from "node:url";
|
|
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), ".."); const build = path.resolve(process.argv[2] ?? path.join(root, "freecad-source/build-web/configure/bin")); globalThis.__dirname = `${build}${path.sep}`; globalThis.require = createRequire(import.meta.url); const loader = await import(pathToFileURL(path.join(build, "FreeCADWebMeasureRuntimeProbe.js"))); const kernel = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebMeasureRuntimeProbe.wasm")) }); const c = (name, type = "number", argTypes = [], args = []) => kernel.ccall(name, type, argTypes, args); const initialize = (name) => ({ run: c("fc_web_measure_initialize", "number", ["string"], [name]), code: c("fc_web_measure_error_code", "string"), message: c("fc_web_measure_error_message", "string"), calls: c("fc_web_measure_initialization_calls"), runs: c("fc_web_measure_initialization_runs"), initialized: c("fc_web_measure_initialized") }); const first = initialize("Measure"); const repeated = initialize("Measure"); const type = { run: c("fc_web_measure_type_probe", "number", ["string"], ["Measure::MeasureDistance"]), type: c("fc_web_measure_last_type", "string"), code: c("fc_web_measure_error_code", "string") }; const missing = initialize("MeasureMissing"); const gui = initialize("MeasureGui"); const result = { first, repeated, type, missing, gui }; const stable = JSON.stringify(result); if (first.run !== 1 || repeated.run !== 1 || first.runs !== 1 || repeated.runs !== 1 || type.run !== 1 || type.type !== "Measure::MeasureDistance" || missing.code !== "module_unavailable" || gui.code !== "gui_dependency_unavailable") throw new Error(stable); const report = { schema: "freecad-web-p6-measure-runtime/v1", taskId: "FW-P6-MEA-B", module: "Measure", result: "pass", resultSha256: crypto.createHash("sha256").update(stable).digest("hex"), responses: result, initialization: { calls: repeated.calls, runs: repeated.runs, idempotent: repeated.runs === 1 }, dependencies: { part: true, freecadApp: true, gui: false }, commands: ["cmake --build freecad-source/build-web/configure --target FreeCADWebMeasureRuntimeProbe -j 8", "node tools/run_p6_measure_runtime_smoke.mjs freecad-source/build-web/configure/bin"], artifacts: { wasm: "freecad-source/build-web/configure/bin/FreeCADWebMeasureRuntimeProbe.wasm", workerLog: "docs/freecad-p6-measure-b-runtime.log" }, boundaries: ["Runtime verifies Measure module registration and Measure::MeasureDistance visibility only; GUI measurement actions remain deferred."] }; report.wasmSha256 = crypto.createHash("sha256").update(fs.readFileSync(path.join(build, "FreeCADWebMeasureRuntimeProbe.wasm"))).digest("hex"); fs.writeFileSync(path.join(root, "docs/p6/measure-runtime.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(root, "docs/freecad-p6-measure-b-runtime.log"), `${JSON.stringify({ result: report.result, initializationRuns: report.initialization.runs, type: report.responses.type.type, missingCode: report.responses.missing.code, guiCode: report.responses.gui.code, wasmSha256: report.wasmSha256 })}\n`); console.log(JSON.stringify({ result: report.result, initializationRuns: report.initialization.runs, type: report.responses.type.type, wasmSha256: report.wasmSha256 }));
|