Files
FreeCADWasmDev/tools/run_p6_show_action02_kernel.mjs
wangdequan 9a7c4f0335 Save FreeCAD Web workspace sources and user validation evidence
IFC native binding remains incomplete; preserve accurate test results.
2026-09-15 22:01:58 +08:00

3 lines
3.1 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") => probe.ccall(name, type); const run = () => ({ run: c("fc_web_show_python_api"), apiCount: c("fc_web_show_python_api_count"), tempoState: c("fc_web_show_tempo_state"), resourcesReleased: c("fc_web_show_resources_released"), dependencyAvailable: c("fc_web_show_dependency_available"), error: c("fc_web_show_api_error", "string") }); const first = run(); const second = run(); const fixture = { module: "Show", action: "python-api", api: ["TempoVis", "DepGraphTools", "SceneDetail", "Container", "TVStack"], guiUp: false }; const semantic = value => ({ run: value.run, apiCount: value.apiCount, tempoState: value.tempoState, resourcesReleased: value.resourcesReleased, dependencyAvailable: value.dependencyAvailable, error: value.error }); const details = { first, second, deterministic: JSON.stringify(semantic(first)) === JSON.stringify(semantic(second)), pass: first.run === 1 && first.apiCount === 2 && first.tempoState === 0 && first.resourcesReleased === 1 && first.dependencyAvailable === 1 && first.error === "" }; const report = { schema: "freecad-web-p6-show-action-02-kernel/v1", taskId: "FW-P6-SHW-ACT-02-C", module: "Show", action: "python-api", 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-action-02-c-kernel.log" }, boundaries: ["Native probe executes the official Show Python package with FreeCAD.GuiUp=False and closes the temporary document; GUI-only SceneDetails are excluded."] }; fs.writeFileSync(path.join(docs, "show-action-02-kernel.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(root, "docs/freecad-p6-show-action-02-c-kernel.log"), `${JSON.stringify({ result: report.result, deterministic: details.deterministic, apiCount: first.apiCount, tempoState: first.tempoState, resourcesReleased: first.resourcesReleased })}\n`); console.log(JSON.stringify({ result: report.result, deterministic: details.deterministic, apiCount: first.apiCount, resourcesReleased: first.resourcesReleased })); if (report.result !== "pass") process.exitCode = 1;