about summary refs log tree commit diff
path: root/library/test/src/formatters/json.rs
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-08-04 16:06:56 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2025-08-04 16:06:56 +0200
commit75e20afb822e628b66fc4f45d567d3db22c0f82d (patch)
treeff1a344532533d0e77c852ab07a23584e2a14e69 /library/test/src/formatters/json.rs
parente1b9081e699065badfc1a9419ec9566e5c8615c4 (diff)
downloadrust-75e20afb822e628b66fc4f45d567d3db22c0f82d.tar.gz
rust-75e20afb822e628b66fc4f45d567d3db22c0f82d.zip
Add new `test::print_merged_doctests_times` used by rustdoc to display more detailed time information and add new `OutputFormatter::write_merged_doctests_times` method to handle it
Diffstat (limited to 'library/test/src/formatters/json.rs')
-rw-r--r--library/test/src/formatters/json.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/library/test/src/formatters/json.rs b/library/test/src/formatters/json.rs
index 92c1c0716f1..4a101f00d74 100644
--- a/library/test/src/formatters/json.rs
+++ b/library/test/src/formatters/json.rs
@@ -215,6 +215,17 @@ impl<T: Write> OutputFormatter for JsonFormatter<T> {
 
         Ok(state.failed == 0)
     }
+
+    fn write_merged_doctests_times(
+        &mut self,
+        total_time: f64,
+        compilation_time: f64,
+    ) -> io::Result<()> {
+        let newline = "\n";
+        self.writeln_message(&format!(
+            r#"{{ "type": "report", "total_time": {total_time}, "compilation_time": {compilation_time} }}{newline}"#,
+        ))
+    }
 }
 
 /// A formatting utility used to print strings with characters in need of escaping.