feat: require native EDIF geometry in engineering identity

This commit is contained in:
阿白叔 committed 2026-11-03 11:43:45 +08:00
1 parent 63f3417f19
commit 89500cbb5f
2 files changed
+94 -5

No files matched your search

+20
View File
@@ -98,6 +98,7 @@ def test_capture_only_exports_fresh_copy_and_leaves_source_unchanged(project, tm
assert clone.parent == root/'project' and clone != source
(clone.parent/'database/icdb.dat').write_bytes(b'export changed disposable copy')
(root/'design.rpt').write_bytes(ascii_report())
(root/'design.edf').write_bytes(edif_report())
return {'success': True, 'safe_to_continue': True, 'detail': ''}
monkeypatch.setattr(identity, '_run_exports', exports)
monkeypatch.setattr(identity, 'csv_identity', lambda _: {'work/identity': 'csv proof'})
@@ -150,3 +151,22 @@ def test_export_timeout_retains_process_without_kill(project, tmp_path, monkeypa
assert len(identity._retained_exports) == 1
assert seen[0][-5:] == ['-f', '-h', '-c', '-t', '-nostrip']
assert (root/'ascii-process.json').is_file()
def edif_report(timestamp=b'2026 11 3 11 40 56'):
return (b'(edif DxD (edifVersion 2 0 0) (status (written (timestamp '+timestamp+b')'
b' (program "DxDesigner Edif Exporter"))) (library Board1 (cell Top'
b' (view SCHEMATIC_VIEW (viewType SCHEMATIC) (page sheet1 (figure LINE (pt 1 2)))'
b' (property timestamp (string "2026 11 3 11 40 56")))))'
b' (design Board1 (cellRef Top (libraryRef Board1))))')
def test_edif_only_normalizes_root_written_timestamp_preserving_geometry_and_properties():
from cbb_refresh_verify.native_engineering_identity import normalize_edif
first = edif_report()
assert normalize_edif(first, 'Top') == normalize_edif(edif_report(b'2026 11 3 11 40 59'), 'Top')
assert normalize_edif(first, 'Top') != normalize_edif(first.replace(b'(pt 1 2)', b'(pt 1 3)'), 'Top')
assert normalize_edif(first, 'Top') != normalize_edif(first.replace(b'"2026 11 3 11 40 56"', b'"changed"'), 'Top')
for bad in [first[:-1], first.replace(b'(edifVersion 2 0 0)', b'(edifVersion 1 0 0)'),
first.replace(b'(cellRef Top', b'(cellRef Other'), first.replace(b'(pt 1 2)', b'')]:
with pytest.raises(ValueError): normalize_edif(bad, 'Top')