25 lines
1.4 KiB
JavaScript
25 lines
1.4 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
function arg(name) {
|
|
const index = process.argv.indexOf(name);
|
|
return index >= 0 ? process.argv[index + 1] : undefined;
|
|
}
|
|
const baselinePath = arg("--baseline");
|
|
const sourceHashesPath = arg("--source-hashes");
|
|
if (!baselinePath || !sourceHashesPath) throw new Error("usage: node tools/web/check-corrective-baseline.mjs --baseline path --source-hashes path");
|
|
const baseline = JSON.parse(fs.readFileSync(path.resolve(root, baselinePath), "utf8"));
|
|
const expected = Object.fromEntries(fs.readFileSync(path.resolve(root, sourceHashesPath), "utf8").trim().split("\n").filter(Boolean).map((line) => {
|
|
const [sha256, relative] = line.trim().split(/\s+/, 2);
|
|
return [relative, sha256];
|
|
}));
|
|
assert.deepEqual(baseline.sourceHashes, expected, "baseline source hash map differs from source-hashes.txt");
|
|
assert.equal(baseline.invariants.queueMutationAllowed, false);
|
|
assert.equal(baseline.invariants.parentPointerMatchesCurrent, true);
|
|
assert.equal(baseline.invariants.exactlyOneCatalogActive, true);
|
|
assert.equal(baseline.invariants.catalogActiveMatchesPlan, true);
|
|
process.stdout.write(`corrective-baseline-check-ok task=${baseline.task} sources=${Object.keys(expected).length} queueMutation=false\n`);
|