app
KiCad - the KiCad Bridge
Public Made by Adomby adom
Drive your own KiCad from an AI, in the background: open every editor, read the whole board as data (the EDA Bridge Standard board model), stack-up, part heights, netlists, place, route, pour, DRC and exports.
master
John Lauer
1.0.61: Every Konnect v0.13.0 capability, 211 verbs (was 133; docs/konnect-gap.md maps all 228 Konnect tools). Schemati…
baad156
14d ago
//! The fab helpers end to end on a small KiCad 10 board fixture (two resistors, a header,
//! a closed outline, a little copper): the pre-flight, the quote numbers, the JLCPCB BOM and
//! a stored zip that the bridge's own reader opens.
use std::path::Path;
use kicad_core::{dfm, fab};
fn fixture() -> String {
std::fs::read_to_string(Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures/fab-mini.kicad_pcb")).unwrap()
}
#[test]
fn fixture_parses_with_the_board_reader() {
let b = kicad_core::pcb::parse_pcb_text(&fixture(), "fab-mini").unwrap();
assert_eq!(b.footprints.len(), 3);
}
#[test]
fn preflight_numbers_bom_and_zip() {
let text = fixture();
let g = dfm::Geometry::from_text(&text).unwrap();
assert!(g.outline_closed().0);
let r = dfm::validate(&g, &dfm::builtin_profile("jlcpcb").unwrap(), &dfm::Options { assembly: true, max_items: 5 }, Err("no kicad-cli in the test"));
let checks: Vec<&str> = r["findings"].as_array().unwrap().iter().map(|f| f["check"].as_str().unwrap()).collect();
assert_eq!(r["pass"], true, "{r}");
assert!(checks.contains(&"3d_models"), "J1 has no model: {checks:?}");
assert!(checks.contains(&"fiducials"));
assert!(!checks.contains(&"min_space") && !checks.contains(&"acid_traps") && !checks.contains(&"edge_clearance"), "{checks:?}");
let n = fab::board_numbers(&text).unwrap();
assert_eq!(n["widthMm"], 30.0);
assert_eq!(n["layers"], 2);
assert_eq!(n["smdParts"], 2);
assert_eq!(n["thtParts"], 1);
assert_eq!(n["uniqueParts"], 2);
assert_eq!(n["holes"], 4, "three header pins and one via");
assert_eq!(n["minTrackMm"], 0.25);
let lines = fab::group_bom(&fab::parts_from_board(&text).unwrap());
let csv = fab::bom_csv(&lines, "jlcpcb");
assert_eq!(csv, "Comment,Designator,Footprint,LCSC Part #\nConn_01x03,J1,PinHeader_1x03_P2.54mm_Vertical,\n10k,\"R1,R2\",R_0603_1608Metric,C25804\n");
let zip = fab::zip_stored(&[("bom/fab-mini_BOM_JLCPCB.csv".into(), csv.clone().into_bytes()), ("README.txt".into(), b"x".to_vec())]).unwrap();
let z = kicad_core::pcm::ZipFile::parse(&zip).unwrap();
assert_eq!(z.entries.len(), 2);
}