From a97d3f4e81d839849dd9c156f7cb81d6d54868f4 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 4 Dec 2024 15:52:27 +0000 Subject: [PATCH] Make `Errored` debug rendering readable --- src/test_result.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test_result.rs b/src/test_result.rs index 329e593c..ee90166c 100644 --- a/src/test_result.rs +++ b/src/test_result.rs @@ -1,6 +1,7 @@ //! Various data structures used for carrying information about test success or failure use crate::{status_emitter::TestStatus, AbortCheck, Error}; +use bstr::ByteSlice; use color_eyre::eyre::Result; /// The possible non-failure results a single test can have. @@ -16,7 +17,6 @@ pub enum TestOk { pub type TestResult = Result; /// Information about a test failure. -#[derive(Debug)] pub struct Errored { /// Command that failed pub(crate) command: String, @@ -28,6 +28,16 @@ pub struct Errored { pub(crate) stdout: Vec, } +impl std::fmt::Debug for Errored { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + writeln!(f, "command: {}", self.command)?; + writeln!(f, "errors: {:#?}", self.errors)?; + writeln!(f, "stderr: {}", self.stderr.to_str_lossy())?; + writeln!(f, "stdout: {}", self.stdout.to_str_lossy())?; + Ok(()) + } +} + impl Errored { /// If no command was executed for this error, use a message instead. pub fn new(errors: Vec, message: &str) -> Self {