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 6d87b07 commit adcac90
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions compiler/base/orchestrator/src/coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2846,6 +2846,14 @@ 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,8 +2862,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)
.map(|v| v.expect("The operation timed out"))
tokio::time::timeout(*TIMEOUT, self).map(|v| v.expect("The operation timed out"))
}
}

Expand Down

0 comments on commit adcac90

Please sign in to comment.