Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows resource startup timeout to be configured #491

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pro-tip : you can use sys.props (which gives you a scala map of the available system properties)

.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