Skip to content

Commit b78492f

Browse files
committed
Fold long undefined-symbol reports with <details>/<summary>
The --details Markdown report of ipk-verify lists every undefined symbol of a failing native binary as a bullet, which can run to dozens or hundreds of entries and make the report unwieldy in CI/PR comments. Collapse the undefined-symbol list into a <details>/<summary> block when it has more than 10 entries, and only for Markdown output. Terminal and Plain output keep the plain bullet list, where raw HTML tags would just be noise. Missing-library bullets stay inline. To do this, thread the OutputFormat through print_component_details into print_bin_verify_details. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PfjeD1nBEtfapZGVJ1U9am
1 parent 601450c commit b78492f

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

packages/ipk-verify/src/main.rs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ fn main() {
130130
print_component_details(
131131
results.iter().map(|(fw, res)| (*fw, &res.app)).collect(),
132132
&mut output,
133+
&format,
133134
)
134135
.unwrap();
135136
}
@@ -158,6 +159,7 @@ fn main() {
158159
.map(|(fw, res)| (*fw, res.services.get(idx).unwrap()))
159160
.collect(),
160161
&mut output,
162+
&format,
161163
)
162164
.unwrap();
163165
}
@@ -222,6 +224,7 @@ fn print_component_summary(
222224
fn print_component_details(
223225
results: Vec<(&Firmware, &ComponentVerifyResult)>,
224226
out: &mut Box<dyn ReportOutput>,
227+
out_fmt: &OutputFormat,
225228
) -> Result<bool, Error> {
226229
let (_, result) = *results.first().unwrap();
227230
if result.detection.is_some() {
@@ -236,7 +239,7 @@ fn print_component_details(
236239
for (fw, result) in &results {
237240
if let ComponentBinVerifyResult::Failed(result) = &result.exe {
238241
out.h5(&format!("On {}", fw.info))?;
239-
print_bin_verify_details(result, out)?;
242+
print_bin_verify_details(result, out, out_fmt)?;
240243
out.write_fmt(format_args!("\n"))?;
241244
}
242245
}
@@ -257,24 +260,43 @@ fn print_component_details(
257260
for (fw, result) in &results {
258261
if let ComponentBinVerifyResult::Failed(result) = &result.libs.get(index).unwrap().1 {
259262
out.h5(&format!("On {}", fw.info))?;
260-
print_bin_verify_details(result, out)?;
263+
print_bin_verify_details(result, out, out_fmt)?;
261264
out.write_fmt(format_args!("\n"))?;
262265
}
263266
}
264267
}
265268
return Ok(false);
266269
}
267270

271+
/// A long list of undefined symbols is folded into a collapsible `<details>`
272+
/// block rather than emitted inline.
273+
const SYMBOL_FOLD_THRESHOLD: usize = 10;
274+
268275
fn print_bin_verify_details(
269276
result: &BinVerifyResult,
270277
out: &mut Box<dyn ReportOutput>,
278+
out_fmt: &OutputFormat,
271279
) -> Result<(), Error> {
272280
for lib in &result.missing_lib {
273281
out.write_fmt(format_args!("* Library {lib} is missing\n"))?;
274282
}
283+
// Collapse a long symbol list behind a <details>/<summary> so the report
284+
// stays scannable. GitHub renders raw HTML in Markdown; other formats keep
285+
// the plain bullet list (raw tags would be noise there).
286+
let fold = *out_fmt == OutputFormat::Markdown
287+
&& result.undefined_sym.len() > SYMBOL_FOLD_THRESHOLD;
288+
if fold {
289+
out.write_fmt(format_args!(
290+
"<details>\n<summary>{} undefined symbols</summary>\n\n",
291+
result.undefined_sym.len()
292+
))?;
293+
}
275294
for sym in &result.undefined_sym {
276295
out.write_fmt(format_args!("* Symbol {sym} is undefined\n"))?;
277296
}
297+
if fold {
298+
out.write_fmt(format_args!("</details>\n"))?;
299+
}
278300
return Ok(());
279301
}
280302

0 commit comments

Comments
 (0)