import pytest import os.path import os filedir = os.path.dirname(os.path.abspath(__file__)) schematics_dir = os.path.join(filedir, "schematics") def find_task(tasks, name: str): t = next((t for t in tasks if t["name"] == name), None) assert(t is not None) return t def exec_task(task): targets = task["targets"] for a in task["actions"]: if isinstance(a, str): cmd = a % dict(targets=" ".join(targets)) ret = os.system(cmd) assert(ret == 0) else: a() def test_doit(tmpdir): from ee.kicad.doit import KicadDoitTasks args = dict( sch=os.path.join(schematics_dir, "schematic-1.sch"), kicad_sch_object_set_dir=os.path.join(tmpdir, "kicad-sch"), component_object_set_dir=os.path.join(tmpdir, "component"), ) tasks = list(KicadDoitTasks(**args).tasks()) assert(len(tasks) > 1) create_kicad_sch_objects = find_task(tasks, "create-kicad-sch-objects") exec_task(create_kicad_sch_objects) kicad_sch_to_component_object = find_task(tasks, "kicad-sch-to-component-object") exec_task(kicad_sch_to_component_object) # thirdparty/olinuxino/HARDWARE/A64-OLinuXino/A64-OLinuXino_Rev_C/A64-OlinuXino_Rev_C.sch