42 lines
4.1 KiB
JavaScript
42 lines
4.1 KiB
JavaScript
import { isDeepStrictEqual } from 'node:util'
|
|
import { readFile } from 'node:fs/promises'
|
|
import { resolve } from 'node:path'
|
|
|
|
const root = resolve(new URL('..', import.meta.url).pathname)
|
|
const report = JSON.parse(await readFile(resolve(root, 'config/freecad-property-linklisthidden-success.json'), 'utf8'))
|
|
const fail = (message) => { throw new Error(`FreeCAD PropertyLinkListHidden success check failed: ${message}`) }
|
|
if (report.schemaVersion !== 1 || report.status !== 'pass' || report.baselineId !== 'freecad-1.1.1-property-linklisthidden-success' || report.freecadVersion !== '1.1.1' || report.gitCommit !== '0108fd4b4850cc46e625b60e53cea7a7bbe69f8d' || report.propertyType !== 'App::PropertyLinkListHidden') fail('baseline is invalid')
|
|
if (report.caseCount !== 2 || report.cases?.length !== 2 || !isDeepStrictEqual(report.bindingBoundary?.oracleDefault, []) || report.bindingBoundary.safeFirstRead !== 'assign-empty-list-before-read') fail('case inventory or first-read boundary changed')
|
|
const expectedHosts = new Map([
|
|
['Sketcher::SketchObject', 'SketchProbe'],
|
|
['Sketcher::SketchObjectPython', 'SketchPythonProbe'],
|
|
])
|
|
const expectedValues = {
|
|
explicitEmpty: [],
|
|
single: ['ExportA'],
|
|
ordered: ['ExportB', 'ExportA'],
|
|
duplicates: ['ExportA', 'ExportB', 'ExportA'],
|
|
restored: [],
|
|
}
|
|
const expectedObjects = (ownerName, ownerTypeId) => [
|
|
{ name: ownerName, typeId: ownerTypeId },
|
|
{ name: 'ExportA', typeId: 'Part::Feature' },
|
|
{ name: 'ExportB', typeId: 'Part::Feature' },
|
|
]
|
|
for (const entry of report.cases) {
|
|
const objectName = expectedHosts.get(entry.objectTypeId)
|
|
if (!objectName || entry.objectName !== objectName || entry.propertyName !== 'Exports' || entry.group !== 'Sketch' || entry.mode !== 'direct-native-property-setter') fail(`${entry.objectTypeId} identity changed`)
|
|
const baselineTargets = entry.phases?.explicitEmpty?.targetShapes
|
|
if (baselineTargets?.ExportA?.isNull !== false || baselineTargets.ExportA.solids !== 1 || baselineTargets.ExportA.faces !== 6 || baselineTargets.ExportA.edges !== 12 || baselineTargets.ExportA.vertices !== 8 || typeof baselineTargets.ExportA.brepSha256 !== 'string') fail(`${entry.objectTypeId} box target is invalid`)
|
|
if (baselineTargets?.ExportB?.isNull !== false || baselineTargets.ExportB.solids !== 1 || baselineTargets.ExportB.faces !== 3 || baselineTargets.ExportB.edges !== 3 || baselineTargets.ExportB.vertices !== 2 || typeof baselineTargets.ExportB.brepSha256 !== 'string') fail(`${entry.objectTypeId} cylinder target is invalid`)
|
|
for (const [phase, expectedValue] of Object.entries(expectedValues)) {
|
|
const snapshot = entry.phases?.[phase]
|
|
if (!isDeepStrictEqual(snapshot?.value, expectedValue) || snapshot.propertyTypeId !== 'App::PropertyLinkListHidden' || snapshot.group !== 'Sketch' || !isDeepStrictEqual(snapshot.propertyStatus, ['26']) || !isDeepStrictEqual(snapshot.editorMode, ['Hidden'])) fail(`${entry.objectTypeId} ${phase} property semantics changed`)
|
|
if (!isDeepStrictEqual(snapshot.ownerState, ['Up-to-date']) || snapshot.statusString !== 'Valid' || snapshot.recomputeResult !== true || snapshot.shape?.applicable !== true || snapshot.shape.isNull !== true || snapshot.shape.solids !== 0 || snapshot.shape.faces !== 0 || snapshot.shape.edges !== 0 || snapshot.shape.vertices !== 0 || snapshot.shape.brepSha256 !== null) fail(`${entry.objectTypeId} ${phase} host state changed`)
|
|
if (!isDeepStrictEqual(snapshot.ownerOutList, []) || !isDeepStrictEqual(snapshot.targetInLists, { ExportA: [], ExportB: [] })) fail(`${entry.objectTypeId} ${phase} leaked a hidden dependency or backlink`)
|
|
if (!isDeepStrictEqual(snapshot.targetShapes, baselineTargets)) fail(`${entry.objectTypeId} ${phase} changed a target Shape`)
|
|
if (!isDeepStrictEqual(snapshot.objectSet, expectedObjects(objectName, entry.objectTypeId))) fail(`${entry.objectTypeId} ${phase} changed the document object set`)
|
|
}
|
|
}
|
|
console.log(JSON.stringify({ status: 'freecad-property-linklisthidden-success-pass', cases: report.caseCount, phases: Object.keys(expectedValues), orderedValue: expectedValues.ordered, duplicateValue: expectedValues.duplicates, hiddenDependency: { ownerOutList: [], targetInLists: { ExportA: [], ExportB: [] } } }, null, 2))
|