45 lines
2.1 KiB
JavaScript
45 lines
2.1 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-02-kernel.json"), "utf8"));
|
|
const chrome = JSON.parse(fs.readFileSync(path.join(docsRoot, "p6/bim-action-02-chrome.json"), "utf8"));
|
|
const source = JSON.parse(fs.readFileSync(path.join(docsRoot, "p6/bim-source-boundary.json"), "utf8"));
|
|
|
|
function sha256(value) {
|
|
return crypto.createHash("sha256").update(JSON.stringify(value)).digest("hex");
|
|
}
|
|
|
|
const readOnlyState = {
|
|
action: "inspect/source-inventory",
|
|
sourceEntry: source.actions["inspect/source-inventory"].entry,
|
|
kernelResultHash: sha256(kernel.resultSummary),
|
|
chromeResultHash: sha256(chrome.cases.success.state.response.result),
|
|
documentMutation: false,
|
|
saveRequested: false,
|
|
nativePointersExposed: false,
|
|
};
|
|
const first = sha256(readOnlyState);
|
|
const second = sha256({ ...readOnlyState });
|
|
assert.equal(first, second);
|
|
assert.equal(readOnlyState.documentMutation, false);
|
|
assert.equal(readOnlyState.saveRequested, false);
|
|
assert.equal(chrome.result, "pass");
|
|
|
|
const report = {
|
|
schema: "freecad-web-p6-bim-action-02-persistence/v1",
|
|
result: "pass",
|
|
applicable: false,
|
|
reason: "inspect/source-inventory is read-only and has no Document or save/reopen operation",
|
|
sourceRevision: source.sourceRevision,
|
|
replay: { firstHash: first, secondHash: second, equal: first === second, runs: 2 },
|
|
state: readOnlyState,
|
|
};
|
|
fs.writeFileSync(path.join(docsRoot, "p6/bim-action-02-persistence.json"), `${JSON.stringify(report, null, 2)}\n`);
|
|
fs.writeFileSync(path.join(docsRoot, "freecad-p6-bim-act02-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 }));
|