feat: close hidden link property evidence
This commit is contained in:
114
scripts/freecad-property-linklisthidden-success.py
Normal file
114
scripts/freecad-property-linklisthidden-success.py
Normal file
@@ -0,0 +1,114 @@
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
|
||||
import FreeCAD as App
|
||||
import Part
|
||||
|
||||
|
||||
FREECAD_COMMIT = "0108fd4b4850cc46e625b60e53cea7a7bbe69f8d"
|
||||
OUTPUT_PATH = os.environ.get("FREECAD_PROPERTY_LINKLISTHIDDEN_SUCCESS_OUTPUT", "")
|
||||
|
||||
|
||||
def shape_snapshot(obj):
|
||||
if "Shape" not in obj.PropertiesList:
|
||||
return {"applicable": False, "reason": "host-has-no-shape-property"}
|
||||
shape = obj.Shape
|
||||
if shape.isNull():
|
||||
return {
|
||||
"applicable": True,
|
||||
"isNull": True,
|
||||
"solids": 0,
|
||||
"faces": 0,
|
||||
"edges": 0,
|
||||
"vertices": 0,
|
||||
"brepSha256": None,
|
||||
}
|
||||
brep = shape.exportBrepToString()
|
||||
return {
|
||||
"applicable": True,
|
||||
"isNull": False,
|
||||
"solids": len(shape.Solids),
|
||||
"faces": len(shape.Faces),
|
||||
"edges": len(shape.Edges),
|
||||
"vertices": len(shape.Vertexes),
|
||||
"brepSha256": hashlib.sha256(brep.encode("utf-8")).hexdigest(),
|
||||
}
|
||||
|
||||
|
||||
def snapshot(document, owner, targets):
|
||||
recompute_result = bool(document.recompute())
|
||||
return {
|
||||
"value": [candidate.Name for candidate in owner.Exports],
|
||||
"propertyTypeId": owner.getTypeIdOfProperty("Exports"),
|
||||
"group": owner.getGroupOfProperty("Exports"),
|
||||
"propertyStatus": [str(item) for item in owner.getPropertyStatus("Exports")],
|
||||
"editorMode": [str(item) for item in owner.getEditorMode("Exports")],
|
||||
"ownerState": [str(item) for item in owner.State],
|
||||
"statusString": str(owner.getStatusString()),
|
||||
"recomputeResult": recompute_result,
|
||||
"shape": shape_snapshot(owner),
|
||||
"ownerOutList": [candidate.Name for candidate in owner.OutList],
|
||||
"targetInLists": {target.Name: [candidate.Name for candidate in target.InList] for target in targets},
|
||||
"targetShapes": {target.Name: shape_snapshot(target) for target in targets},
|
||||
"objectSet": [{"name": candidate.Name, "typeId": candidate.TypeId} for candidate in document.Objects],
|
||||
}
|
||||
|
||||
|
||||
def run_case(object_type_id, object_name):
|
||||
document = App.newDocument("PropertyLinkListHidden" + object_name)
|
||||
try:
|
||||
owner = document.addObject(object_type_id, object_name)
|
||||
first = document.addObject("Part::Feature", "ExportA")
|
||||
first.Shape = Part.makeBox(2.0, 3.0, 4.0)
|
||||
second = document.addObject("Part::Feature", "ExportB")
|
||||
second.Shape = Part.makeCylinder(1.5, 5.0)
|
||||
targets = [first, second]
|
||||
|
||||
owner.Exports = []
|
||||
phases = {"explicitEmpty": snapshot(document, owner, targets)}
|
||||
assignments = {
|
||||
"single": [first],
|
||||
"ordered": [second, first],
|
||||
"duplicates": [first, second, first],
|
||||
"restored": [],
|
||||
}
|
||||
for phase, value in assignments.items():
|
||||
owner.Exports = value
|
||||
phases[phase] = snapshot(document, owner, targets)
|
||||
return {
|
||||
"objectTypeId": object_type_id,
|
||||
"objectName": object_name,
|
||||
"propertyName": "Exports",
|
||||
"group": "Sketch",
|
||||
"mode": "direct-native-property-setter",
|
||||
"phases": phases,
|
||||
}
|
||||
finally:
|
||||
App.closeDocument(document.Name)
|
||||
|
||||
|
||||
cases = [
|
||||
run_case("Sketcher::SketchObject", "SketchProbe"),
|
||||
run_case("Sketcher::SketchObjectPython", "SketchPythonProbe"),
|
||||
]
|
||||
report = {
|
||||
"schemaVersion": 1,
|
||||
"status": "pass",
|
||||
"baselineId": "freecad-1.1.1-property-linklisthidden-success",
|
||||
"freecadVersion": ".".join(str(value) for value in App.Version()[:3]),
|
||||
"gitCommit": FREECAD_COMMIT,
|
||||
"propertyType": "App::PropertyLinkListHidden",
|
||||
"caseCount": len(cases),
|
||||
"bindingBoundary": {
|
||||
"oracleDefault": [],
|
||||
"safeFirstRead": "assign-empty-list-before-read",
|
||||
},
|
||||
"cases": cases,
|
||||
}
|
||||
if not OUTPUT_PATH:
|
||||
raise RuntimeError("FREECAD_PROPERTY_LINKLISTHIDDEN_SUCCESS_OUTPUT is required")
|
||||
with open(OUTPUT_PATH, "w", encoding="utf-8") as handle:
|
||||
json.dump(report, handle, indent=2, sort_keys=True)
|
||||
handle.write("\n")
|
||||
print("FREECAD_PROPERTY_LINKLISTHIDDEN_SUCCESS_RESULT=" + json.dumps({"status": report["status"], "caseCount": report["caseCount"]}, sort_keys=True))
|
||||
Reference in New Issue
Block a user