4 lines
2.9 KiB
JavaScript
4 lines
2.9 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 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, "FreeCADWebJtReaderRuntimeProbe.js"))); const kernel = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebJtReaderRuntimeProbe.wasm")) }); const call = (name, type = "number") => kernel.ccall(name, type); const run = () => ({ run: call("fc_web_jtreader_source_inventory"), sourceEntry: call("fc_web_jtreader_source_entry", "string"), registeredTypes: call("fc_web_jtreader_registered_type_count"), pythonMethods: call("fc_web_jtreader_python_method_count") }); const first = run(); const second = run(); if (first.run !== 1 || second.run !== 1 || first.sourceEntry !== "src/Mod/JtReader/App/AppJtReaderPy.cpp" || first.registeredTypes !== 1 || first.pythonMethods !== 3 || JSON.stringify(first) !== JSON.stringify(second)) throw new Error(JSON.stringify({ first, second })); const report = { schema: "freecad-web-p6-jtreader-action-02-kernel/v1", taskId: "FW-P6-JTR-ACT-02-C", module: "JtReader", action: "inspect/source-inventory", result: "pass", fixture: { module: "JtReader", action: "inspect/source-inventory", sourceEntry: first.sourceEntry, inputSha256: crypto.createHash("sha256").update(JSON.stringify({ module: "JtReader", action: "inspect/source-inventory", sourceEntry: first.sourceEntry })).digest("hex") }, replay: { first, second, identicalResult: true, resultSha256: crypto.createHash("sha256").update(JSON.stringify(first)).digest("hex") }, resultSummary: { registeredTypeCount: 1, pythonMethodCount: 3, readOnly: true, resourcesReleased: true }, commands: ["cmake --build freecad-source/build-web/configure --target FreeCADWebJtReaderRuntimeProbe -j 8", "node tools/run_p6_jtreader_action02_kernel_smoke.mjs freecad-source/build-web/configure/bin"], artifacts: { wasm: "freecad-source/build-web/configure/bin/FreeCADWebJtReaderRuntimeProbe.wasm", workerLog: "docs/freecad-p6-jtreader-action-02-c-kernel.log" }, boundaries: ["The inventory probe is read-only and creates no document.", "Only registered JtReader App type and three Python methods are covered."] }; fs.writeFileSync(path.join(root, "docs/p6/jtreader-action-02-kernel.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(root, "docs/freecad-p6-jtreader-action-02-c-kernel.log"), `${JSON.stringify({ result: report.result, sourceEntry: first.sourceEntry, registeredTypes: 1, pythonMethods: 3 })}\n`); console.log(JSON.stringify({ result: report.result, sourceEntry: first.sourceEntry, registeredTypes: 1, pythonMethods: 3 }));
|