Merge PR #629: Make check --json list warning messages instead of a count (#526)

This commit is contained in:
aiongg
2026-10-22 02:34:30 +00:00
+12 -2
View File
@@ -141,7 +141,8 @@ pub struct FileReport {
pub path: String,
/// GridCraft couldn't open the file: its message.
pub error: Option<String>,
pub warnings: usize,
/// Import warnings, in the order the importer produced them.
pub warnings: Vec<String>,
pub calc: CalcReport,
pub round_trip: RoundTrip,
}
@@ -287,7 +288,7 @@ fn check_inner(path: &str, bytes: &[u8], opts: &Options) -> FileReport {
return report;
}
};
report.warnings = warnings.len();
report.warnings = warnings;
let mut fresh = cached.clone();
let mut calc = Calc::new();
calc.recalc_all(&mut fresh);
@@ -1600,6 +1601,15 @@ mod tests {
assert_eq!(package_of(&source), ["lost relationship madeUp"]);
}
#[test]
fn json_lists_warning_messages() {
let with = FileReport { path: "a.ods".into(), warnings: vec!["ODS data-only import".into()], ..Default::default() };
let without = FileReport { path: "b.xlsx".into(), ..Default::default() };
let v = report_json(&[with, without], &Options::default());
assert_eq!(v["files"][0]["warnings"], json!(["ODS data-only import"]));
assert_eq!(v["files"][1]["warnings"], json!([]));
}
#[test]
fn unopenable_files_are_reported() {
let r = check_bytes("broken.xlsx", b"PK\x03\x04 not really", &Options::default());