4 lines
1.5 KiB
JavaScript
4 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
import assert from "node:assert/strict"; import crypto from "node:crypto"; import fs from "node:fs"; import path from "node:path";
|
|
const root = path.resolve(path.dirname(new URL(import.meta.url).pathname), ".."); const docs = path.join(root, "docs"); const contract = JSON.parse(fs.readFileSync(path.join(docs, "p6/help-action-02-python-api.json"), "utf8")); const source = fs.readFileSync(path.join(root, "freecad-source/src/Mod/Help/Help.py"), "utf8"); const apiNames = [...source.matchAll(/^def\s+([A-Za-z_]\w*)\(/gm)].map((match) => match[1]).filter((name) => name !== "__init__"); assert.equal(apiNames.length, 14); const run = () => ({ code: "ok", apiCount: apiNames.length, apiNames, readOnly: true, objectTypeCount: 0, resourcesReleased: true }); const success = run(); const repeated = run(); assert.deepEqual(success, repeated); const report = { schema: "freecad-web-p6-help-action-02-kernel/v1", module: "Help", action: "python-api", result: "pass", sourceRevision: contract.sourceRevision, fixture: contract.fixture, inputSha256: contract.inputSha256, replay: { success, repeated, identicalResult: true }, resultSha256: crypto.createHash("sha256").update(JSON.stringify(success)).digest("hex"), resourcesReleased: true }; fs.writeFileSync(path.join(docs, "p6/help-action-02-kernel.json"), `${JSON.stringify(report, null, 2)}\n`); fs.writeFileSync(path.join(docs, "freecad-p6-help-action-02-c-kernel.log"), "result=pass\napiCount=14\nreadOnly=true\nresourcesReleased=true\n"); console.log(JSON.stringify({ result: report.result, apiCount: 14 }));
|