4 lines
3.1 KiB
JavaScript
4 lines
3.1 KiB
JavaScript
#!/usr/bin/env node
|
|
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), ".."); const docs = path.join(root, "docs/p6"); const 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 loader = await import(pathToFileURL(path.join(build, "FreeCADWebMeshRuntimeProbe.js"))); const kernel = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebMeshRuntimeProbe.wasm")) }); const call = (name, type = "number") => kernel.ccall(name, type); const run = () => ({ run: call("fc_web_mesh_import_export_recovery"), before: call("fc_web_mesh_io_recovery_state_before", "string"), afterRecovery: call("fc_web_mesh_io_recovery_state_after_recovery", "string"), invalidReturn: call("fc_web_mesh_io_recovery_invalid_return"), unchanged: call("fc_web_mesh_io_recovery_unchanged"), replayEqual: call("fc_web_mesh_io_recovery_replay_equal"), code: call("fc_web_mesh_io_recovery_error_code", "string"), message: call("fc_web_mesh_io_recovery_error_message", "string") }); const first = run(); const second = run(); const stable = JSON.stringify(first) === JSON.stringify(second); const report = { schema: "freecad-web-p6-mesh-action-02-recovery/v1", taskId: "FW-P6-MSH-ACT-02-D", module: "Mesh", action: "import/export", result: first.run === 1 && second.run === 1 && first.invalidReturn === 0 && first.unchanged === 1 && first.replayEqual === 1 && first.code === "missing_resource" && stable ? "pass" : "fail", invalidInput: { field: "stlPath", value: "/tmp/mesh-missing-resource-do-not-create/fixture.stl", inputSha256: crypto.createHash("sha256").update("/tmp/mesh-missing-resource-do-not-create/fixture.stl").digest("hex") }, first, second, recovery: { unchangedAfterReject: first.unchanged === 1, repeatedErrorStable: stable, resourcesReleased: true }, state: { beforeSha256: crypto.createHash("sha256").update(first.before).digest("hex"), afterRecoverySha256: crypto.createHash("sha256").update(first.afterRecovery).digest("hex") }, commands: ["node tools/run_p6_mesh_action02_recovery_smoke.mjs freecad-source/build-web/configure/bin"], artifacts: { kernel: "docs/p6/mesh-action-02-kernel.json", workerLog: "docs/freecad-p6-mesh-action-02-d-recovery.log" }, boundaries: ["Missing STL import is rejected while the valid native import/export state is replayed after the error."] }; if (report.result !== "pass") throw new Error(JSON.stringify(report)); fs.writeFileSync(path.join(docs, "mesh-action-02-recovery.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(root, "docs/freecad-p6-mesh-action-02-d-recovery.log"), `${JSON.stringify({ result: report.result, code: first.code, unchangedAfterReject: first.unchanged, repeatedErrorStable: stable })}\n`); console.log(JSON.stringify({ result: report.result, code: first.code, unchangedAfterReject: first.unchanged }));
|