fix(review): retain metadata version diagnostics across scopes
This commit is contained in:
parent
248f6bcff7
commit
0cbb2c0e2f
1 changed files with 104 additions and 7 deletions
|
|
@ -104,6 +104,73 @@ fn incomplete_reports_distinguish_known_differences_and_include_structured_locat
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn future_layer_metadata_remains_incomplete_under_geometry_scopes() {
|
||||
for location in ["CHIP", "legend"] {
|
||||
let bytes = if location == "CHIP" {
|
||||
layout(&[(
|
||||
"CHIP",
|
||||
vec![square(), label((900, 7), "KLAMATH_LAYER_NAMES_V2")],
|
||||
)])
|
||||
} else {
|
||||
layout(&[
|
||||
("CHIP", vec![square()]),
|
||||
("legend", vec![label((900, 7), "KLAMATH_LAYER_NAMES_V2")]),
|
||||
])
|
||||
};
|
||||
let source = Document::parse(&bytes).unwrap().diagnostics[0].offset;
|
||||
for scope in [
|
||||
Scope::default(),
|
||||
Scope {
|
||||
layer: Some((1, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
Scope {
|
||||
layer: Some((999, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
Scope {
|
||||
top: Some("CHIP".into()),
|
||||
..Default::default()
|
||||
},
|
||||
Scope {
|
||||
cell: Some("CHIP".into()),
|
||||
..Default::default()
|
||||
},
|
||||
Scope {
|
||||
top: Some("CHIP".into()),
|
||||
layer: Some((1, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
Scope {
|
||||
cell: Some("CHIP".into()),
|
||||
layer: Some((1, 0)),
|
||||
..Default::default()
|
||||
},
|
||||
] {
|
||||
let doc = Document::parse(&bytes)
|
||||
.unwrap()
|
||||
.selected(&scope, false)
|
||||
.unwrap();
|
||||
assert_eq!(doc.diagnostics.len(), 1, "{scope:?}");
|
||||
let diagnostic = &doc.diagnostics[0];
|
||||
assert_eq!(diagnostic.code, "unsupported_metadata_version");
|
||||
assert_eq!(diagnostic.cell.as_deref(), Some(location));
|
||||
assert_eq!(diagnostic.layer, Some((900, 7)));
|
||||
assert_eq!(diagnostic.offset, source);
|
||||
let diff = Comparison::between(&doc, &doc);
|
||||
assert_eq!(diff.exit_code(), 2);
|
||||
assert!(!diff.is_equal());
|
||||
assert!(diff.text(0).contains("INCOMPLETE"));
|
||||
let json = diff.json_report(&doc, &doc, &inputs(), &ReportOptions::default());
|
||||
assert_eq!(json["status"], "incomplete");
|
||||
assert_eq!(json["result"], "unknown");
|
||||
assert_eq!(json["exit_code"], 2);
|
||||
assert_eq!(json["diagnostics"].as_array().unwrap().len(), 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json_is_unbounded_by_default_and_explicit_filters_do_not_change_totals() {
|
||||
let a = layout(&[("CHIP", vec![])]);
|
||||
|
|
@ -542,4 +609,25 @@ fn cli_emits_json_for_success_input_errors_scope_errors_and_argument_errors() {
|
|||
assert_eq!(command(&[])["result"], "equal");
|
||||
fs::write(&b, unknown(square())).unwrap();
|
||||
assert_eq!(command(&[])["status"], "incomplete");
|
||||
fs::write(
|
||||
&b,
|
||||
layout(&[
|
||||
("CHIP", vec![square()]),
|
||||
("legend", vec![label((900, 7), "KLAMATH_LAYER_NAMES_V2")]),
|
||||
]),
|
||||
)
|
||||
.unwrap();
|
||||
for flags in [
|
||||
&["--layer", "1/0"][..],
|
||||
&["--top", "CHIP"],
|
||||
&["--cell", "CHIP", "--layer", "1/0"],
|
||||
] {
|
||||
let report = command(flags);
|
||||
assert_eq!(report["status"], "incomplete");
|
||||
assert_eq!(report["exit_code"], 2);
|
||||
assert_eq!(
|
||||
report["diagnostics"][0]["code"],
|
||||
"unsupported_metadata_version"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue