Skip to content

Commit

Permalink
Make Errored debug rendering readable
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Dec 4, 2024
1 parent bf517eb commit a97d3f4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/test_result.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -16,7 +17,6 @@ pub enum TestOk {
pub type TestResult = Result<TestOk, Errored>;

/// Information about a test failure.
#[derive(Debug)]
pub struct Errored {
/// Command that failed
pub(crate) command: String,
Expand All @@ -28,6 +28,16 @@ pub struct Errored {
pub(crate) stdout: Vec<u8>,
}

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<Error>, message: &str) -> Self {
Expand Down

0 comments on commit a97d3f4

Please sign in to comment.