Fix config pickup behaviour so that both examples and usage-examples build

correctly
This commit is contained in:
datdenkikniet 2023-04-15 21:16:45 +02:00
parent 859cd418f0
commit d838286de6
4 changed files with 39 additions and 15 deletions

View file

@ -383,6 +383,7 @@ impl<'a> CargoCommand<'a> {
if let Some(cargoarg) = cargoarg {
args.extend_from_slice(&[cargoarg]);
}
args.extend_from_slice(&[
self.command(),
"--example",
@ -407,9 +408,15 @@ impl<'a> CargoCommand<'a> {
mode,
} => {
let mut args = vec!["+nightly"];
if let Some(cargoarg) = cargoarg {
args.extend_from_slice(&[cargoarg]);
}
// We need to be in the `rtic` directory to pick up
// the correct .cargo/config.toml file
args.extend_from_slice(&["-Z", "unstable-options", "-C", "rtic"]);
args.extend_from_slice(&[
self.command(),
"--example",
@ -641,6 +648,11 @@ impl<'a> CargoCommand<'a> {
if let Some(cargoarg) = cargoarg {
args.extend_from_slice(&[cargoarg]);
}
// We need to be in the `rtic` directory to pick up
// the correct .cargo/config.toml file
args.extend_from_slice(&["-Z", "unstable-options", "-C", "rtic"]);
args.extend_from_slice(&[
self.command(),
"--example",
@ -694,6 +706,13 @@ impl<'a> CargoCommand<'a> {
_ => None,
}
}
pub fn print_stdout_intermediate(&self) -> bool {
match self {
Self::ExampleSize { .. } => true,
_ => false,
}
}
}
impl BuildMode {
@ -737,6 +756,10 @@ pub fn run_command(command: &CargoCommand, stderr_mode: OutputMode) -> anyhow::R
let stderr = String::from_utf8(result.stderr).unwrap_or("Not displayable".into());
let stdout = String::from_utf8(result.stdout).unwrap_or("Not displayable".into());
if command.print_stdout_intermediate() && exit_status.success() {
log::info!("\n{}", stdout);
}
Ok(RunResult {
exit_status,
stdout,
@ -850,9 +873,8 @@ pub fn handle_results(globals: &Globals, results: Vec<FinalRunResult>) -> Result
.clone()
.for_each(|(cmd, error)| error!("❌ Failed: {cmd}\n {}\n{error}", cmd.as_cmd_string()));
let ecount = errors.count();
let cecount = command_errors.count();
if ecount != 0 || cecount != 0 {
let ecount = errors.count() + command_errors.count();
if ecount != 0 {
log::error!("{ecount} commands failed.");
Err(())
} else {

View file

@ -100,8 +100,8 @@ impl fmt::Display for TestRunError {
TestRunError::CommandError(e) => {
write!(
f,
"Command failed with exit status {}: {}",
e.exit_status, e.stdout
"Command failed with exit status {}: {} {}",
e.exit_status, e.stdout, e.stderr
)
}
TestRunError::PathConversionError(p) => {