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 { 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, "FreeCADWebShowRuntimeProbe.js"))); const probe = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebShowRuntimeProbe.wasm")), print: () => {}, printErr: () => {} }); const c = (name, type = "number", argTypes = [], args = []) => probe.ccall(name, type, argTypes, args); const entry = "src/Mod/Show/__init__.py"; const run = () => ({ valid: c("fc_web_show_source_inventory_validate", "number", ["string"], [entry]), apiValid: c("fc_web_show_python_api_validate", "number", ["string"], [entry]), apiCount: c("fc_web_show_python_api_count"), sourceEntry: c("fc_web_show_source_entry", "string"), moduleAvailable: c("fc_web_show_module_available"), resourcesReleased: c("fc_web_show_resources_released"), error: c("fc_web_show_last_error", "string") }); const first = run(); const second = run(); const semantic = value => ({ valid: value.valid, apiValid: value.apiValid, apiCount: value.apiCount, sourceEntry: value.sourceEntry, moduleAvailable: value.moduleAvailable, resourcesReleased: value.resourcesReleased, error: value.error }); const fixture = { module: "Show", action: "inspect/source-inventory", sourceEntry: entry, api: ["TempoVis", "DepGraphTools"] }; const details = { first, second, deterministic: JSON.stringify(semantic(first)) === JSON.stringify(semantic(second)), pass: first.valid === 1 && first.apiValid === 1 && first.apiCount === 2 && first.sourceEntry === entry && first.moduleAvailable === 1 && first.resourcesReleased === 1 && first.error === "" }; const report = { schema: "freecad-web-p6-show-kernel/v1", taskId: "FW-P6-SHW-C", module: "Show", action: "inspect/source-inventory", result: details.pass && details.deterministic ? "pass" : "fail", fixture: { ...fixture, inputSha256: crypto.createHash("sha256").update(JSON.stringify(fixture)).digest("hex") }, details, resultSha256: crypto.createHash("sha256").update(JSON.stringify(details)).digest("hex"), artifacts: { wasm: "freecad-source/build-web/configure/bin/FreeCADWebShowRuntimeProbe.wasm", workerLog: "docs/freecad-p6-show-c-kernel.log" }, boundaries: ["Native probe imports the official Show Python package from embedded source and reports source/API visibility; GUI-only SceneDetails remain excluded."] }; fs.writeFileSync(path.join(docs, "show-kernel.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(root, "docs/freecad-p6-show-c-kernel.log"), `${JSON.stringify({ result: report.result, deterministic: details.deterministic, sourceEntry: first.sourceEntry, apiCount: first.apiCount, resourcesReleased: first.resourcesReleased })}\n`); console.log(JSON.stringify({ result: report.result, deterministic: details.deterministic, sourceEntry: first.sourceEntry, apiCount: first.apiCount })); if (report.result !== "pass") process.exitCode = 1;
|