Skip to content

Commit

Permalink
Add an environment variable to control test timeout (#683)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxvanyang committed Aug 1, 2024
1 parent e1c014a commit 090ed52
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,19 @@ where
|| {
let mut diagnostics = Vec::new();

const TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
let default = if std::env::var_os("CI").is_some() {
60
} else {
30
};

let timeout = std::env::var("CARGO_DENY_TEST_TIMEOUT_SECS")
.ok()
.and_then(|ts| ts.parse().ok())
.unwrap_or(default);
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 +318,7 @@ where
}
}
recv(trx) -> _ => {
anyhow::bail!("Timed out after {TIMEOUT:?}");
anyhow::bail!("Timed out after {timeout:?}");
}
}
}
Expand Down

0 comments on commit 090ed52

Please sign in to comment.