Files
FreeCADWasmDev/tools/run_p6_robot_python_recovery.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
1.9 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),before=c("fc_web_robot_python_api"),invalid={run:c("fc_web_robot_type_probe","number",["string"],["Robot::MissingPythonType"]),error:c("fc_web_robot_error","string")},repeated={run:c("fc_web_robot_type_probe","number",["string"],["Robot::MissingPythonType"]),error:c("fc_web_robot_error","string")},after=c("fc_web_robot_python_api"),report={schema:"freecad-web-p6-robot-python-recovery/v1",taskId:"FW-P6-ROB-ACT-03-D",module:"Robot",action:"python-api",result:before===1&&invalid.run===0&&repeated.run===0&&invalid.error==="type_not_found"&&repeated.error===invalid.error&&after===1?"pass":"fail",before,invalid,repeated,after,recovery:{unchangedAfterInvalid:before===after,repeatedErrorStable:invalid.error===repeated.error},artifacts:{kernel:"docs/p6/robot-action-03-kernel.json",workerLog:"docs/freecad-p6-robot-action-03-d-recovery.log"}};fs.writeFileSync(path.join(docs,"robot-action-03-recovery.json"),JSON.stringify(report,null,2)+"\n");fs.writeFileSync(path.join(root,"docs/freecad-p6-robot-action-03-d-recovery.log"),JSON.stringify({result:report.result,invalidError:invalid.error})+"\n");console.log(JSON.stringify({result:report.result,invalidError:invalid.error}));if(report.result!=="pass")process.exitCode=1;