Add a helper function for outputting details
This commit is contained in:
parent
634a11ef48
commit
232be8614d
2 changed files with 18 additions and 9 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use crate::metrics;
|
||||
use crate::metrics::{JobMetrics, JobName, get_test_suites};
|
||||
use crate::utils::pluralize;
|
||||
use crate::utils::{output_details, pluralize};
|
||||
use build_helper::metrics::{
|
||||
BuildStep, JsonRoot, TestOutcome, TestSuite, TestSuiteMetadata, format_build_steps,
|
||||
};
|
||||
|
|
@ -19,14 +19,9 @@ fn record_bootstrap_step_durations(metrics: &JsonRoot) {
|
|||
let step = BuildStep::from_invocation(invocation);
|
||||
let table = format_build_steps(&step);
|
||||
eprintln!("Step `{}`\n{table}\n", invocation.cmdline);
|
||||
println!(
|
||||
r"<details>
|
||||
<summary>{}</summary>
|
||||
<pre><code>{table}</code></pre>
|
||||
</details>
|
||||
",
|
||||
invocation.cmdline
|
||||
);
|
||||
output_details(&invocation.cmdline, || {
|
||||
println!("<pre><code>{table}</code></pre>");
|
||||
});
|
||||
}
|
||||
eprintln!("Recorded {} bootstrap invocation(s)", metrics.invocations.len());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,3 +13,17 @@ pub fn read_to_string<P: AsRef<Path>>(path: P) -> anyhow::Result<String> {
|
|||
pub fn pluralize(text: &str, count: usize) -> String {
|
||||
if count == 1 { text.to_string() } else { format!("{text}s") }
|
||||
}
|
||||
|
||||
/// Outputs a HTML <details> section with the provided summary.
|
||||
/// Output printed by `func` will be contained within the section.
|
||||
pub fn output_details<F>(summary: &str, func: F)
|
||||
where
|
||||
F: FnOnce(),
|
||||
{
|
||||
println!(
|
||||
r"<details>
|
||||
<summary>{summary}</summary>"
|
||||
);
|
||||
func();
|
||||
println!("</details>\n");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue