Skip to content

Commit

Permalink
Make the test timeout configurable from an environment variable
Browse files Browse the repository at this point in the history
These can be slower when running the amd64 Docker images on an arm64
host.
  • Loading branch information
shepmaster committed Nov 18, 2023
1 parent abe23c6 commit e68a3bf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/base/orchestrator/src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2846,6 +2846,11 @@ mod tests {
Ok(())
}

static TIMEOUT: Lazy<Duration> = Lazy::new(|| {
let millis = env::var("TESTS_TIMEOUT_MS").ok().and_then(|v| v.parse().ok()).unwrap_or(5000);
Duration::from_millis(millis)
});

trait TimeoutExt: Future + Sized {
#[allow(clippy::type_complexity)]
fn with_timeout(
Expand All @@ -2854,7 +2859,7 @@ mod tests {
tokio::time::Timeout<Self>,
fn(Result<Self::Output, tokio::time::error::Elapsed>) -> Self::Output,
> {
tokio::time::timeout(Duration::from_millis(5000), self)
tokio::time::timeout(*TIMEOUT, self)
.map(|v| v.expect("The operation timed out"))
}
}
Expand Down

0 comments on commit e68a3bf

Please sign in to comment.