3 lines
3.4 KiB
JavaScript
3 lines
3.4 KiB
JavaScript
import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path"; import { createRequire } from "node:module"; import { fileURLToPath, pathToFileURL } from "node:url";
|
|
const root=path.resolve(path.dirname(fileURLToPath(import.meta.url)),".."),build=path.resolve(process.argv[2]??path.join(root,"freecad-source/build-web/configure/bin")),docs=path.join(root,"docs/p6"),runtime=JSON.parse(fs.readFileSync(path.join(docs,"points-runtime.json"),"utf8"));globalThis.__dirname=`${build}${path.sep}`;globalThis.require=createRequire(import.meta.url);const loader=await import(pathToFileURL(path.join(build,"FreeCADWebPointsRuntimeProbe.js"))),probe=await loader.default({wasmBinary:fs.readFileSync(path.join(build,"FreeCADWebPointsRuntimeProbe.wasm"))}),call=(n,t="number")=>probe.ccall(n,t),save=()=>({run:call("fc_web_points_save_reopen"),error:call("fc_web_points_persistence_error","string"),path:call("fc_web_points_persistence_path","string"),type:call("fc_web_points_persistence_type","string"),count:call("fc_web_points_persistence_count"),size:call("fc_web_points_persistence_size"),beforeMinX:call("fc_web_points_persistence_before_min_x"),afterMinX:call("fc_web_points_persistence_after_min_x")}),before=save(),invalid=call("fc_web_points_recovery"),invalidResult={error:call("fc_web_points_recovery_error","string"),validBefore:call("fc_web_points_recovery_valid_before"),validInvalid:call("fc_web_points_recovery_valid_invalid"),validAfter:call("fc_web_points_recovery_valid_after"),beforeMinX:call("fc_web_points_recovery_before_min_x"),afterMinX:call("fc_web_points_recovery_after_min_x")},replayInvalid=call("fc_web_points_recovery"),replayError=call("fc_web_points_recovery_error","string"),after=save(),result={before,invalid,invalidResult,replayInvalid,replayError,after,stateUnchanged:before.run===1&&after.run===1&&before.type===after.type&&before.count===after.count&&before.beforeMinX===after.afterMinX&&invalidResult.beforeMinX===invalidResult.afterMinX&&invalidResult.validBefore===3&&invalidResult.validInvalid===2&&invalidResult.validAfter===3,repeatedErrorEqual:invalidResult.error===replayError};if(!result.stateUnchanged||!result.repeatedErrorEqual)throw new Error(JSON.stringify(result));const input={validAction:"save/reopen",invalidField:"Points[1].x=NaN",recoveryAction:"fc_web_points_recovery"},report={schema:"freecad-web-points-action-04-recovery/v1",task_id:"FW-P6-PTS-ACT-04-D",module:"Points",action:"save/reopen",status:"pass",source_revision:runtime.source_revision,input_sha256:crypto.createHash("sha256").update(JSON.stringify(input)).digest("hex"),result,result_sha256:crypto.createHash("sha256").update(JSON.stringify(result)).digest("hex"),commands:["node tools/run_p6_points_action04_recovery.mjs freecad-source/build-web/configure/bin"],artifacts:{kernel:"docs/p6/points-action-04-kernel.json",runtime:"docs/p6/points-runtime.json"},boundaries:["NaN point input is rejected by the native Points recovery path; the valid persisted snapshot remains unchanged and save/reopen succeeds again."]};fs.writeFileSync(path.join(docs,"points-action-04-recovery.json"),`${JSON.stringify(report,null,2)}\n`);fs.writeFileSync(path.join(root,"docs/freecad-p6-points-action-04-d-recovery.log"),`${JSON.stringify({status:report.status,stateUnchanged:result.stateUnchanged,repeatedErrorEqual:result.repeatedErrorEqual,resultSha256:report.result_sha256})}\n`);console.log(JSON.stringify({status:report.status,stateUnchanged:result.stateUnchanged,resultSha256:report.result_sha256}));
|