Skip to content

Commit

Permalink
Allows resource startup timeout to be configured
Browse files Browse the repository at this point in the history
Configurable by a new system property
  • Loading branch information
mcgizzle committed Feb 25, 2022
1 parent 7fe40e2 commit a2ec5cc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/framework/src-jvm/RunnerCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import java.util.concurrent.atomic.{ AtomicBoolean, AtomicInteger }

import scala.concurrent.duration._
import scala.concurrent.{ ExecutionContext, Promise }
import scala.util.Try

import cats.data.Chain
import cats.effect.{ Sync, _ }
Expand Down Expand Up @@ -119,9 +120,15 @@ trait RunnerCompat[F[_]] { self: sbt.testing.Runner =>
gate)
stillRunning.set(sbtTasks.size)

val maybeTimeout: Option[FiniteDuration] = Try(System.getProperty("weaver.test.startupTimeout"))
.toOption
.flatMap(Option(_))
.flatMap(timeoutString => Try(timeoutString.toInt).toOption)
.map(_.seconds)

// Waiting for the resources to be allocated.
scala.concurrent.blocking {
scala.concurrent.Await.result(gate.future, 120.second)
scala.concurrent.Await.result(gate.future, maybeTimeout.getOrElse(120.second))
}
sbtTasks.toArray
}
Expand Down

0 comments on commit a2ec5cc

Please sign in to comment.