Skip to content

Commit

Permalink
Add an environment variable to control test timeout
Browse files Browse the repository at this point in the history
The environment variable name is `CARGO_DENY_TEST_TIMEOUT`, it should be
able to be parsed into `u64`, otherwise still use 30s as timeout by
default.
  • Loading branch information
jaxvanyang committed Aug 1, 2024
1 parent e1c014a commit 799cc92
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,13 @@ where
|| {
let mut diagnostics = Vec::new();

const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
let timeout = match std::env::var("CARGO_DENY_TEST_TIMEOUT") {
Ok(timeout) => timeout.parse().unwrap_or(30),
_ => 30,
};
let timeout = std::time::Duration::from_secs(timeout);

let trx = crossbeam::channel::after(TIMEOUT);
let trx = crossbeam::channel::after(timeout);
loop {
crossbeam::select! {
recv(rx) -> msg => {
Expand All @@ -308,7 +312,7 @@ where
}
}
recv(trx) -> _ => {
anyhow::bail!("Timed out after {TIMEOUT:?}");
anyhow::bail!("Timed out after {timeout:?}");
}
}
}
Expand Down

0 comments on commit 799cc92

Please sign in to comment.