2 lines
2.5 KiB
JavaScript
2 lines
2.5 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",valid=()=>({valid:c("fc_web_robot_source_inventory_validate","number",["string"],[entry]),types:c("fc_web_robot_registered_type_count"),bindings:c("fc_web_robot_python_binding_count"),released:c("fc_web_robot_inventory_resources_released")}),before=valid(),bad=()=>({valid:c("fc_web_robot_source_inventory_validate","number",["string"],["src/Mod/Robot/App/Bad.cpp"]),error:c("fc_web_robot_inventory_error","string")}),rejected=bad(),repeated=bad(),after=valid(),hash=v=>crypto.createHash("sha256").update(JSON.stringify(v)).digest("hex"),sem=v=>({types:v.types,bindings:v.bindings,released:v.released}),report={schema:"freecad-web-p6-robot-action-02-recovery/v1",taskId:"FW-P6-ROB-ACT-02-D",module:"Robot",action:"inspect/source-inventory",result:before.valid===1&&rejected.valid===0&&repeated.valid===0&&rejected.error==="revision_mismatch"&&repeated.error===rejected.error&&after.valid===1&&hash(sem(before))===hash(sem(after))?"pass":"fail",before,rejected,repeated,after,recovery:{beforeSha256:hash(sem(before)),afterSha256:hash(sem(after)),unchangedAfterReject:hash(sem(before))===hash(sem(after)),repeatedErrorStable:rejected.error===repeated.error},artifacts:{kernel:"docs/p6/robot-action-02-kernel.json",workerLog:"docs/freecad-p6-robot-action-02-d-recovery.log"}};fs.writeFileSync(path.join(docs,"robot-action-02-recovery.json"),JSON.stringify(report,null,2)+"\n");fs.writeFileSync(path.join(root,"docs/freecad-p6-robot-action-02-d-recovery.log"),JSON.stringify({result:report.result,invalidError:rejected.error,unchangedAfterReject:report.recovery.unchangedAfterReject})+"\n");console.log(JSON.stringify({result:report.result,invalidError:rejected.error,unchangedAfterReject:report.recovery.unchangedAfterReject}));if(report.result!=="pass")process.exitCode=1;
|