Skip to content

Commit 4facf45

Browse files
committed
test: use snapshot_eval for footprint inference errors
1 parent 5b36558 commit 4facf45

File tree

3 files changed

+21
-41
lines changed

3 files changed

+21
-41
lines changed

crates/pcb-zen-core/tests/component_footprint_inference.rs

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,10 @@ fn component_infers_footprint_from_symbol_legacy_stem_pair() {
131131
);
132132
}
133133

134-
#[test]
135-
fn component_without_footprint_errors_when_inferred_file_missing() {
136-
let mut files = HashMap::new();
137-
files.insert("Part.kicad_sym".to_string(), single_pin_symbol("Part"));
138-
files.insert("test.zen".to_string(), component_zen_without_footprint());
139-
140-
let result = eval_with_files(files, "test.zen");
141-
assert!(!result.is_success(), "expected eval failure");
142-
let rendered = result
143-
.diagnostics
144-
.iter()
145-
.map(|d| d.to_string())
146-
.collect::<Vec<_>>()
147-
.join("\n");
148-
assert!(
149-
rendered.contains("Inferred footprint file not found"),
150-
"unexpected diagnostics: {rendered}"
151-
);
152-
}
134+
snapshot_eval!(missing_local_inferred_footprint, {
135+
"Part.kicad_sym" => single_pin_symbol("Part"),
136+
"test.zen" => component_zen_without_footprint(),
137+
});
153138

154139
#[test]
155140
fn explicit_footprint_takes_precedence_over_symbol_footprint_property() {
@@ -351,28 +336,10 @@ Component(
351336
);
352337
}
353338

354-
#[test]
355-
fn kicad_lib_fp_footprint_is_not_inferred_for_non_kicad_symbols() {
356-
let mut files = HashMap::new();
357-
files.insert(
358-
"Part.kicad_sym".to_string(),
359-
single_pin_symbol("Package_SO:TSSOP-8_4.4x3mm_P0.65mm"),
360-
);
361-
files.insert("test.zen".to_string(), component_zen_without_footprint());
362-
363-
let result = eval_with_files(files, "test.zen");
364-
assert!(!result.is_success(), "expected eval failure");
365-
let rendered = result
366-
.diagnostics
367-
.iter()
368-
.map(|d| d.to_string())
369-
.collect::<Vec<_>>()
370-
.join("\n");
371-
assert!(
372-
rendered.contains("No declared dependency matches"),
373-
"unexpected diagnostics: {rendered}"
374-
);
375-
}
339+
snapshot_eval!(libfp_requires_declared_dependency, {
340+
"Part.kicad_sym" => single_pin_symbol("Package_SO:TSSOP-8_4.4x3mm_P0.65mm"),
341+
"test.zen" => component_zen_without_footprint(),
342+
});
376343

377344
#[test]
378345
fn kicad_lib_fp_fallback_requires_footprints_dependency() {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
source: crates/pcb-zen-core/tests/component_footprint_inference.rs
3+
assertion_line: 339
4+
expression: output
5+
---
6+
Error: test.zen:2:1-6:2 Failed to infer footprint from KiCad symbol property 'Package_SO:TSSOP-8_4.4x3mm_P0.65mm': No declared dependency matches 'gitlab.com/kicad/libraries/kicad-footprints/Package_SO.pretty'
7+
Add a dependency that covers this path to [dependencies] in pcb.toml
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
source: crates/pcb-zen-core/tests/component_footprint_inference.rs
3+
assertion_line: 134
4+
expression: output
5+
---
6+
Error: test.zen:2:1-6:2 Inferred footprint file not found: /Part.kicad_mod

0 commit comments

Comments
 (0)