Skip to content

Commit

Permalink
Merge pull request #491 from mcgizzle/issue-489/configurable-startup-…
Browse files Browse the repository at this point in the history
…timeout

Allows resource startup timeout to be configured
  • Loading branch information
Baccata authored Mar 1, 2022
2 parents 7ff2d8c + ff06057 commit b563391
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 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,14 @@ trait RunnerCompat[F[_]] { self: sbt.testing.Runner =>
gate)
stillRunning.set(sbtTasks.size)

val maybeTimeout: Option[FiniteDuration] =
sys.props.get("weaver.test.startupTimeout")
.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 b563391

Please sign in to comment.