Skip to main content

momus_core/
lib.rs

1pub mod ast;
2pub mod config;
3pub mod deps;
4pub mod engine;
5pub mod junit;
6pub mod leak;
7pub mod transport;
8
9/// Write a serializable report as pretty-printed JSON to `{output_dir}/{filename}`.
10///
11/// Creates the output directory if it doesn't exist.
12pub fn write_report_json<T: serde::Serialize>(
13    output_dir: &std::path::Path,
14    filename: &str,
15    report: &T,
16) -> anyhow::Result<()> {
17    std::fs::create_dir_all(output_dir)?;
18    let path = output_dir.join(filename);
19    let json = serde_json::to_string_pretty(report)?;
20    std::fs::write(&path, json)?;
21    tracing::info!("Report written to: {}", path.display());
22    Ok(())
23}