pixalynx/cm5-minimal-carrier

A 4-layer Raspberry Pi CM5 carrier board routes USB‑C 5V power through an RT9742 load switch with TVS protection and capacitive filtering, while providing ESD-protected HDMI output, CM5 connectors, test points, and ground/power planes.

Version
0.1.1
License
unset
Stars
0

scripts/test-manufacturing-audit.py

"""Negative tests: prove the CAM audit rejects real manufacturing export mistakes."""
import pathlib, shutil, subprocess, tempfile
R=pathlib.Path(__file__).resolve().parents[1]
PYTHON='/Applications/KiCad/KiCad.app/Contents/Frameworks/Python.framework/Versions/Current/bin/python3'
with tempfile.TemporaryDirectory(prefix='cm5-cam-audit-') as folder:
    root=pathlib.Path(folder)
    for name in ['lib/design.json','lib/manufacturing.json','dist/index/circuit.json']:
        dst=root/name;dst.parent.mkdir(parents=True,exist_ok=True);shutil.copy2(R/name,dst)
    shutil.copytree(R/'output',root/'output',ignore=shutil.ignore_patterns('*.zip','*.png','*.svg','*.html','schematics'))
    def run():return subprocess.run([PYTHON,str(R/'scripts/audit-manufacturing.py'),str(root)],text=True,capture_output=True)
    baseline=run();assert baseline.returncode==0,baseline.stderr
    cases=[
        ('shifted Gerber origin','output/fabrication-REVIEW/cm5-minimal-Edge_Cuts.gm1',lambda s:s.replace('X0Y0D01*','X1000000Y0D01*'),'Gerber outline uses the CPL origin'),
        ('paste on bare TP1','output/fabrication-REVIEW/cm5-minimal-B_Paste.gbp',lambda s:s.replace('M02*','X54000000Y42000000D03*\nM02*'),'Paste on probe pad'),
        ('incorrect USB peg drill','output/fabrication-REVIEW/cm5-minimal-NPTH.drl',lambda s:s.replace('C0.650','C0.750'),'All NPTH holes retain their coordinates and diameters'),
    ]
    for name,file,mutation,message in cases:
        p=root/file;original=p.read_text();changed=mutation(original);assert changed!=original
        p.write_text(changed)
        result=run()
        p.write_text(original)
        assert result.returncode!=0 and message in result.stderr, f'{name}: {result.stdout}\n{result.stderr}'
        print('PASS:',name,'is rejected')