Skip to content

Commit

Permalink
[nextest-runner] on exec fail, stash error into stderr
Browse files Browse the repository at this point in the history
A bit of a hack but a thoughtful one.
  • Loading branch information
sunshowers committed Sep 25, 2023
1 parent bf14e82 commit 55f7f2a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nextest-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cargo_metadata = "0.17.0"
cfg-if = "1.0.0"
chrono = "0.4.31"
debug-ignore = "1.0.5"
display-error-chain = "0.2.0"
either = "1.9.0"
futures = "0.3.28"
guppy = "0.17.1"
Expand Down
25 changes: 16 additions & 9 deletions nextest-runner/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ use crate::{
};
use async_scoped::TokioScope;
use bytes::Bytes;
use display_error_chain::DisplayErrorChain;
use future_queue::StreamExt;
use futures::{future::try_join, prelude::*};
use nextest_metadata::{FilterMatch, MismatchReason};
use rand::{distributions::OpenClosed01, thread_rng, Rng};
use std::{
convert::Infallible,
fmt::Write,
marker::PhantomData,
num::NonZeroUsize,
process::Stdio,
Expand Down Expand Up @@ -628,15 +630,20 @@ impl<'a> TestRunnerInner<'a> {
.await
{
Ok(run_status) => run_status,
Err(_) => InternalExecuteStatus {
// TODO: can we return more information in stdout/stderr? investigate this
stdout: Bytes::new(),
stderr: Bytes::new(),
result: ExecutionResult::ExecFail,
stopwatch_end: stopwatch.end(),
is_slow: false,
delay_before_start,
},
Err(error) => {
// Put the error chain inside stderr.
let mut stderr = bytes::BytesMut::new();
writeln!(&mut stderr, "{}", DisplayErrorChain::new(error)).unwrap();

InternalExecuteStatus {
stdout: Bytes::new(),
stderr: stderr.freeze(),
result: ExecutionResult::ExecFail,
stopwatch_end: stopwatch.end(),
is_slow: false,
delay_before_start,
}
}
}
}

Expand Down

0 comments on commit 55f7f2a

Please sign in to comment.