Files
FreeCADWasmDev/tools/run_p6_sketcher_geometry_family_r1.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

57 lines
2.8 KiB
JavaScript

#!/usr/bin/env node
import assert from "node:assert/strict";
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, "FreeCADWebSketcherProbe.js")));
const kernel = await loader.default({
wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebSketcherProbe.wasm")),
print: () => {},
printErr: () => {},
});
const request = { cmd: "sketcher.geometryFamily", args: {} };
const raw = String(kernel.ccall("fc_web_dispatch_json", "string", ["string"], [JSON.stringify(request)]));
const native = JSON.parse(raw);
assert.equal(native.ok, true, raw);
assert.equal(native.cmd, request.cmd);
assert.equal(native.count, 9);
assert.equal(native.passed, 9);
assert.equal(native.resourcesReleased, true);
assert.equal(native.source, "freecad-source");
assert.equal(native.records.length, 9);
for (const record of native.records) {
assert.equal(record.status, "passed", JSON.stringify(record));
assert.equal(record.resourcesReleased, true, JSON.stringify(record));
}
const wasmPath = path.join(build, "FreeCADWebSketcherProbe.wasm");
const report = {
schema: "freecad-web-p6-sketcher-geometry-family-r1/v1",
taskId: "FW-P6-FPA-D1-SKETCHER-R1",
result: "passed",
command: request,
native,
source: {
dispatcher: "fc_web_dispatch_json",
probe: "freecad-source/src/WebAssembly/FreeCADCoreProbe/SketcherProbe.cpp",
wasm: "freecad-source/build-web/configure/bin/FreeCADWebSketcherProbe.wasm",
wasmSha256: crypto.createHash("sha256").update(fs.readFileSync(wasmPath)).digest("hex"),
},
boundaries: [
"All nine previously registration-only Sketcher types now have native construction/property fixtures.",
"Sketcher::SketchObject representative geometry/recompute evidence remains preserved in sketcher-geometry-family-kernel.json.",
"React/Worker layers consume the structured dispatcher result; no JavaScript geometry algorithm is used.",
],
};
fs.writeFileSync(path.join(root, "docs/p6/sketcher-geometry-family-r1.json"), `${JSON.stringify(report, null, 2)}\n`);
fs.writeFileSync(path.join(root, "docs/freecad-p6-sketcher-geometry-family-r1.log"), `${JSON.stringify({ result: report.result, count: native.count, passed: native.passed, resourcesReleased: native.resourcesReleased })}\n`);
console.log(JSON.stringify({ result: report.result, count: native.count, passed: native.passed, resourcesReleased: native.resourcesReleased }));