19 lines
1.9 KiB
JavaScript
19 lines
1.9 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 docsRoot = path.join(root, "docs");
|
|
const kernel = JSON.parse(fs.readFileSync(path.join(docsRoot, "p6/bim-action-03-kernel.json"), "utf8"));
|
|
const chrome = JSON.parse(fs.readFileSync(path.join(docsRoot, "p6/bim-action-03-chrome.json"), "utf8"));
|
|
const state = { action: "python-api", apiCount: kernel.replay.success.result.apiCount, sourceEntry: kernel.fixture.entry, chromeResultHash: crypto.createHash("sha256").update(JSON.stringify(chrome.cases.success.state.response.result)).digest("hex"), documentMutation: false, saveRequested: false, nativePointersExposed: false };
|
|
const firstHash = crypto.createHash("sha256").update(JSON.stringify(state)).digest("hex");
|
|
const secondHash = crypto.createHash("sha256").update(JSON.stringify({ ...state })).digest("hex");
|
|
assert.equal(firstHash, secondHash); assert.equal(state.documentMutation, false); assert.equal(state.saveRequested, false); assert.equal(chrome.result, "pass");
|
|
const report = { schema: "freecad-web-p6-bim-action-03-persistence/v1", result: "pass", applicable: false, reason: "python-api is a read-only source inventory and has no Document or save/reopen operation", sourceRevision: kernel.fixture.sourceRevision, replay: { firstHash, secondHash, equal: firstHash === secondHash, runs: 2 }, state };
|
|
fs.writeFileSync(path.join(docsRoot, "p6/bim-action-03-persistence.json"), `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(path.join(docsRoot, "freecad-p6-bim-act03-persistence.log"), `${JSON.stringify({ result: report.result, applicable: report.applicable, replayEqual: report.replay.equal, documentMutation: report.state.documentMutation })}\n`);
|
|
console.log(JSON.stringify({ result: report.result, applicable: report.applicable, replayEqual: report.replay.equal }));
|