Add FreeCAD WebAssembly runtime probes
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
Push Crowdin Translations / update-crowdin (push) Has been cancelled
Fetch Crowdin Translations / update-crowdin (push) Has been cancelled
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
Push Crowdin Translations / update-crowdin (push) Has been cancelled
Fetch Crowdin Translations / update-crowdin (push) Has been cancelled
This commit is contained in:
107
src/WebAssembly/FreeCADCoreProbe/partdesign-runtime-smoke.js
Normal file
107
src/WebAssembly/FreeCADCoreProbe/partdesign-runtime-smoke.js
Normal file
@@ -0,0 +1,107 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const { pathToFileURL } = require("url");
|
||||
|
||||
const build = path.resolve(process.argv[2] || "build-web/configure/bin");
|
||||
|
||||
async function main() {
|
||||
globalThis.__dirname = `${build}${path.sep}`;
|
||||
globalThis.require = require;
|
||||
const loader = await import(pathToFileURL(path.join(build, "FreeCADWebPartDesignRuntimeProbe.js")));
|
||||
const probe = await loader.default({ wasmBinary: fs.readFileSync(path.join(build, "FreeCADWebPartDesignRuntimeProbe.wasm")) });
|
||||
const call = (name, type = "number", argTypes = [], values = []) => probe.ccall(name, type, argTypes, values);
|
||||
const valid = call("fc_web_partdesign_initialize", "number", ["string"], ["PartDesign"]);
|
||||
const repeat = call("fc_web_partdesign_initialize", "number", ["string"], ["PartDesign"]);
|
||||
const type = call("fc_web_partdesign_type_probe", "number", ["string"], ["PartDesign::AdditiveBox"]);
|
||||
const typeName = call("fc_web_partdesign_last_type", "string");
|
||||
const unknownType = call("fc_web_partdesign_type_probe", "number", ["string"], ["PartDesign::MissingFeature"]);
|
||||
const unknownTypeError = call("fc_web_partdesign_error_code", "string");
|
||||
const gui = call("fc_web_partdesign_initialize", "number", ["string"], ["PartDesignGui"]);
|
||||
const guiError = call("fc_web_partdesign_error_code", "string");
|
||||
const unknownModule = call("fc_web_partdesign_initialize", "number", ["string"], ["UnknownWorkbench"]);
|
||||
const unknownModuleError = call("fc_web_partdesign_error_code", "string");
|
||||
const empty = call("fc_web_partdesign_initialize", "number", ["string"], [""]);
|
||||
const emptyError = call("fc_web_partdesign_error_code", "string");
|
||||
const recovered = call("fc_web_partdesign_type_probe", "number", ["string"], ["PartDesign::Body"]);
|
||||
const action = process.env.PARTDESIGN_RUNTIME_ONLY
|
||||
? { skipped: true }
|
||||
: (() => {
|
||||
const actionRun = call("fc_web_partdesign_create_recompute");
|
||||
return {
|
||||
run: actionRun,
|
||||
error: call("fc_web_partdesign_action_error", "string"),
|
||||
volume: call("fc_web_partdesign_action_volume"),
|
||||
recomputeCount: call("fc_web_partdesign_action_recompute_count"),
|
||||
objectCount: call("fc_web_partdesign_action_object_count"),
|
||||
documentsAfter: call("fc_web_partdesign_action_documents_after"),
|
||||
};
|
||||
})();
|
||||
const recoveryRun = process.env.PARTDESIGN_RUNTIME_ONLY ? 1 : call("fc_web_partdesign_recovery");
|
||||
const recovery = process.env.PARTDESIGN_RUNTIME_ONLY ? { skipped: true } : {
|
||||
run: recoveryRun,
|
||||
error: call("fc_web_partdesign_recovery_error", "string"),
|
||||
beforeVolume: call("fc_web_partdesign_recovery_before_volume"),
|
||||
invalidVolume: call("fc_web_partdesign_recovery_invalid_volume"),
|
||||
afterVolume: call("fc_web_partdesign_recovery_after_volume"),
|
||||
invalidReturn: call("fc_web_partdesign_recovery_invalid_return"),
|
||||
afterReturn: call("fc_web_partdesign_recovery_after_return"),
|
||||
};
|
||||
const result = {
|
||||
valid,
|
||||
repeat,
|
||||
type,
|
||||
typeName,
|
||||
unknownType,
|
||||
unknownTypeError,
|
||||
gui,
|
||||
guiError,
|
||||
unknownModule,
|
||||
unknownModuleError,
|
||||
empty,
|
||||
emptyError,
|
||||
recovered,
|
||||
recoveredTypeName: call("fc_web_partdesign_last_type", "string"),
|
||||
action,
|
||||
recovery,
|
||||
initializationCalls: call("fc_web_partdesign_initialization_calls"),
|
||||
initializationRuns: call("fc_web_partdesign_initialization_runs"),
|
||||
registeredTypes: call("fc_web_partdesign_registered_types"),
|
||||
};
|
||||
const inspectRun = call("fc_web_partdesign_source_inventory_validate", "number", ["string"], ["src/Mod/PartDesign/App/AppPartDesign.cpp"]);
|
||||
const inspectFirst = {
|
||||
run: inspectRun,
|
||||
sourceEntry: call("fc_web_partdesign_inspect_source_entry", "string"),
|
||||
summary: call("fc_web_partdesign_inspect_summary", "string"),
|
||||
sourceFiles: call("fc_web_partdesign_inspect_source_files", "string"),
|
||||
registeredTypes: call("fc_web_partdesign_inspect_registered_types"),
|
||||
formatCount: call("fc_web_partdesign_inspect_format_count"),
|
||||
pythonBindings: call("fc_web_partdesign_inspect_python_bindings"),
|
||||
resourcesReleased: call("fc_web_partdesign_inspect_resources_released"),
|
||||
};
|
||||
const inspectSecond = {
|
||||
run: call("fc_web_partdesign_source_inventory_validate", "number", ["string"], ["src/Mod/PartDesign/App/AppPartDesign.cpp"]),
|
||||
sourceEntry: call("fc_web_partdesign_inspect_source_entry", "string"),
|
||||
summary: call("fc_web_partdesign_inspect_summary", "string"),
|
||||
sourceFiles: call("fc_web_partdesign_inspect_source_files", "string"),
|
||||
registeredTypes: call("fc_web_partdesign_inspect_registered_types"),
|
||||
formatCount: call("fc_web_partdesign_inspect_format_count"),
|
||||
pythonBindings: call("fc_web_partdesign_inspect_python_bindings"),
|
||||
resourcesReleased: call("fc_web_partdesign_inspect_resources_released"),
|
||||
};
|
||||
const inspectInvalid = call("fc_web_partdesign_source_inventory_validate", "number", ["string"], ["src/Mod/PartDesign/App/Missing.cpp"]);
|
||||
const inspectInvalidError = call("fc_web_partdesign_error_code", "string");
|
||||
const inspectEmpty = call("fc_web_partdesign_source_inventory_validate", "number", ["string"], [""]);
|
||||
const inspectEmptyError = call("fc_web_partdesign_error_code", "string");
|
||||
result.inspect = { first: inspectFirst, second: inspectSecond, invalid: inspectInvalid, invalidError: inspectInvalidError, empty: inspectEmpty, emptyError: inspectEmptyError };
|
||||
const actionPass = result.action.skipped === true || (result.action.run === 1 && result.action.error === "" && Math.abs(result.action.volume - 24) <= 1e-9 && result.action.recomputeCount > 0 && result.action.objectCount === 2 && result.action.documentsAfter === 0);
|
||||
const recoveryPass = result.recovery.skipped === true || (result.recovery.run === 1 && result.recovery.invalidReturn === 0 && result.recovery.afterReturn === 1 && result.recovery.error.includes("Length of box too small") && Math.abs(result.recovery.beforeVolume - result.recovery.invalidVolume) <= 1e-9 && Math.abs(result.recovery.afterVolume - 24) <= 1e-9);
|
||||
if (result.valid !== 1 || result.repeat !== 1 || result.type !== 1 || result.typeName !== "PartDesign::AdditiveBox" || result.unknownType !== 0 || result.unknownTypeError !== "type_not_found" || result.gui !== 0 || result.guiError !== "gui_dependency_unavailable" || result.unknownModule !== 0 || result.unknownModuleError !== "module_unavailable" || result.empty !== 0 || result.emptyError !== "invalid_argument" || result.recovered !== 1 || result.recoveredTypeName !== "PartDesign::Body" || result.initializationRuns !== 1 || result.registeredTypes !== 9 || !actionPass || !recoveryPass || inspectFirst.run !== 1 || JSON.stringify(inspectFirst) !== JSON.stringify(inspectSecond) || inspectFirst.registeredTypes !== 8 || inspectFirst.formatCount !== 0 || inspectFirst.pythonBindings !== 2 || inspectFirst.resourcesReleased !== 1 || inspectInvalid !== 0 || inspectInvalidError !== "revision_mismatch" || inspectEmpty !== 0 || inspectEmptyError !== "invalid_argument") {
|
||||
throw new Error(JSON.stringify(result));
|
||||
}
|
||||
console.log(JSON.stringify(result));
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user