Files
FreeCADWasmDev/tools/run_p6_meshpart_kernel_smoke.mjs
wangdequan 9a7c4f0335 Save FreeCAD Web workspace sources and user validation evidence
IFC native binding remains incomplete; preserve accurate test results.
2026-09-15 22:01:58 +08:00

4 lines
2.8 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 docs = path.join(root, "docs/p6"); 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, "FreeCADWebMeshPartRuntimeProbe.js"))); const kernel = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebMeshPartRuntimeProbe.wasm")) }); const c = (name, type = "number") => kernel.ccall(name, type); const run = () => ({ run: c("fc_web_meshpart_create_recompute"), facets: c("fc_web_meshpart_kernel_facets"), points: c("fc_web_meshpart_kernel_points"), resourcesReleased: c("fc_web_meshpart_kernel_resources_released"), code: c("fc_web_meshpart_kernel_error_code", "string"), message: c("fc_web_meshpart_kernel_error_message", "string") }); const fixture = { module: "MeshPart", action: "create/recompute", source: "Part::Box 1x1x1", method: "Mesher::Standard" }; const first = run(); const second = run(); const stable = JSON.stringify(first) === JSON.stringify(second); if (first.run !== 1 || second.run !== 1 || first.facets <= 0 || first.points <= 0 || first.resourcesReleased !== 1 || first.code !== "" || !stable) throw new Error(JSON.stringify({ first, second, stable })); const report = { schema: "freecad-web-p6-meshpart-kernel/v1", taskId: "FW-P6-MSP-C", module: "MeshPart", action: "create/recompute", result: "pass", fixture: { ...fixture, inputSha256: crypto.createHash("sha256").update(JSON.stringify(fixture)).digest("hex") }, replay: { first, second, identicalResult: stable, resultSha256: crypto.createHash("sha256").update(JSON.stringify(first)).digest("hex") }, resultSummary: { objectType: "Part::Box", method: "Mesher::Standard", facetCount: first.facets, pointCount: first.points, resourcesReleased: true }, commands: ["node tools/run_p6_meshpart_kernel_smoke.mjs freecad-source/build-web/configure/bin"], artifacts: { wasm: "freecad-source/build-web/configure/bin/FreeCADWebMeshPartRuntimeProbe.wasm", workerLog: "docs/freecad-p6-meshpart-c-kernel.log" }, boundaries: ["Only the no-SMESH OCC standard mesher fixture is covered; Netgen/Mefisto and GUI tessellation remain excluded."] }; fs.writeFileSync(path.join(docs, "meshpart-kernel.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(root, "docs/freecad-p6-meshpart-c-kernel.log"), `${JSON.stringify({ result: report.result, facets: first.facets, points: first.points, resourcesReleased: true })}\n`); console.log(JSON.stringify({ result: report.result, facets: first.facets, points: first.points }));