test_source_package_closure.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. from pathlib import Path
  2. import shutil
  3. import pytest
  4. from tools.source_package_closure import current_cpld_paths
  5. ROOT=Path(__file__).resolve().parents[2]
  6. def test_current_closure_contains_public_replay_dependencies():
  7. paths=current_cpld_paths(ROOT)
  8. required={'tools/fw_targets.py','tools/source_identity.py','tools/source_package_closure.py',
  9. 'contracts/mrdimm-status.yaml','contracts/ct7428-format.json','config/current-product-tests.json',
  10. 'generated/mrdimm/snapshot-layout.json','tools/_vendor/prod2u_status.py',
  11. 'tests/sim/i2c_master_tasks.vh','tests/sim/motor_queue_storage_tb.v','tools/td2026',
  12. 'docs/current-analysis-status.md','docs/audits/mrdimm-header-word-copy.md',
  13. 'tests/sim/motor_control_hold_monitor.vh','tools/prod2u_gui.py'}
  14. assert required<=set(paths)
  15. assert len(paths)==len(set(paths))
  16. assert not any('/legacy/' in p or p.startswith('src/generated/') for p in paths)
  17. assert not {'ACTIVE_GOAL_LOCK.yaml','PHASE_STATE.json','EVIDENCE_INDEX.json'} & set(paths)
  18. def copy_closure(destination):
  19. for relative in current_cpld_paths(ROOT):
  20. path=destination/relative;path.parent.mkdir(parents=True,exist_ok=True)
  21. shutil.copy2(ROOT/relative,path)
  22. def test_missing_local_import_fails_instead_of_disappearing(tmp_path):
  23. copy_closure(tmp_path)
  24. path=tmp_path/'tools/fw_cli.py'
  25. path.write_text(path.read_text()+'\nfrom tools.missing_required_replay_module import run\n')
  26. with pytest.raises(ValueError,match='required local Python import missing'):
  27. current_cpld_paths(tmp_path)
  28. def test_missing_generated_dependency_fails(tmp_path):
  29. copy_closure(tmp_path)
  30. (tmp_path/'generated/mrdimm/snapshot-layout.json').unlink()
  31. with pytest.raises(ValueError,match='required source dependency missing'):
  32. current_cpld_paths(tmp_path)