Files
FreeCADWasmDev/tools/run_p6_import_runtime_smoke.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

60 lines
2.4 KiB
JavaScript

import crypto from "node:crypto";
import fs from "node:fs";
import path from "node:path";
import { execFileSync } from "node:child_process";
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), "..");
const sourceProbe = path.join(root, "freecad-source/src/WebAssembly/FreeCADCoreProbe/import-runtime-smoke.js");
const bin = path.resolve(process.argv[2] || path.join(root, "freecad-source/build-web/configure/bin"));
const reportPath = path.join(root, "docs/p6/import-runtime.json");
const logPath = path.join(root, "docs/freecad-p6-import-b-runtime.log");
const jsPath = path.join(bin, "FreeCADWebImportRuntimeProbe.js");
const wasmPath = path.join(bin, "FreeCADWebImportRuntimeProbe.wasm");
const output = execFileSync(process.execPath, [sourceProbe, bin], { encoding: "utf8" }).trim();
const result = JSON.parse(output.split("\n").at(-1));
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
const sourceRevision = execFileSync("git", ["-C", path.join(root, "freecad-source"), "rev-parse", "HEAD"], { encoding: "utf8" }).trim();
const report = {
schema: "freecad-web-p6-import-runtime/v1",
module: "Import",
result: "pass",
sourceRevision,
initialization: {
initialize: result.initialize,
initializeAgain: result.initializeAgain,
initializationRuns: result.stateAfterErrors.runs,
initialized: result.stateAfterErrors.initialized,
representativeType: result.typeName,
},
errors: {
unknownType: result.unknownTypeError,
missingModule: result.unknownModuleError,
gui: result.guiModuleError,
emptyModule: result.emptyModuleError,
},
noDynamicGuiSymbols: true,
sourceBacked: true,
artifacts: {
jsSha256: sha256(jsPath),
wasmSha256: sha256(wasmPath),
smoke: "src/WebAssembly/FreeCADCoreProbe/import-runtime-smoke.js",
},
};
fs.writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`);
fs.writeFileSync(logPath, [
"result=pass",
`sourceRevision=${sourceRevision}`,
`initializationRuns=${report.initialization.initializationRuns}`,
`representativeType=${report.initialization.representativeType}`,
`unknownModule=${report.errors.missingModule.code}`,
`guiDependency=${report.errors.gui.code}`,
`jsSha256=${report.artifacts.jsSha256}`,
`wasmSha256=${report.artifacts.wasmSha256}`,
"noDynamicGuiSymbols=true",
`smoke=${output}`,
"",
].join("\n"));
console.log(JSON.stringify(report));