mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
Improve locality of error messages & ExampleBuild + Qemu commands, and
indicate failure earlier
This commit is contained in:
parent
1c84ccf6e4
commit
deeb3877f0
2 changed files with 42 additions and 42 deletions
|
@ -312,19 +312,16 @@ pub fn qemu_run_examples<'c>(
|
||||||
let target = backend.to_target();
|
let target = backend.to_target();
|
||||||
let features = Some(target.and_features(backend.to_rtic_feature()));
|
let features = Some(target.and_features(backend.to_rtic_feature()));
|
||||||
|
|
||||||
let build = examples_iter(examples).map(|example| {
|
examples_iter(examples)
|
||||||
|
.flat_map(|example| {
|
||||||
let cmd_build = CargoCommand::ExampleBuild {
|
let cmd_build = CargoCommand::ExampleBuild {
|
||||||
// We need to be in the correct
|
|
||||||
cargoarg: &None,
|
cargoarg: &None,
|
||||||
example,
|
example,
|
||||||
target,
|
target,
|
||||||
features: features.clone(),
|
features: features.clone(),
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
};
|
};
|
||||||
(globals, cmd_build, overwrite)
|
|
||||||
});
|
|
||||||
|
|
||||||
let run = examples_iter(examples).map(|example| {
|
|
||||||
let cmd_qemu = CargoCommand::Qemu {
|
let cmd_qemu = CargoCommand::Qemu {
|
||||||
cargoarg,
|
cargoarg,
|
||||||
example,
|
example,
|
||||||
|
@ -332,10 +329,19 @@ pub fn qemu_run_examples<'c>(
|
||||||
features: features.clone(),
|
features: features.clone(),
|
||||||
mode: BuildMode::Release,
|
mode: BuildMode::Release,
|
||||||
};
|
};
|
||||||
(globals, cmd_qemu, overwrite)
|
|
||||||
});
|
|
||||||
|
|
||||||
build.chain(run).run_and_coalesce()
|
#[cfg(not(feature = "rayon"))]
|
||||||
|
{
|
||||||
|
[cmd_build, cmd_qemu].into_iter()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rayon")]
|
||||||
|
{
|
||||||
|
[cmd_build, cmd_qemu].into_par_iter()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.map(|cmd| (globals, cmd, overwrite))
|
||||||
|
.run_and_coalesce()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check the binary sizes of examples
|
/// Check the binary sizes of examples
|
||||||
|
|
|
@ -765,6 +765,10 @@ pub fn run_command(command: &CargoCommand, stderr_mode: OutputMode) -> anyhow::R
|
||||||
log::info!("\n{}", stdout);
|
log::info!("\n{}", stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !exit_status.success() {
|
||||||
|
log::error!("❌ Command failed. Run to completion for the summary.");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(RunResult {
|
Ok(RunResult {
|
||||||
exit_status,
|
exit_status,
|
||||||
stdout,
|
stdout,
|
||||||
|
@ -825,32 +829,19 @@ pub fn handle_results(globals: &Globals, results: Vec<FinalRunResult>) -> Result
|
||||||
});
|
});
|
||||||
|
|
||||||
let log_stdout_stderr = |level: Level| {
|
let log_stdout_stderr = |level: Level| {
|
||||||
move |(command, stdout, stderr): (&CargoCommand, &String, &String)| {
|
move |(cmd, stdout, stderr): (&CargoCommand, &String, &String)| {
|
||||||
|
let cmd = cmd.as_cmd_string();
|
||||||
if !stdout.is_empty() && !stderr.is_empty() {
|
if !stdout.is_empty() && !stderr.is_empty() {
|
||||||
log::log!(
|
log::log!(level, "\n{cmd}\nStdout:\n{stdout}\nStderr:\n{stderr}");
|
||||||
level,
|
|
||||||
"Output for \"{command}\"\nStdout:\n{stdout}\nStderr:\n{stderr}"
|
|
||||||
);
|
|
||||||
} else if !stdout.is_empty() {
|
} else if !stdout.is_empty() {
|
||||||
log::log!(
|
log::log!(level, "\n{cmd}\nStdout:\n{}", stdout.trim_end());
|
||||||
level,
|
|
||||||
"Output for \"{command}\":\nStdout:\n{}",
|
|
||||||
stdout.trim_end()
|
|
||||||
);
|
|
||||||
} else if !stderr.is_empty() {
|
} else if !stderr.is_empty() {
|
||||||
log::log!(
|
log::log!(level, "\n{cmd}\nStderr:\n{}", stderr.trim_end());
|
||||||
level,
|
|
||||||
"Output for \"{command}\"\nStderr:\n{}",
|
|
||||||
stderr.trim_end()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
successes.clone().for_each(log_stdout_stderr(Level::Debug));
|
successes.for_each(|(cmd, stdout, stderr)| {
|
||||||
errors.clone().for_each(log_stdout_stderr(Level::Error));
|
|
||||||
|
|
||||||
successes.for_each(|(cmd, _, _)| {
|
|
||||||
let path = if let Some(dir) = cmd.chdir() {
|
let path = if let Some(dir) = cmd.chdir() {
|
||||||
let path = dir.as_os_str().to_str().unwrap_or("Not displayable");
|
let path = dir.as_os_str().to_str().unwrap_or("Not displayable");
|
||||||
format!(" (in {path}")
|
format!(" (in {path}")
|
||||||
|
@ -863,15 +854,18 @@ pub fn handle_results(globals: &Globals, results: Vec<FinalRunResult>) -> Result
|
||||||
} else {
|
} else {
|
||||||
info!("✅ Success: {cmd}{path}");
|
info!("✅ Success: {cmd}{path}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_stdout_stderr(Level::Debug)((cmd, stdout, stderr));
|
||||||
});
|
});
|
||||||
|
|
||||||
errors.clone().for_each(|(cmd, _, _)| {
|
errors.clone().for_each(|(cmd, stdout, stderr)| {
|
||||||
if let Some(dir) = cmd.chdir() {
|
if let Some(dir) = cmd.chdir() {
|
||||||
let path = dir.as_os_str().to_str().unwrap_or("Not displayable");
|
let path = dir.as_os_str().to_str().unwrap_or("Not displayable");
|
||||||
error!("❌ Failed: {cmd} (in {path}) \n {}", cmd.as_cmd_string());
|
error!("❌ Failed: {cmd} (in {path}) \n {}", cmd.as_cmd_string());
|
||||||
} else {
|
} else {
|
||||||
error!("❌ Failed: {cmd}\n {}", cmd.as_cmd_string());
|
error!("❌ Failed: {cmd}\n {}", cmd.as_cmd_string());
|
||||||
}
|
}
|
||||||
|
log_stdout_stderr(Level::Error)((cmd, stdout, stderr));
|
||||||
});
|
});
|
||||||
|
|
||||||
command_errors
|
command_errors
|
||||||
|
|
Loading…
Reference in a new issue