4 lines
3.0 KiB
JavaScript
4 lines
3.0 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, "FreeCADWebMeshRuntimeProbe.js"))); const kernel = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebMeshRuntimeProbe.wasm")) }); const call = (name, type = "number", argTypes = [], args = []) => kernel.ccall(name, type, argTypes, args); const entry = "src/Mod/Mesh/App/AppMesh.cpp"; const run = () => ({ run: call("fc_web_mesh_source_inventory_validate", "number", ["string"], [entry]), sourceEntry: call("fc_web_mesh_inventory_source_entry", "string"), apiCount: call("fc_web_mesh_inventory_python_bindings"), readOnly: call("fc_web_mesh_inventory_read_only"), resourcesReleased: call("fc_web_mesh_inventory_resources_released"), code: call("fc_web_mesh_inventory_error_code", "string"), message: call("fc_web_mesh_inventory_error_message", "string") }); const first = run(); const second = run(); const fixture = { module: "Mesh", action: "python-api", sourceEntry: entry, apiNames: ["MeshPoint", "Edge", "Facet", "Mesh", "Feature"] }; if (first.run !== 1 || second.run !== 1 || first.sourceEntry !== entry || first.apiCount !== 5 || first.readOnly !== 1 || first.resourcesReleased !== 1 || JSON.stringify(first) !== JSON.stringify(second)) throw new Error(JSON.stringify({ first, second })); const report = { schema: "freecad-web-p6-mesh-action-04-kernel/v1", taskId: "FW-P6-MSH-ACT-04-C", module: "Mesh", action: "python-api", result: "pass", fixture: { ...fixture, inputSha256: crypto.createHash("sha256").update(JSON.stringify(fixture)).digest("hex") }, replay: { first, second, identicalResult: true, resultSha256: crypto.createHash("sha256").update(JSON.stringify(first)).digest("hex") }, resultSummary: { sourceEntry: entry, apiCount: first.apiCount, apiNames: fixture.apiNames, readOnly: true, resourcesReleased: true }, commands: ["node tools/run_p6_mesh_action04_kernel_smoke.mjs freecad-source/build-web/configure/bin"], artifacts: { wasm: "freecad-source/build-web/configure/bin/FreeCADWebMeshRuntimeProbe.wasm", workerLog: "docs/freecad-p6-mesh-action-04-c-kernel.log" }, boundaries: ["This is read-only API registration evidence, not arbitrary Python execution."] }; fs.writeFileSync(path.join(docs, "mesh-action-04-kernel.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(root, "docs/freecad-p6-mesh-action-04-c-kernel.log"), `${JSON.stringify({ result: report.result, sourceEntry: entry, apiCount: first.apiCount, apiNames: fixture.apiNames })}\n`); console.log(JSON.stringify({ result: report.result, apiCount: first.apiCount, apiNames: fixture.apiNames }));
|