55 lines
3.5 KiB
JavaScript
55 lines
3.5 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, "FreeCADWebMeasureKernelProbe.js")));
|
|
const kernel = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebMeasureKernelProbe.wasm")) });
|
|
const call = (name, type = "number") => kernel.ccall(name, type);
|
|
const run = () => ({
|
|
run: call("fc_web_measure_source_inventory"),
|
|
sourceEntry: call("fc_web_measure_inventory_source_entry", "string"),
|
|
registeredTypes: call("fc_web_measure_inventory_registered_types"),
|
|
pythonBindings: call("fc_web_measure_inventory_python_bindings"),
|
|
readOnly: call("fc_web_measure_inventory_read_only"),
|
|
resourcesReleased: call("fc_web_measure_inventory_resources_released"),
|
|
code: call("fc_web_measure_inventory_error_code", "string"),
|
|
message: call("fc_web_measure_inventory_error_message", "string"),
|
|
});
|
|
const first = run();
|
|
const second = run();
|
|
if (
|
|
first.run !== 1
|
|
|| second.run !== 1
|
|
|| first.sourceEntry !== "src/Mod/Measure/App/AppMeasure.cpp"
|
|
|| first.registeredTypes < 10
|
|
|| first.pythonBindings !== 2
|
|
|| first.readOnly !== 1
|
|
|| first.resourcesReleased !== 1
|
|
|| JSON.stringify(first) !== JSON.stringify(second)
|
|
) throw new Error(JSON.stringify({ first, second }));
|
|
const fixture = { module: "Measure", action: "inspect/source-inventory", sourceEntry: first.sourceEntry };
|
|
const report = {
|
|
schema: "freecad-web-p6-measure-action-02-kernel/v1",
|
|
taskId: "FW-P6-MEA-ACT-02-C",
|
|
module: "Measure",
|
|
action: "inspect/source-inventory",
|
|
result: "pass",
|
|
fixture: { ...fixture, inputSha256: crypto.createHash("sha256").update(JSON.stringify(fixture)).digest("hex") },
|
|
replay: { first, second, identicalResult: true, resultSha256: crypto.createHash("sha256").update(JSON.stringify(first)).digest("hex") },
|
|
resultSummary: { sourceEntry: first.sourceEntry, registeredTypeCount: first.registeredTypes, pythonBindingCount: first.pythonBindings, readOnly: true, resourcesReleased: true },
|
|
commands: ["EM_CACHE=/tmp/freecad-emscripten-cache cmake --build freecad-source/build-web/configure --target FreeCADWebMeasureKernelProbe -j 8", "node tools/run_p6_measure_action02_kernel_smoke.mjs freecad-source/build-web/configure/bin"],
|
|
artifacts: { wasm: "freecad-source/build-web/configure/bin/FreeCADWebMeasureKernelProbe.wasm", workerLog: "docs/freecad-p6-measure-action-02-c-kernel.log" },
|
|
boundaries: ["The inventory probe is read-only and creates no document.", "GUI registration and GUI-only measurement actions remain excluded."]
|
|
};
|
|
fs.writeFileSync(path.join(docs, "measure-action-02-kernel.json"), `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(path.join(root, "docs/freecad-p6-measure-action-02-c-kernel.log"), `${JSON.stringify({ result: report.result, sourceEntry: first.sourceEntry, registeredTypes: first.registeredTypes, pythonBindings: first.pythonBindings, resourcesReleased: true })}\n`);
|
|
console.log(JSON.stringify({ result: report.result, sourceEntry: first.sourceEntry, registeredTypes: first.registeredTypes, pythonBindings: first.pythonBindings }));
|