test_source_package_closure.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. 'tools/remote/prod2u-remote.ps1','tools/windows/remote-doctor.ps1',
  15. 'tests/unit/test_windows_remote_entrypoints.py'}
  16. assert required<=set(paths)
  17. assert len(paths)==len(set(paths))
  18. assert not any('/legacy/' in p or p.startswith('src/generated/') for p in paths)
  19. assert not {'ACTIVE_GOAL_LOCK.yaml','PHASE_STATE.json','EVIDENCE_INDEX.json'} & set(paths)
  20. def copy_closure(destination):
  21. for relative in current_cpld_paths(ROOT):
  22. path=destination/relative;path.parent.mkdir(parents=True,exist_ok=True)
  23. shutil.copy2(ROOT/relative,path)
  24. def test_missing_local_import_fails_instead_of_disappearing(tmp_path):
  25. copy_closure(tmp_path)
  26. path=tmp_path/'tools/fw_cli.py'
  27. path.write_text(path.read_text()+'\nfrom tools.missing_required_replay_module import run\n')
  28. with pytest.raises(ValueError,match='required local Python import missing'):
  29. current_cpld_paths(tmp_path)
  30. def test_missing_generated_dependency_fails(tmp_path):
  31. copy_closure(tmp_path)
  32. (tmp_path/'generated/mrdimm/snapshot-layout.json').unlink()
  33. with pytest.raises(ValueError,match='required source dependency missing'):
  34. current_cpld_paths(tmp_path)