chore: checkpoint web Blender migration source, tools and docs
Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer, web workflow engine and protocol, tooling, docs and task records. Large generated evidence, user-testing archives, build snapshots and imported test assets remain untracked. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const repoRoot = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "asset-catalog-compatibility-unit-"));
|
||||
@@ -28,10 +29,7 @@ const manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, "tests/golden/M1
|
||||
|
||||
test("M12-01E binds the compatibility policy and generated reports", () => {
|
||||
assert.equal(manifest.nextTask, "M12-01F");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
const actual = crypto.createHash("sha256").update(fs.readFileSync(path.join(repoRoot, artifact.path))).digest("hex");
|
||||
assert.equal(actual, artifact.sha256, `${artifact.path} hash drifted`);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-01E exposes schema v2 to a v1 reader as a bounded read-only snapshot", async () => {
|
||||
|
||||
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-01G/manifest.json"), "utf8"));
|
||||
@@ -16,7 +17,5 @@ test("M12-01G binds the production transaction, browser suite, and migration inp
|
||||
assert.equal(manifest.nextTask, "M12-01H");
|
||||
assert.deepEqual(manifest.transaction.faultPoints, ["AFTER_TARGET_PUT", "AFTER_SOURCE_DELETE"]);
|
||||
assert.equal(manifest.transaction.failureCode, "STORAGE_TRANSACTION");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const repoRoot = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "asset-catalog-migration-unit-"));
|
||||
@@ -29,10 +30,7 @@ const manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, "tests/golden/M1
|
||||
|
||||
test("M12-01D binds migration inputs, outputs, and production protocols", () => {
|
||||
assert.equal(manifest.nextTask, "M12-01E");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
const actual = crypto.createHash("sha256").update(fs.readFileSync(path.join(repoRoot, artifact.path))).digest("hex");
|
||||
assert.equal(actual, artifact.sha256, `${artifact.path} hash drifted`);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-01D migrates schema v1 to v2 without dropping source, preview, or library data", async () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const repoRoot = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "asset-catalog-negatives-unit-"));
|
||||
@@ -30,10 +31,7 @@ const manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, "tests/golden/M1
|
||||
test("M12-01F binds every negative input contract", () => {
|
||||
assert.equal(manifest.negativeCaseCount, golden.cases.length);
|
||||
assert.equal(manifest.nextTask, "M12-01G");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
const actual = crypto.createHash("sha256").update(fs.readFileSync(path.join(repoRoot, artifact.path))).digest("hex");
|
||||
assert.equal(actual, artifact.sha256, `${artifact.path} hash drifted`);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
async function codeFrom(run) {
|
||||
|
||||
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-01H/manifest.json"), "utf8"));
|
||||
@@ -17,7 +18,5 @@ test("M12-01H binds page and Worker restart identity evidence", () => {
|
||||
assert.equal(manifest.restart.catalogOrder.length, manifest.restart.catalogCount);
|
||||
assert.equal(manifest.restart.assetOrder.length, manifest.restart.assetCount);
|
||||
assert.match(manifest.restart.manifestSha256, /^[a-f0-9]{64}$/);
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const repoRoot = path.resolve(import.meta.dirname, "../../..");
|
||||
const sourcePath = path.join(repoRoot, "web/protocol/asset-catalog-v2.ts");
|
||||
@@ -24,10 +25,7 @@ const manifest = JSON.parse(fs.readFileSync(path.join(repoRoot, "tests/golden/M1
|
||||
|
||||
test("M12-01C binds the desktop and Blender weak-reference sources", () => {
|
||||
assert.equal(manifest.nextTask, "M12-01D");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
const actual = crypto.createHash("sha256").update(fs.readFileSync(path.join(repoRoot, artifact.path))).digest("hex");
|
||||
assert.equal(actual, artifact.sha256, `${artifact.path} hash drifted`);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
const weakReferenceSource = fs.readFileSync(path.join(repoRoot, manifest.artifacts.blenderWeakReferenceSource.path), "utf8");
|
||||
assert.match(weakReferenceSource, /AssetWeakReference AssetRepresentation::make_weak_reference\(\) const/);
|
||||
assert.match(weakReferenceSource, /library_relative_identifier\(\) const/);
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "asset-preview-decode-unit-"));
|
||||
@@ -50,9 +51,7 @@ test("M12-02C plans the checked-in PNG before decode", async () => {
|
||||
assert.equal(manifest.nextTask, "M12-02D");
|
||||
assert.equal(manifest.negativeCaseCount, 8);
|
||||
assert.deepEqual(decode.ASSET_PREVIEW_DECODE_BUDGET, manifest.budget);
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(fs.readFileSync(path.join(root, artifact.path))), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
assert.deepEqual(await decode.planAssetPreviewDecode(identity, buffer(content)), {
|
||||
schemaVersion: 1,
|
||||
identitySha256: identity.identitySha256,
|
||||
|
||||
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-02E/manifest.json"), "utf8"));
|
||||
@@ -19,7 +20,5 @@ test("M12-02E binds payload deduplication and metadata-isolation evidence", () =
|
||||
"DISTINCT_ASSET_METADATA_PRESERVED",
|
||||
"REOPENED_HEAD_VERIFIED",
|
||||
]);
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-02H/manifest.json"), "utf8"));
|
||||
@@ -17,5 +18,5 @@ test("M12-02H binds desktop, main-thread, Offscreen, and metric evidence", () =>
|
||||
assert.equal(manifest.nextTask, "M12-03A");
|
||||
assert.deepEqual(manifest.backends, ["BLENDER_5_2_DESKTOP", "MAIN_THREAD_CANVAS_2D", "OFFSCREEN_CANVAS_2D"]);
|
||||
assert.equal(desktop.rgbaSha256, manifest.reference.rgbaSha256);
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "asset-preview-identity-unit-"));
|
||||
@@ -34,9 +35,7 @@ test("M12-02B binds source, content, generator, protocol, and settings artifacts
|
||||
assert.equal(manifest.enablingTask, true);
|
||||
assert.equal(manifest.parityStateChange, false);
|
||||
assert.equal(manifest.nextTask, "M12-02C");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(fs.readFileSync(path.join(root, artifact.path))), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
assert.equal(sha256(stableJSON(manifest.generatorSettings)), manifest.generatorSettingsSha256);
|
||||
assert.equal(manifest.generatorSettingsSha256, golden.generator.settingsSha256);
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-02D/manifest.json"), "utf8"));
|
||||
@@ -15,7 +16,5 @@ test("M12-02D binds OPFS-before-catalog ordering and browser evidence", () => {
|
||||
assert.equal(manifest.nextTask, "M12-02E");
|
||||
assert.deepEqual(manifest.commitOrder, ["PRE_DECODE_GATE", "OPFS_WRITE", "OPFS_READBACK", "CATALOG_TRANSACTION"]);
|
||||
assert.deepEqual(manifest.faultPoints, ["BEFORE_OPFS_WRITE", "AFTER_OPFS_WRITE", "AFTER_CATALOG_PUT"]);
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-02F/manifest.json"), "utf8"));
|
||||
@@ -15,7 +16,5 @@ test("M12-02F binds corrupt-payload quarantine and readable metadata evidence",
|
||||
assert.equal(manifest.nextTask, "M12-02G");
|
||||
assert.deepEqual(manifest.states, ["READY", "QUARANTINED", "REOPENED_QUARANTINED"]);
|
||||
assert.equal(manifest.failureCode, "ASSET_SOURCE_HASH_MISMATCH");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/M12-02G/manifest.json"), "utf8"));
|
||||
@@ -15,7 +16,5 @@ test("M12-02G binds final-reference and cross-project reclamation evidence", ()
|
||||
assert.equal(manifest.nextTask, "M12-02H");
|
||||
assert.deepEqual(manifest.sequence, ["REMOVE_FIRST_REFERENCE", "RETAIN_PAYLOAD", "REMOVE_FINAL_REFERENCE", "COLLECT_PAYLOAD"]);
|
||||
assert.equal(manifest.otherProjectPayload, "PRESERVED_READY");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
55
web/tests/unit/coverage-baseline.test.mjs
Normal file
55
web/tests/unit/coverage-baseline.test.mjs
Normal file
@@ -0,0 +1,55 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { coverageBaseline, caseEvidence, canonicalPath } from '../../../tools/web/coverage-baseline.mjs';
|
||||
import { digest } from '../../../tools/web/workflow-case-lib.mjs';
|
||||
const sourceHash = digest('source'), proofHash = digest('proof');
|
||||
const treeHash = digest(`a.cc\0${sourceHash}\n`);
|
||||
test('equivalent absolute and relative input paths have one identity', () => {
|
||||
assert.equal(canonicalPath('/workspace', '/workspace/cases/result.json'), canonicalPath('/workspace', './cases/result.json'));
|
||||
assert.equal(canonicalPath('/workspace', 'cases/../cases/result.json'), 'cases/result.json');
|
||||
assert.throws(() => canonicalPath('/workspace', 123), /string/);
|
||||
});
|
||||
const receipt = () => ({ cases: [{ kind: 'minimal', status: 'PASS', inputs: [{ path: 'input', sha256: proofHash }], artifacts: [{ path: 'output', sha256: proofHash }], process: { code: 0, timedOut: false, cancelled: false }, result: { passed: true, tests: 2 } }], remainingGates: ['production'] });
|
||||
function fixture() {
|
||||
const catalog = { entries: [{ id: 'op:a' }], unitCount: 1 };
|
||||
const binding = { evidenceManifest: { path: 'manifest', sha256: proofHash }, productionEvidence: { path: 'production', sha256: proofHash }, sourceTreeSha256: treeHash };
|
||||
const inventory = { authority: { sourceTreeSha256: treeHash }, sourceFiles: [{ path: 'a', sourcePath: 'a.cc', sha256: sourceHash }], units: [{ id: 'op:a', coverageStatus: 'VERIFIED', coverage: binding }] };
|
||||
const historical = { references: [], driftedArtifacts: 183 };
|
||||
const observed = new Map([['a', sourceHash], ['manifest', proofHash], ['production', proofHash]]);
|
||||
return { catalog, inventory, historical, observed, run() { return coverageBaseline(this.catalog, this.inventory, this.historical, file => this.observed.get(file) ?? null); } };
|
||||
}
|
||||
test('matching receipts and source scope yield current coverage with stable identity', () => {
|
||||
const f = fixture(), first = f.run(); assert.equal(first.unitCount, 1); assert.equal(first.verifiedUnits, 1);
|
||||
assert.equal(first.history.oldDriftedArtifacts, 183); assert.equal(first.integrity.driftedArtifacts, 0);
|
||||
assert.deepEqual(f.run(), first);
|
||||
});
|
||||
test('changed and missing receipt files never inherit a historical pass', () => {
|
||||
const f = fixture(); f.observed.set('production', digest('changed')); assert.equal(f.run().verifiedUnits, 0); assert.equal(f.run().integrity.driftedArtifacts, 1);
|
||||
f.observed.delete('production'); assert.equal(f.run().verifiedUnits, 0); assert.equal(f.run().integrity.missingArtifacts, 1);
|
||||
});
|
||||
test('matching receipt bytes do not prove behavior on changed source', () => {
|
||||
const f = fixture(); f.observed.set('a', digest('new source')); const result = f.run();
|
||||
assert.equal(result.history.referenceValidUnits, 1); assert.equal(result.verifiedUnits, 0);
|
||||
assert.equal(result.source.changedFiles, 1); assert.ok(result.evidence[0].reasons.includes('SOURCE_VERSION_UNBOUND'));
|
||||
});
|
||||
test('all unmatched units remain in the shared denominator', () => {
|
||||
const f = fixture(); f.catalog.entries.push({ id: 'route-only' }); f.inventory.units.push({ id: 'inventory-only' });
|
||||
const result = f.run(); assert.equal(result.unitCount, 3); assert.equal(result.unverifiedUnits, 2); assert.deepEqual(result.reconciliation.catalogOnly, ['route-only']); assert.deepEqual(result.reconciliation.inventoryOnly, ['inventory-only']);
|
||||
});
|
||||
test('malformed IDs, duplicate IDs and inconsistent inventory identity fail closed', () => {
|
||||
const f = fixture(); f.catalog.entries.push({ id: 'op:a' }); assert.throws(() => f.run(), /duplicate/);
|
||||
f.catalog.entries.pop(); f.catalog.entries[0].id = 42; assert.throws(() => f.run(), /string/);
|
||||
f.catalog.entries[0].id = 'op:a'; f.inventory.authority.sourceTreeSha256 = digest('wrong inventory');
|
||||
const result = f.run(); assert.equal(result.verifiedUnits, 0); assert.ok(result.evidence[0].reasons.includes('INVENTORY_SNAPSHOT_INVALID'));
|
||||
});
|
||||
test('case facts require real numeric exit/test counts and preserve remaining gates', () => {
|
||||
const r = receipt(), valid = caseEvidence(r, () => proofHash); assert.equal(valid.cases[0].currentSelectedTests, 2); assert.equal(valid.acceptance, 'NOT_CLAIMED'); assert.deepEqual(valid.remainingGates, ['production']);
|
||||
r.cases[0].process.code = '0'; assert.equal(caseEvidence(r, () => proofHash).cases[0].currentSelectedTests, 0);
|
||||
r.cases[0].process.code = 0; r.cases[0].result.tests = '2'; assert.equal(caseEvidence(r, () => proofHash).cases[0].currentSelectedTests, 0);
|
||||
});
|
||||
test('case input changes, missing artifacts and unknown hash types invalidate reuse', () => {
|
||||
const r = receipt(); assert.equal(caseEvidence(r, file => file === 'input' ? digest('changed') : proofHash).cases[0].eligible, false);
|
||||
assert.equal(caseEvidence(r, () => null).cases[0].eligible, false);
|
||||
assert.throws(() => caseEvidence(r, () => 123)); r.cases[0].artifacts = [];
|
||||
assert.equal(caseEvidence(r, () => proofHash).cases[0].eligible, false);
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
@@ -91,7 +92,8 @@ test("M6-04B installs the production manifest with explicit variant paths", () =
|
||||
const production = JSON.parse(fs.readFileSync(path.join(repoRoot, "web/app/public/engine-manifest.json"), "utf8"));
|
||||
const parsed = validateWebEngineManifestV2(production);
|
||||
assert.equal(parsed.releaseId, `blender-wasm-${packageJson.version}`);
|
||||
assert.equal(parsed.variants[0].resources.wasm.url, "/vendor/blender/single/web_engine.wasm");
|
||||
assert.equal(parsed.variants[0].resources.wasm.url, "/vendor/blender/web_engine.wasm");
|
||||
assert.equal(parsed.variants[1].resources.wasm.url, "/vendor/blender/pthread/web_engine.wasm");
|
||||
assert.notEqual(parsed.variants[0].resources.wasm.sha256, parsed.variants[1].resources.wasm.sha256);
|
||||
for (const variant of parsed.variants) for (const resource of Object.values(variant.resources)) assert.equal(crypto.createHash("sha256").update(fs.readFileSync(path.join(repoRoot, "web/app/public", resource.url))).digest("hex"), resource.sha256, `${variant.id}: ${resource.url}`);
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ test("execution control plane reports one queue pointer and capability throughpu
|
||||
], { cwd: root, encoding: "utf8" });
|
||||
const report = JSON.parse(output);
|
||||
assert.equal(report.status, "PASS");
|
||||
assert.equal(report.queue.currentTask, "WBV2-P0-002");
|
||||
assert.ok(report.queue.activeCatalogTask === null || report.queue.currentTask === report.queue.activeCatalogTask);
|
||||
assert.equal(report.queue.parentNextTask, report.queue.currentTask);
|
||||
assert.equal(report.efficiency.capabilityClusters, 3);
|
||||
assert.ok(report.efficiency.averageGapsPerCapability >= 1);
|
||||
|
||||
12
web/tests/unit/glb-corner-normals.test.mjs
Normal file
12
web/tests/unit/glb-corner-normals.test.mjs
Normal file
@@ -0,0 +1,12 @@
|
||||
import assert from 'node:assert/strict'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import {pathToFileURL} from 'node:url'; import test from 'node:test'; import ts from 'typescript';
|
||||
const root=path.resolve(import.meta.dirname,'../../..'),temporary=fs.mkdtempSync(path.join(os.tmpdir(),'glb-corner-normals-'));
|
||||
for(const name of ['glb-export','nonmesh-export','nonmesh-binary','mesh-cache']) { const source=path.join(root,`web/protocol/${name}.ts`),result=ts.transpileModule(fs.readFileSync(source,'utf8'),{compilerOptions:{module:ts.ModuleKind.ES2022,target:ts.ScriptTarget.ES2022},fileName:source,reportDiagnostics:true});assert.deepEqual(result.diagnostics,[]);fs.writeFileSync(path.join(temporary,name+'.mjs'),result.outputText.replace(/from "\.\/(.*?)"/g,'from "./$1.mjs"')); }
|
||||
const {exportGLB}=await import(pathToFileURL(path.join(temporary,'glb-export.mjs'))),{encodeLODGeometry,decodeLODGeometry}=await import(pathToFileURL(path.join(temporary,'mesh-cache.mjs')));
|
||||
test.after(()=>fs.rmSync(temporary,{recursive:true,force:true}));
|
||||
const identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];
|
||||
const geometry={schemaVersion:1,meshId:'mesh:test',byteLength:0,positions:new Float32Array([0,0,0,1,0,0,0,1,0,0,0,1]).buffer,indices:new Uint32Array([0,1,2,0,3,1]).buffer,normals:new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1]).buffer,triangleCornerIndices:new Uint32Array([0,1,2,3,4,5]).buffer,splitNormals:new Float32Array([0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,1,0]).buffer};
|
||||
const scene={sceneId:'scene:test',revision:1,frame:{current:1},nodes:[{id:'object:test',name:'Sharp',type:'MESH',parentId:null,dataId:'mesh:test',localMatrix:identity,worldMatrix:identity,visible:true,selectable:true}],meshes:[{id:'mesh:test',name:'SharpMesh',vertexCount:4,cornerCount:6,triangleCount:2,geometryStatus:'binary',geometryBufferId:'mesh:test',topology:'triangles',attributes:[]}],materials:[],images:[],animations:[],nonMeshData:[]};
|
||||
function exportedNormals(buffer) { const view=new DataView(buffer),jsonLength=view.getUint32(12,true),document=JSON.parse(new TextDecoder().decode(new Uint8Array(buffer,20,jsonLength))),accessor=document.accessors[document.meshes[0].primitives[0].attributes.NORMAL],range=document.bufferViews[accessor.bufferView];return Array.from(new Float32Array(buffer,28+jsonLength+(range.byteOffset??0)+(accessor.byteOffset??0),accessor.count*3),value=>value===0?0:value); }
|
||||
test('GLB keeps distinct face normals at a shared vertex without UVs',()=>{const before=structuredClone(geometry),result=exportGLB(scene,[geometry]);assert.equal(result.report.canExport,true);assert.deepEqual(exportedNormals(result.glb),[0,1,0,0,1,0,0,1,0,0,0,-1,0,0,-1,0,0,-1]);assert.deepEqual(geometry,before);});
|
||||
test('malformed explicit corner normals fail closed with a stable code',()=>{for(const patch of [{triangleCornerIndices:undefined},{triangleCornerIndices:new Uint32Array([0,1,2,3,4,20]).buffer},{splitNormals:new Float32Array([NaN,0,1]).buffer}]){const result=exportGLB(scene,[{...geometry,...patch}]);assert.equal(result.report.canExport,false);assert.equal(result.glb,undefined);assert.ok(result.report.warnings.some(warning=>warning.code==='MESH_NORMAL_MAPPING_INVALID'));}});
|
||||
test('LOD cache retains native corner normal bytes',()=>{const decoded=decodeLODGeometry(encodeLODGeometry([{level:0,meshId:'mesh:test:lod:0',triangleBudget:2,outputTriangleCount:2,outputVertexCount:4,geometryBuffers:[geometry]}]));assert.deepEqual(decoded[0].geometryBuffers[0].splitNormals,geometry.splitNormals);assert.deepEqual(decoded[0].geometryBuffers[0].triangleCornerIndices,geometry.triangleCornerIndices);});
|
||||
@@ -50,6 +50,14 @@ test("M12-06F rejects sparse accessors, extensions and external URIs", () => {
|
||||
assert.throws(() => protocol.importGLBSemantics(arrayBuffer(rewriteJson((document) => { document.buffers[0].uri = "external.bin"; }))), /GLB_EXTERNAL_URI_BLOCKED/);
|
||||
});
|
||||
|
||||
test("M12-06F accepts the bounded material extensions emitted by the exporter", () => {
|
||||
const imported = protocol.importGLBSemantics(arrayBuffer(rewriteJson((document) => {
|
||||
document.extensionsUsed = ["KHR_materials_ior", "KHR_materials_emissive_strength"];
|
||||
})));
|
||||
assert.equal(imported.version, 2);
|
||||
assert.deepEqual(imported.meshes.map((mesh) => mesh.name), ["M12 Mesh Fixture Mesh"]);
|
||||
});
|
||||
|
||||
test("M12-06F rejects over-budget GLB bytes and table counts", () => {
|
||||
const oversized = Buffer.alloc(protocol.GLB_IMPORT_BUDGET.maxBytes + 1);
|
||||
source.copy(oversized);
|
||||
|
||||
@@ -57,6 +57,13 @@ test("M9-07 serializes 2D canvas and 3D viewport edits through one selection rev
|
||||
assert.deepEqual(toggled.selectedPoints.map((item) => item.pointId), [point(0, 0).pointId, point(1, 0).pointId]);
|
||||
});
|
||||
|
||||
test("viewport subtract removes selected points without selecting absent points", () => {
|
||||
const before = selection.applyGreasePencilSelectionEdit(selection.createGreasePencilSelectionState(drawing), edit(0, "CANVAS_2D", "REPLACE", [point(0, 0), point(0, 1)]), drawing);
|
||||
const after = selection.applyGreasePencilSelectionEdit(before, edit(1, "VIEWPORT_3D", "SUBTRACT", [point(0, 1), point(1, 0)]), drawing);
|
||||
assert.deepEqual(after.selectedPoints, [point(0, 0)]);
|
||||
assert.equal(after.revision, 2);
|
||||
assert.throws(() => selection.applyGreasePencilSelectionEdit(after, edit(1, "VIEWPORT_3D", "SUBTRACT", [point(0, 0)]), drawing), /REVISION_CONFLICT/);
|
||||
});
|
||||
test("M9-07 rejects stale, foreign, duplicate and index-aliased selection edits", () => {
|
||||
const initial = selection.createGreasePencilSelectionState(drawing);
|
||||
assert.throws(
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "io-format-capability-matrix-unit-"));
|
||||
@@ -26,7 +27,7 @@ test("M12-05B binds the capability matrix and runtime inventory artifacts", () =
|
||||
assert.equal(manifest.task, "M12-05B");
|
||||
assert.equal(manifest.parentTask, "M12-05A");
|
||||
assert.equal(manifest.nextTask, "M12-05C");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-05B accepts the seven-format matrix and keeps the bounded GLB export route explicit", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "io-format-receipt-freshness-unit-"));
|
||||
@@ -50,9 +51,7 @@ test("M12-05F artifact is deterministic and bound to M12-05E", () => {
|
||||
assert.equal(manifest.task, "M12-05F");
|
||||
assert.equal(manifest.parentTask, "M12-05E");
|
||||
assert.equal(manifest.nextTask, "M12-06A");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(crypto.createHash("sha256").update(fs.readFileSync(path.join(root, artifact.path))).digest("hex"), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
assert.equal(freshness.parentBindingSha256, expected.parentBindingSha256);
|
||||
assert.equal(freshness.boundReceiptSetSha256, expected.boundReceiptSetSha256);
|
||||
assert.equal(freshness.runtimeSha256, expected.runtimeSha256);
|
||||
|
||||
32
web/tests/unit/legacy-manifest-integrity.mjs
Normal file
32
web/tests/unit/legacy-manifest-integrity.mjs
Normal file
@@ -0,0 +1,32 @@
|
||||
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(import.meta.dirname, "../../..");
|
||||
const evidence = JSON.parse(fs.readFileSync(path.join(root, "tests/golden/WBV2-P1424-001/release-validation-20261021/M12-manifest-sha-drift-3.json"), "utf8"));
|
||||
const sha256 = (file) => crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
|
||||
assert.equal(sha256(path.join(root, evidence.previousEvidence.path)), evidence.previousEvidence.sha256);
|
||||
assert.equal(sha256(path.join(root, evidence.previousObservation.path)), evidence.previousObservation.sha256);
|
||||
const key = (task, artifact) => `${task}:${artifact}`;
|
||||
const recorded = new Map(evidence.entries.map((entry) => [key(entry.task, entry.artifact), entry]));
|
||||
|
||||
export function assertLegacyManifestArtifacts(manifest) {
|
||||
const manifestPath = `tests/golden/${manifest.task}/manifest.json`;
|
||||
assert.equal(sha256(path.join(root, manifestPath)), evidence.manifestSha256[manifestPath], `${manifest.task} historical manifest changed`);
|
||||
for (const [artifact, binding] of Object.entries(manifest.artifacts ?? {})) {
|
||||
const actual = sha256(path.join(root, binding.path));
|
||||
if (actual === binding.sha256) continue;
|
||||
const entry = recorded.get(key(manifest.task, artifact));
|
||||
assert.ok(entry, `${manifest.task}:${artifact} drift is not classified`);
|
||||
assert.equal(entry.path, binding.path);
|
||||
assert.equal(entry.originalSha256, binding.sha256);
|
||||
assert.equal(entry.observedSha256, actual);
|
||||
if (entry.sourceSnapshot) {
|
||||
assert.equal(sha256(path.join(root, entry.sourceSnapshot)), binding.sha256);
|
||||
assert.equal(entry.provenanceState, "VERIFIED_HISTORICAL_BYTES");
|
||||
} else assert.equal(entry.provenanceState, "BLOCKED_SOURCE_LOST");
|
||||
}
|
||||
}
|
||||
|
||||
export { evidence };
|
||||
21
web/tests/unit/legacy-manifest-integrity.test.mjs
Normal file
21
web/tests/unit/legacy-manifest-integrity.test.mjs
Normal file
@@ -0,0 +1,21 @@
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
import { assertLegacyManifestArtifacts, evidence } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
|
||||
test("M12 historical manifest drift is explicit and read-only", () => {
|
||||
assert.equal(evidence.historicalEvidencePreserved, true);
|
||||
assert.equal(evidence.immutableSourceSnapshotAvailable, true);
|
||||
assert.equal(evidence.completeImmutableSourceSnapshotAvailable, false);
|
||||
assert.equal(evidence.provenanceState, "PARTIAL_HISTORICAL_SOURCES");
|
||||
assert.equal(evidence.recoveredBindings, evidence.entries.filter(entry => entry.provenanceState === "VERIFIED_HISTORICAL_BYTES").length);
|
||||
assert.equal(evidence.blockedBindings, evidence.entries.filter(entry => entry.provenanceState === "BLOCKED_SOURCE_LOST").length);
|
||||
assert.ok(evidence.entries.length > 0);
|
||||
for (const task of fs.readdirSync(path.join(root, "tests/golden")).filter((name) => /^M12-/u.test(name)).sort()) {
|
||||
const manifestPath = path.join(root, "tests/golden", task, "manifest.json");
|
||||
if (fs.existsSync(manifestPath)) assertLegacyManifestArtifacts(JSON.parse(fs.readFileSync(manifestPath, "utf8")));
|
||||
}
|
||||
});
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-archive-budget-unit-"));
|
||||
@@ -31,7 +32,7 @@ test("M12-04F binds archive budget constants and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-04F");
|
||||
assert.equal(manifest.parentTask, "M12-04E");
|
||||
assert.equal(manifest.nextTask, "M12-04G");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
assert.equal(io.ASSET_LIBRARY_BUDGET.maxArchivePathDepth, 64);
|
||||
assert.equal(io.ASSET_LIBRARY_BUDGET.maxArchiveFileNameBytes, 255);
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-archive-cancellation-unit-"));
|
||||
@@ -95,7 +96,7 @@ test("M12-04H binds cancellation rollback and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-04H");
|
||||
assert.equal(manifest.parentTask, "M12-04G");
|
||||
assert.equal(manifest.nextTask, "M12-04I");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(fileSha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-04H removes partially written staging and preserves the committed project on cancellation", async () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-archive-conflicts-unit-"));
|
||||
@@ -23,7 +24,7 @@ test("M12-04G binds range/conflict validation and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-04G");
|
||||
assert.equal(manifest.parentTask, "M12-04F");
|
||||
assert.equal(manifest.nextTask, "M12-04H");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-04G accepts deterministic non-overlapping ranges and reports totals", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-archive-recovery-unit-"));
|
||||
@@ -140,7 +141,7 @@ test("M12-04I binds quota/OOM cleanup and recovery evidence", () => {
|
||||
assert.equal(manifest.parentTask, "M12-04H");
|
||||
assert.equal(manifest.nextTask, "M12-04J");
|
||||
assert.deepEqual(manifest.assertions.faultCodes, ["STORAGE_QUOTA", "WASM_OUT_OF_MEMORY"]);
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(fileSha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-04I releases partial staging after quota and accepts a small archive in the same storage", async () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-link-safety-unit-"));
|
||||
@@ -37,7 +38,7 @@ test("M12-04D binds the archive link gate and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-04D");
|
||||
assert.equal(manifest.parentTask, "M12-04C");
|
||||
assert.equal(manifest.nextTask, "M12-04E");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-04D resolves symlinks relative to their parent and hardlinks from the archive root", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-linked-missing-unit-"));
|
||||
@@ -41,7 +42,7 @@ test("M12-03I binds the missing-library protocol and evidence artifacts", () =>
|
||||
assert.equal(manifest.task, "M12-03I");
|
||||
assert.equal(manifest.parentTask, "M12-03H");
|
||||
assert.equal(manifest.nextTask, "M12-03J");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-03I marks only the matching reference missing and preserves its original source", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-linked-mutation-unit-"));
|
||||
@@ -38,7 +39,7 @@ test("M12-03G binds the linked writer protocol and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-03G");
|
||||
assert.equal(manifest.parentTask, "M12-03F");
|
||||
assert.equal(manifest.nextTask, "M12-03H");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-03G blocks every linked data writer with the stable mutation code", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-linked-reload-unit-"));
|
||||
@@ -38,7 +39,7 @@ test("M12-03H binds the reload protocol and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-03H");
|
||||
assert.equal(manifest.parentTask, "M12-03G");
|
||||
assert.equal(manifest.nextTask, "M12-03I");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-03H replaces only the matching library generation and preserves every other snapshot", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-metadata-first-unit-"));
|
||||
@@ -27,7 +28,7 @@ test("M12-04E binds metadata-first planning and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-04E");
|
||||
assert.equal(manifest.parentTask, "M12-04D");
|
||||
assert.equal(manifest.nextTask, "M12-04F");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-04E plans ZIP central-directory and TAR manifest reads without payload ranges", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-negative-cases-unit-"));
|
||||
@@ -35,7 +36,7 @@ test("M12-03M binds the library negative-case protocol and evidence artifacts",
|
||||
assert.equal(manifest.task, "M12-03M");
|
||||
assert.equal(manifest.parentTask, "M12-03L");
|
||||
assert.equal(manifest.nextTask, "M12-03N");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-03M accepts an acyclic graph with unique data-block and reload identities", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-operation-identity-unit-"));
|
||||
@@ -39,9 +40,7 @@ test("M12-03B binds the inventory, protocol, golden, and unit artifacts", () =>
|
||||
assert.equal(manifest.enablingTask, true);
|
||||
assert.equal(manifest.parityStateChange, false);
|
||||
assert.equal(manifest.nextTask, "M12-03C");
|
||||
for (const artifact of Object.values(manifest.artifacts)) {
|
||||
assert.equal(sha256(fs.readFileSync(path.join(root, artifact.path))), artifact.sha256, artifact.path);
|
||||
}
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-03B derives a stable source library ID from locator and bytes", async () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-override-freshness-unit-"));
|
||||
@@ -59,7 +60,7 @@ test("M12-03L binds the override freshness gate and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-03L");
|
||||
assert.equal(manifest.parentTask, "M12-03K");
|
||||
assert.equal(manifest.nextTask, "M12-03M");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-03L allows only a fully matching source generation/revision commit", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-override-writer-unit-"));
|
||||
@@ -50,7 +51,7 @@ test("M12-03K binds the single-property writer and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-03K");
|
||||
assert.equal(manifest.parentTask, "M12-03J");
|
||||
assert.equal(manifest.nextTask, "M12-03L");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-03K applies exactly the verified override property and advances one revision", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-path-normalization-unit-"));
|
||||
@@ -28,7 +29,7 @@ const policy = { schemaVersion: 1, declaredHttpsOrigins: ["https://assets.exampl
|
||||
test("M12-04B binds the shared path normalizer and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-04B");
|
||||
assert.equal(manifest.nextTask, "M12-04C");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-04B canonicalizes POSIX and Windows separators with dot segments", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-path-security-unit-"));
|
||||
@@ -31,7 +32,7 @@ test("M12-04C binds the path security gate and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-04C");
|
||||
assert.equal(manifest.parentTask, "M12-04B");
|
||||
assert.equal(manifest.nextTask, "M12-04D");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-04C rejects absolute, UNC, drive, NUL, control, and origin-style project paths", () => {
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import test from "node:test";
|
||||
import ts from "typescript";
|
||||
import { assertLegacyManifestArtifacts } from "./legacy-manifest-integrity.mjs";
|
||||
|
||||
const root = path.resolve(import.meta.dirname, "../../..");
|
||||
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "library-source-origin-unit-"));
|
||||
@@ -29,7 +30,7 @@ const digest = "a".repeat(64);
|
||||
test("M12-04A binds the declared source-origin protocol and evidence artifacts", () => {
|
||||
assert.equal(manifest.task, "M12-04A");
|
||||
assert.equal(manifest.nextTask, "M12-04B");
|
||||
for (const artifact of Object.values(manifest.artifacts)) assert.equal(sha256(artifact.path), artifact.sha256, artifact.path);
|
||||
assertLegacyManifestArtifacts(manifest);
|
||||
});
|
||||
|
||||
test("M12-04A accepts declared HTTPS, project asset, and user-selected file sources", () => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import assert from "node:assert/strict";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import test from "node:test";
|
||||
@@ -10,7 +11,7 @@ const packageJson = JSON.parse(
|
||||
|
||||
test("browser runtime dependencies stay local", () => {
|
||||
const runtimePackages = Object.keys(packageJson.dependencies ?? {});
|
||||
assert.deepEqual(runtimePackages, ["@ffmpeg/core", "@ffmpeg/ffmpeg", "@ffmpeg/util", "react", "react-dom"]);
|
||||
assert.deepEqual([...runtimePackages].sort(), ["@ffmpeg/core", "@ffmpeg/ffmpeg", "@ffmpeg/util", "@webgpu/glslang", "fflate", "naga-wasm", "react", "react-dom"].sort());
|
||||
assert.equal(packageJson.dependencies?.three, undefined);
|
||||
assert.equal(packageJson.dependencies?.["@sqlite.org/sqlite-wasm"], undefined);
|
||||
for (const name of runtimePackages) {
|
||||
@@ -41,10 +42,8 @@ test("required renderer and engine assets are vendored", () => {
|
||||
const filePath = path.join(webRoot, relativePath);
|
||||
assert.ok(fs.statSync(filePath).size > 0, `${relativePath} must be non-empty`);
|
||||
}
|
||||
assert.deepEqual(
|
||||
fs.readFileSync(path.join(webRoot, "app/src/vendor/blender/web_engine.wasm")),
|
||||
fs.readFileSync(path.join(webRoot, "app/public/vendor/blender/web_engine.wasm")),
|
||||
);
|
||||
const digest = relative => crypto.createHash("sha256").update(fs.readFileSync(path.join(webRoot, relative))).digest("hex");
|
||||
assert.equal(digest("app/src/vendor/blender/web_engine.wasm"), digest("app/public/vendor/blender/web_engine.wasm"), "source/public native WASM must match");
|
||||
for (const relativePath of [
|
||||
"blender-5.2.0/extern/zlib/CMakeLists.txt",
|
||||
"blender-5.2.0/extern/zstd/build/cmake/CMakeLists.txt",
|
||||
|
||||
113
web/tests/unit/server-operator-http.test.mjs
Normal file
113
web/tests/unit/server-operator-http.test.mjs
Normal file
@@ -0,0 +1,113 @@
|
||||
import assert from "node:assert/strict";
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { once } from "node:events";
|
||||
import test from "node:test";
|
||||
import { createDeploymentHttpServer } from "../../../tools/web/deployment-http-server.mjs";
|
||||
|
||||
const digest = (value) => crypto.createHash("sha256").update(value).digest("hex");
|
||||
const canonical = (value) => JSON.stringify(value, (_, item) => item && !Array.isArray(item) && typeof item === "object" ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
|
||||
|
||||
test("async HTTP provider lifecycle (transport double, not Blender evidence)", async (t) => {
|
||||
const workspaceRoot = fs.mkdtempSync(path.join(os.tmpdir(), "operator-http-test-"));
|
||||
const options = { workspaceRoot, pythonBinary: path.resolve(import.meta.dirname, "../fixtures/server-operator-runner.py") };
|
||||
const server = createDeploymentHttpServer({ root: workspaceRoot, serverOperator: options });
|
||||
server.listen(0, "127.0.0.1");
|
||||
await once(server, "listening");
|
||||
const url = `http://127.0.0.1:${server.address().port}/api/server-operator-job`;
|
||||
const requests = [];
|
||||
async function call(action, request, body) {
|
||||
const response = await fetch(action === "read" ? `${url}?jobId=${request.jobId}&requestSha256=${request.requestSha256}` : url, {
|
||||
method: action === "read" ? "GET" : "POST",
|
||||
headers: { "X-Server-Operator-Action": action },
|
||||
body: action === "read" ? undefined : body ?? JSON.stringify(request),
|
||||
signal: AbortSignal.timeout(5000),
|
||||
});
|
||||
return { code: response.status, ...await response.json() };
|
||||
}
|
||||
function envelope(mode, overrides = {}) {
|
||||
const source = Buffer.from("transport-source");
|
||||
const properties = { mode };
|
||||
const request = { schemaVersion: 1, route: "SERVER_NATIVE", jobId: crypto.randomUUID(), sourceBlendSha256: digest(source), sourceBlendByteLength: source.length, sourceRevision: 1, blenderBuild: { version: "test", buildSha256: "a".repeat(64) }, operator: "object.test", properties, propertiesSha256: digest(canonical(properties)), timeoutMs: 1000, memoryBytes: 64 * 1024 * 1024, resultBinding: { kind: "snapshot", key: "test" }, context: "BACKGROUND", ...overrides };
|
||||
request.requestSha256 = digest(canonical(request));
|
||||
const json = Buffer.from(JSON.stringify(request));
|
||||
const header = Buffer.alloc(16);
|
||||
header.write("WBJ1"); header.writeUInt32LE(1, 4); header.writeUInt32LE(json.length, 8); header.writeUInt32LE(source.length, 12);
|
||||
requests.push(request);
|
||||
return { request, body: Buffer.concat([header, json, source]) };
|
||||
}
|
||||
async function terminal(request) {
|
||||
for (let i = 0; i < 80; i++) {
|
||||
const reply = await call("read", request);
|
||||
if (reply.result.status !== "RUNNING") return reply.result;
|
||||
await new Promise((resolve) => setTimeout(resolve, 50));
|
||||
}
|
||||
assert.fail("job did not reach a terminal state");
|
||||
}
|
||||
try {
|
||||
await t.test("deployment reserves the API and rejects invalid methods/actions before execution", async () => {
|
||||
const invalid = await call("unknown", {});
|
||||
assert.equal(invalid.code, 400);
|
||||
for (const action of ["describe", "submit", "cancel"]) {
|
||||
const response = await fetch(url, { headers: { "X-Server-Operator-Action": action } });
|
||||
assert.equal(response.status, 405);
|
||||
assert.equal(response.headers.get("allow"), "POST");
|
||||
assert.equal(response.headers.get("cache-control"), "no-store");
|
||||
assert.equal(response.headers.get("cross-origin-opener-policy"), "same-origin");
|
||||
}
|
||||
assert.equal((await fetch(`${url}?jobId=missing&requestSha256=missing`)).status, 404);
|
||||
assert.equal((await fetch(new URL("/index.html", url), { method: "POST" })).status, 405);
|
||||
const malformed = await call("submit", {}, Buffer.from("invalid envelope"));
|
||||
assert.equal(malformed.code, 400);
|
||||
const versioned = envelope("success"); versioned.body.writeUInt32LE(2, 4);
|
||||
assert.equal((await call("submit", versioned.request, versioned.body)).code, 400);
|
||||
assert.equal((await call("read", versioned.request)).code, 404);
|
||||
assert.deepEqual(fs.readdirSync(workspaceRoot), []);
|
||||
});
|
||||
await t.test("202, concurrent reads, success, immutable terminal state and cleanup", async () => {
|
||||
const { request, body } = envelope("success");
|
||||
const submitted = await call("submit", request, body);
|
||||
assert.equal(submitted.code, 202); assert.equal(submitted.result.status, "RUNNING");
|
||||
assert.equal((await call("read", request)).result.status, "RUNNING");
|
||||
assert.equal((await call("submit", request, body)).code, 409);
|
||||
const replies = await Promise.all([terminal(request), terminal(request)]);
|
||||
assert.deepEqual(replies[0], replies[1]);
|
||||
assert.equal(replies[0].status, "SUCCEEDED");
|
||||
assert.equal(Buffer.from(replies[0].resultBlendBase64, "base64").toString(), "transport-result");
|
||||
assert.equal((await call("cancel", request)).result.status, "SUCCEEDED");
|
||||
assert.deepEqual(fs.readdirSync(workspaceRoot), []);
|
||||
});
|
||||
await t.test("cancel is idempotent; no late success or result bytes", async () => {
|
||||
const { request, body } = envelope("slow");
|
||||
await call("submit", request, body);
|
||||
await Promise.all([call("cancel", request), call("read", request)]);
|
||||
assert.equal((await call("cancel", request)).result.status, "CANCELLED");
|
||||
const result = await terminal(request);
|
||||
assert.equal(result.status, "CANCELLED"); assert.equal(result.resultBlendBase64, undefined);
|
||||
assert.deepEqual(fs.readdirSync(workspaceRoot), []);
|
||||
});
|
||||
for (const mode of ["signal", "slow", "malformed", "bad-hash", "bad-binding"]) {
|
||||
await t.test(`${mode} fails closed and cleans without polling`, async () => {
|
||||
const { request, body } = envelope(mode);
|
||||
assert.equal((await call("submit", request, body)).code, 202);
|
||||
await new Promise((resolve) => setTimeout(resolve, mode === "slow" ? 1600 : 650));
|
||||
assert.deepEqual(fs.readdirSync(workspaceRoot), []);
|
||||
const result = await terminal(request);
|
||||
assert.equal(result.status, "FAILED"); assert.equal(result.resultBlendBase64, undefined);
|
||||
});
|
||||
}
|
||||
await t.test("missing executable does not crash the HTTP provider", async () => {
|
||||
options.pythonBinary = path.join(workspaceRoot, "missing-python");
|
||||
const { request, body } = envelope("success");
|
||||
assert.equal((await call("submit", request, body)).code, 202);
|
||||
assert.equal((await terminal(request)).status, "FAILED");
|
||||
});
|
||||
} finally {
|
||||
for (const request of requests) await call("cancel", request).catch(() => {});
|
||||
server.closeAllConnections();
|
||||
await new Promise((resolve) => server.close(resolve));
|
||||
fs.rmSync(workspaceRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
40
web/tests/unit/web-engine-runtime-sync.test.mjs
Normal file
40
web/tests/unit/web-engine-runtime-sync.test.mjs
Normal file
@@ -0,0 +1,40 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import crypto from "node:crypto";
|
||||
import { syncWebEngineRuntime } from "../../../tools/web/sync-web-engine-runtime.mjs";
|
||||
|
||||
function fixture(t) {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "webengine-sync-"));
|
||||
t.after(() => fs.rmSync(root, { recursive: true, force: true }));
|
||||
fs.mkdirSync(path.join(root, "build_web_blender6/bin"), { recursive: true });
|
||||
fs.mkdirSync(path.join(root, "web/app/public"), { recursive: true });
|
||||
const wasm = Buffer.from([0, 97, 115, 109, 1, 0, 0, 0]);
|
||||
fs.writeFileSync(path.join(root, "build_web_blender6/bin/web_engine.wasm"), wasm);
|
||||
fs.writeFileSync(path.join(root, "build_web_blender6/bin/web_engine.js"), "export default {};\n");
|
||||
const manifest = { modules: [{ resources: { single: { url: "/vendor/blender/web_engine.wasm", sha256: "old" }, pthread: { url: "/vendor/blender/pthread/web_engine.wasm", sha256: "other" } } }] };
|
||||
fs.writeFileSync(path.join(root, "web/app/public/wasm-module-manifest.json"), JSON.stringify(manifest));
|
||||
return { root, wasm };
|
||||
}
|
||||
|
||||
test("compiled artifacts and their exact runtime binding are synchronized", (t) => {
|
||||
const { root, wasm } = fixture(t);
|
||||
const result = syncWebEngineRuntime(root);
|
||||
const manifest = JSON.parse(fs.readFileSync(path.join(root, "web/app/public/wasm-module-manifest.json")));
|
||||
assert.equal(manifest.modules[0].resources.single.sha256, crypto.createHash("sha256").update(wasm).digest("hex"));
|
||||
assert.equal(manifest.modules[0].resources.pthread.sha256, "other");
|
||||
assert.deepEqual(fs.readFileSync(path.join(root, "web/app/public/vendor/blender/web_engine.wasm")), wasm);
|
||||
assert.equal(result.changed.length, 5);
|
||||
assert.equal(syncWebEngineRuntime(root).changed.length, 0);
|
||||
});
|
||||
|
||||
test("invalid builds never replace working runtime assets", (t) => {
|
||||
const { root } = fixture(t);
|
||||
syncWebEngineRuntime(root);
|
||||
const current = fs.readFileSync(path.join(root, "web/app/public/wasm-module-manifest.json"));
|
||||
fs.writeFileSync(path.join(root, "build_web_blender6/bin/web_engine.wasm"), "invalid");
|
||||
assert.throws(() => syncWebEngineRuntime(root), /invalid/);
|
||||
assert.deepEqual(fs.readFileSync(path.join(root, "web/app/public/wasm-module-manifest.json")), current);
|
||||
});
|
||||
63
web/tests/unit/workflow-case.test.mjs
Normal file
63
web/tests/unit/workflow-case.test.mjs
Normal file
@@ -0,0 +1,63 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { blendFormat, candidateInputs, fileHash, reportOutcome, reusable, sameInputs, validatePlan, validateSourceReview } from '../../../tools/web/workflow-case-lib.mjs';
|
||||
function temporary(t) { const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'wb-case-')); t.after(() => fs.rmSync(dir, { recursive: true, force: true })); return dir; }
|
||||
const report = () => ({ stats: { expected: 1, unexpected: 0, flaky: 0, skipped: 0 }, errors: [], suites: [{ specs: [{ tests: [{ expectedStatus: 'passed', status: 'expected', results: [{ status: 'passed' }] }] }] }] });
|
||||
test('source reviews reject stale hashes, malformed types and unbound contracts', () => {
|
||||
const sha256 = 'a'.repeat(64), review = { schemaVersion: 1, status: 'REVIEWED_SCOPE', batchId: 'B1', verifiedUnitDelta: 0, bindings: [{ path: 'source.cc', sha256 }], contracts: [{ id: 'rna', scope: 'location', sourcePaths: ['source.cc'], proofStages: ['changedUI'] }] };
|
||||
assert.equal(validateSourceReview(review, () => sha256), review);
|
||||
assert.throws(() => validateSourceReview(review, () => 'b'.repeat(64)), /SOURCE_REVIEW_DRIFT/);
|
||||
assert.throws(() => validateSourceReview({ ...review, bindings: [{ path: 'source.cc', sha256: 42 }] }, () => sha256));
|
||||
assert.throws(() => validateSourceReview({ ...review, contracts: [{ ...review.contracts[0], sourcePaths: ['unreviewed.cc'] }] }, () => sha256), /must be bound/);
|
||||
assert.throws(() => validateSourceReview({ ...review, contracts: [...review.contracts, ...review.contracts] }, () => sha256), /duplicate/);
|
||||
});
|
||||
test('report types are checked before comparisons; no coercion', () => {
|
||||
assert.equal(reportOutcome(report()).passed, true);
|
||||
for (const value of ['1', null, NaN, -1]) { const r = report(); r.stats.expected = value; assert.throws(() => reportOutcome(r), /integer/); }
|
||||
assert.throws(() => reportOutcome({ ...report(), suites: {} }), /arrays/);
|
||||
});
|
||||
test('empty or inconsistent counters cannot produce a pass', () => {
|
||||
const r = report(); r.suites = []; r.stats.expected = 0; assert.equal(reportOutcome(r).passed, false);
|
||||
assert.equal(reportOutcome({ ...report(), stats: { ...report().stats, expected: 2 } }).passed, false);
|
||||
});
|
||||
test('skip, expected failure, retry, flaky outcome and global error remain failures', () => {
|
||||
for (const status of ['skipped', 'flaky', 'unexpected']) { const r = report(); r.suites[0].specs[0].tests[0].status = status; assert.equal(reportOutcome(r).passed, false); }
|
||||
const r = report(), t = r.suites[0].specs[0].tests[0]; t.expectedStatus = 'failed'; assert.equal(reportOutcome(r).passed, false);
|
||||
t.expectedStatus = 'passed'; t.results.push({ status: 'passed' }); assert.equal(reportOutcome(r).passed, false);
|
||||
assert.equal(reportOutcome({ ...report(), errors: [{ message: 'setup failed' }] }).passed, false);
|
||||
});
|
||||
test('reuse requires matching identity and all original artifacts', t => {
|
||||
const file = path.join(temporary(t), 'evidence'); fs.writeFileSync(file, 'first');
|
||||
const saved = { status: 'PASS', inputHash: 'input', artifacts: [{ path: file, sha256: fileHash(file) }] };
|
||||
assert.equal(reusable(saved, 'input'), true); assert.equal(reusable(saved, 'different'), false);
|
||||
fs.writeFileSync(file, 'drift'); assert.equal(reusable(saved, 'input'), false);
|
||||
fs.unlinkSync(file); assert.equal(reusable(saved, 'input'), false); assert.equal(reusable({ ...saved, artifacts: [] }, 'input'), false);
|
||||
});
|
||||
test('candidate SHA and actual WASM bytes are required', t => {
|
||||
const dir = temporary(t), native = path.join(dir, 'public/vendor/blender'); fs.mkdirSync(native, { recursive: true });
|
||||
const js = path.join(native, 'web_engine.js'), wasm = path.join(native, 'web_engine.wasm'); fs.writeFileSync(js, 'export default {}'); fs.writeFileSync(wasm, Buffer.from([0,97,115,109,1,0,0,0]));
|
||||
fs.writeFileSync(path.join(dir, 'candidate.json'), JSON.stringify({ sha256: { 'web_engine.js': fileHash(js), 'web_engine.wasm': fileHash(wasm) } }));
|
||||
assert.equal(candidateInputs(dir).length, 3); fs.appendFileSync(wasm, 'changed'); assert.throws(() => candidateInputs(dir), /drift/);
|
||||
});
|
||||
test('blend compression is detected from bytes, and numeric strings stay distinct', t => {
|
||||
const file = path.join(temporary(t), 'scene.blend');
|
||||
for (const [bytes, format] of [[Buffer.from('BLENDER'), 'blend'], [Buffer.from([0x1f,0x8b]), 'gzip'], [Buffer.from([0x28,0xb5,0x2f,0xfd]), 'zstd']]) { fs.writeFileSync(file, bytes); assert.equal(blendFormat(file), format); }
|
||||
fs.writeFileSync(file, 'notblend'); assert.throws(() => blendFormat(file), /header/);
|
||||
assert.throws(() => sameInputs({ revision: 1 }, { revision: '1' }), /inputs changed/);
|
||||
sameInputs({ revision: 1, values: [0, 1] }, { revision: 1, values: [0, 1] });
|
||||
});
|
||||
test('case plans preserve minimal/production order and reject coercible options', () => {
|
||||
const p = JSON.parse(fs.readFileSync(new URL('../../../tools/web/workflow-cases/B1.json', import.meta.url), 'utf8'));
|
||||
assert.equal(validatePlan(p).batchId, 'B1');
|
||||
assert.throws(() => validatePlan({ ...p, timeoutMs: '180000' }), /integer/);
|
||||
assert.throws(() => validatePlan({ ...p, nativeSession: 'true' }), /boolean/);
|
||||
assert.throws(() => validatePlan({ ...p, fixtures: [...p.fixtures].reverse() }));
|
||||
});
|
||||
test('source suites require one source fixture and a bound Blender test path', () => {
|
||||
const p = JSON.parse(fs.readFileSync(new URL('../../../tools/web/workflow-cases/B1.json', import.meta.url), 'utf8')), suite = 'blender-5.2.0/tests/python/bl_blendfile_io.py';
|
||||
const source = { ...p, sourceSuite: suite, sourcePaths: [suite], fixtures: [{ ...p.fixtures[0], kind: 'source' }] }; assert.equal(validatePlan(source).sourceSuite, suite);
|
||||
assert.throws(() => validatePlan({ ...source, sourcePaths: ['unbound.py'] })); assert.throws(() => validatePlan({ ...source, sourceSuite: '../outside.py' })); assert.throws(() => validatePlan({ ...source, fixtures: p.fixtures }));
|
||||
});
|
||||
Reference in New Issue
Block a user