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

2 lines
2.6 KiB
JavaScript

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),".."),docs=path.join(root,"docs/p6"),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 l=await import(pathToFileURL(path.join(build,"FreeCADWebRobotRuntimeProbe.js"))),p=await l.default({wasmBinary:fs.readFileSync(path.join(build,"FreeCADWebRobotRuntimeProbe.wasm")),print:()=>{},printErr:()=>{}}),c=(n,t="number",a=[],v=[])=>p.ccall(n,t,a,v),entry="src/Mod/Robot/App/AppRobot.cpp",snap=()=>({valid:c("fc_web_robot_source_inventory_validate","number",["string"],[entry]),entry:c("fc_web_robot_source_entry","string"),summary:c("fc_web_robot_source_summary","string"),types:c("fc_web_robot_registered_type_count"),bindings:c("fc_web_robot_python_binding_count"),released:c("fc_web_robot_inventory_resources_released"),error:c("fc_web_robot_inventory_error","string")}),first=snap(),second=snap(),invalid={valid:c("fc_web_robot_source_inventory_validate","number",["string"],["src/Mod/Robot/App/Missing.cpp"]),error:c("fc_web_robot_inventory_error","string")},hash=v=>crypto.createHash("sha256").update(JSON.stringify(v)).digest("hex"),details={first,second,invalid,deterministic:JSON.stringify(first)===JSON.stringify(second),pass:first.valid===1&&second.valid===1&&first.types===5&&first.bindings===3&&invalid.valid===0&&invalid.error==="revision_mismatch"},fixture={module:"Robot",action:"inspect/source-inventory",sourceEntry:entry},report={schema:"freecad-web-p6-robot-action-02-kernel/v1",taskId:"FW-P6-ROB-ACT-02-C",module:"Robot",action:"inspect/source-inventory",result:details.pass&&details.deterministic?"pass":"fail",fixture:{...fixture,inputSha256:hash(fixture)},details,resultSha256:hash(details),artifacts:{wasm:"freecad-source/build-web/configure/bin/FreeCADWebRobotRuntimeProbe.wasm",workerLog:"docs/freecad-p6-robot-action-02-c-kernel.log"},boundaries:["Inventory is read-only; RobotGui and optional simulation actions remain excluded."]};fs.writeFileSync(path.join(docs,"robot-action-02-kernel.json"),JSON.stringify(report,null,2)+"\n");fs.writeFileSync(path.join(root,"docs/freecad-p6-robot-action-02-c-kernel.log"),JSON.stringify({result:report.result,types:first.types,bindings:first.bindings})+"\n");console.log(JSON.stringify({result:report.result,types:first.types,bindings:first.bindings}));if(report.result!=="pass")process.exitCode=1;