add context to command failures (#466)

Fixes #465
This commit is contained in:
bmc-msft
2021-01-26 16:29:59 -05:00
committed by GitHub
parent de67c9db63
commit cfcf493a23
10 changed files with 78 additions and 32 deletions

View File

@ -126,7 +126,7 @@ impl CoverageRecorder {
cmd.env(k, v);
}
let child = cmd.spawn()?;
let child = cmd.spawn().context("gdb failed to start")?;
Ok(child)
}
@ -163,7 +163,7 @@ impl CoverageRecorder {
cmd.env(k, v);
}
let child = cmd.spawn()?;
let child = cmd.spawn().context("cdb.exe failed to start")?;
Ok(child)
}

View File

@ -6,7 +6,7 @@ use crate::tasks::{
heartbeat::*,
utils::{self, default_bool_true},
};
use anyhow::Result;
use anyhow::{Context, Result};
use futures::stream::StreamExt;
use onefuzz::{
expand::Expand,
@ -150,7 +150,7 @@ impl GeneratorTask {
output_dir: impl AsRef<Path>,
) -> Result<()> {
utils::reset_tmp_dir(&output_dir).await?;
let mut generator = {
let (mut generator, generator_path) = {
let mut expand = Expand::new();
expand
.generated_inputs(&output_dir)
@ -179,11 +179,13 @@ impl GeneratorTask {
for (k, v) in &self.config.generator_env {
generator.env(k, expand.evaluate_value(v)?);
}
generator
(generator, generator_path)
};
info!("Generating test cases with {:?}", generator);
let output = generator.spawn()?;
let output = generator
.spawn()
.with_context(|| format!("generator failed to start: {}", generator_path))?;
monitor_process(output, "generator".to_string(), true, None).await?;
Ok(())

View File

@ -9,7 +9,7 @@ use crate::tasks::{
stats::common::{monitor_stats, StatsFormat},
utils::CheckNotify,
};
use anyhow::{Error, Result};
use anyhow::{Context, Error, Result};
use onefuzz::{
expand::Expand,
fs::{has_files, set_executable, OwnedDir},
@ -213,7 +213,9 @@ async fn start_supervisor(
}
info!("starting supervisor '{:?}'", cmd);
let child = cmd.spawn()?;
let child = cmd
.spawn()
.with_context(|| format!("supervisor failed to start: {:?}", cmd))?;
Ok(child)
}