Add some QoL to run_command

This commit is contained in:
datdenkikniet 2023-04-15 00:09:50 +02:00
parent f741475a3f
commit fa92d8abe7
3 changed files with 24 additions and 18 deletions

View file

@ -44,6 +44,7 @@ const DEFAULT_FEATURES: &str = "test-critical-section";
#[derive(Debug, Clone)]
pub struct RunResult {
exit_status: ExitStatus,
full_command: String,
stdout: String,
stderr: String,
}
@ -329,9 +330,12 @@ fn command_parser(command: &CargoCommand, overwrite: bool) -> anyhow::Result<()>
| CargoCommand::Book { .. }
| CargoCommand::ExampleSize { .. } => {
let cargo_result = run_command(command)?;
let command = cargo_result.full_command;
if let Some(exit_code) = cargo_result.exit_status.code() {
if exit_code != exitcode::OK {
error!("Exit code from command: {exit_code}");
error!("Command {command} failed.");
error!("Exit code: {exit_code}");
if !cargo_result.stdout.is_empty() {
info!("{}", cargo_result.stdout);
}