diff --git a/xtask/src/cargo_commands.rs b/xtask/src/cargo_commands.rs index 9b07088c34..ead6eaa9a0 100644 --- a/xtask/src/cargo_commands.rs +++ b/xtask/src/cargo_commands.rs @@ -10,10 +10,11 @@ use rayon::prelude::*; use iters::*; +#[derive(Debug)] pub enum FinalRunResult<'c> { Success(CargoCommand<'c>, RunResult), Failed(CargoCommand<'c>, RunResult), - CommandError(anyhow::Error), + CommandError(CargoCommand<'c>, anyhow::Error), } fn run_and_convert<'a>( @@ -21,7 +22,8 @@ fn run_and_convert<'a>( ) -> FinalRunResult<'a> { // Run the command let result = command_parser(global, &command, overwrite); - match result { + + let output = match result { // If running the command succeeded without looking at any of the results, // log the data and see if the actual execution was succesfull too. Ok(result) => { @@ -32,8 +34,12 @@ fn run_and_convert<'a>( } } // If it didn't and some IO error occured, just panic - Err(e) => FinalRunResult::CommandError(e), - } + Err(e) => FinalRunResult::CommandError(command, e), + }; + + log::trace!("Final result: {output:?}"); + + output } pub trait CoalescingRunner<'c> { diff --git a/xtask/src/command.rs b/xtask/src/command.rs index 186836b201..93ea824551 100644 --- a/xtask/src/command.rs +++ b/xtask/src/command.rs @@ -774,7 +774,7 @@ pub fn run_successful(run: &RunResult, expected_output_file: &str) -> Result<(), pub fn handle_results(globals: &Globals, results: Vec) -> Result<(), ()> { let errors = results.iter().filter_map(|r| { if let FinalRunResult::Failed(c, r) = r { - Some((c, r)) + Some((c, &r.stdout, &r.stderr)) } else { None } @@ -782,16 +782,22 @@ pub fn handle_results(globals: &Globals, results: Vec) -> Result let successes = results.iter().filter_map(|r| { if let FinalRunResult::Success(c, r) = r { - Some((c, r)) + Some((c, &r.stdout, &r.stderr)) + } else { + None + } + }); + + let command_errors = results.iter().filter_map(|r| { + if let FinalRunResult::CommandError(c, e) = r { + Some((c, e)) } else { None } }); let log_stdout_stderr = |level: Level| { - move |(command, result): (&CargoCommand, &RunResult)| { - let stdout = &result.stdout; - let stderr = &result.stderr; + move |(command, stdout, stderr): (&CargoCommand, &String, &String)| { if !stdout.is_empty() && !stderr.is_empty() { log::log!( level, @@ -816,7 +822,7 @@ pub fn handle_results(globals: &Globals, results: Vec) -> Result successes.clone().for_each(log_stdout_stderr(Level::Debug)); errors.clone().for_each(log_stdout_stderr(Level::Error)); - successes.for_each(|(cmd, _)| { + successes.for_each(|(cmd, _, _)| { let path = if let Some(dir) = cmd.chdir() { let path = dir.as_os_str().to_str().unwrap_or("Not displayable"); format!(" (in {path}") @@ -831,7 +837,7 @@ pub fn handle_results(globals: &Globals, results: Vec) -> Result } }); - errors.clone().for_each(|(cmd, _)| { + errors.clone().for_each(|(cmd, _, _)| { if let Some(dir) = cmd.chdir() { let path = dir.as_os_str().to_str().unwrap_or("Not displayable"); error!("❌ Failed: (in {path}) {cmd}\n {}", cmd.as_cmd_string()); @@ -840,8 +846,13 @@ pub fn handle_results(globals: &Globals, results: Vec) -> Result } }); + command_errors + .clone() + .for_each(|(cmd, error)| error!("❌ Failed: {cmd}\n {}\n{error}", cmd.as_cmd_string())); + let ecount = errors.count(); - if ecount != 0 { + let cecount = command_errors.count(); + if ecount != 0 || cecount != 0 { log::error!("{ecount} commands failed."); Err(()) } else { diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 1cc01850dc..4cf6db8aae 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -324,9 +324,7 @@ fn command_parser( .map_err(TestRunError::PathConversionError)?; // cargo run <..> - info!("Running example: {example}"); let cargo_run_result = run_command(command, output_mode)?; - info!("{}", cargo_run_result.stdout); // Create a file for the expected output if it does not exist or mismatches if overwrite {