3 lines
3.3 KiB
JavaScript
3 lines
3.3 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),run=()=>({run:call("fc_web_points_save_reopen"),error:call("fc_web_points_persistence_error","string"),path:call("fc_web_points_persistence_path","string"),objectType:call("fc_web_points_persistence_type","string"),pointCount: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")}),first=run(),second=run(),stable=v=>({run:v.run,error:v.error,path:v.path,objectType:v.objectType,pointCount:v.pointCount,beforeMinX:v.beforeMinX,afterMinX:v.afterMinX}),result={first,second,deterministic:JSON.stringify(stable(first))===JSON.stringify(stable(second)),roundTrip:first.run===1&&first.error===""&&first.path==="/tmp/PointsWeb.FCStd"&&first.objectType==="Points::Feature"&&first.pointCount===3&&first.size>0&&first.beforeMinX===first.afterMinX&&first.afterMinX===-1};if(!result.roundTrip||!result.deterministic)throw new Error(JSON.stringify(result));const fixture={module:"Points",action:"save/reopen",path:"/tmp/PointsWeb.FCStd",objectType:"Points::Feature",points:[[0,0,0],[1,2,3],[-1,4,2]]},wasmPath=path.join(build,"FreeCADWebPointsRuntimeProbe.wasm"),report={schema:"freecad-web-points-action-04-kernel/v1",task_id:"FW-P6-PTS-ACT-04-C",module:"Points",action:"save/reopen",status:"pass",source_revision:runtime.source_revision,input_sha256:crypto.createHash("sha256").update(JSON.stringify(fixture)).digest("hex"),result,result_sha256:crypto.createHash("sha256").update(JSON.stringify(result)).digest("hex"),commands:["node tools/run_p6_points_action04_kernel.mjs freecad-source/build-web/configure/bin"],artifacts:{runtime:"docs/p6/points-runtime.json",wasm:{path:"freecad-source/build-web/configure/bin/FreeCADWebPointsRuntimeProbe.wasm",sha256:crypto.createHash("sha256").update(fs.readFileSync(wasmPath)).digest("hex")}},boundaries:["Native Points owns FCStd save/reopen and closes documents; semantic state is compared across deterministic replays.","Only the three-point Points::Feature fixture is covered."]};fs.writeFileSync(path.join(docs,"points-action-04-kernel.json"),`${JSON.stringify(report,null,2)}\n`);fs.writeFileSync(path.join(root,"docs/freecad-p6-points-action-04-c-kernel.log"),`${JSON.stringify({status:report.status,roundTrip:result.roundTrip,deterministic:result.deterministic,resultSha256:report.result_sha256})}\n`);console.log(JSON.stringify({status:report.status,roundTrip:result.roundTrip,deterministic:result.deterministic,resultSha256:report.result_sha256}));
|