Skip to content

Commit

Permalink
bugfix: Try to fix Mill flaky test
Browse files Browse the repository at this point in the history
Looks like Mill will sometimes throw an exception which is forwarded to Metals and causes tests to hange, this should make the tests stop hanging and make retries work.
  • Loading branch information
tgodzik committed Sep 29, 2023
1 parent b511ce9 commit 9417374
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import tests.MillServerInitializer
class MillServerCodeLensSuite
extends BaseCodeLensLspSuite("mill-server-lenses", MillServerInitializer) {

override def munitTimeout: Duration = Duration("4min")

test("run-mill-lens", maxRetry = 3) {
cleanWorkspace()
writeLayout(
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/src/main/scala/tests/TestingServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,7 @@ final case class TestingServer(
filename: String,
maxRetries: Int = 4,
): Future[List[l.CodeLens]] = {
Debug.printEnclosing(filename)
val path = toPath(filename)
val uri = path.toURI.toString
val params = new CodeLensParams(new TextDocumentIdentifier(uri))
Expand All @@ -1050,7 +1051,12 @@ final case class TestingServer(
val handler = { refreshCount: Int =>
if (refreshCount > 0)
for {
lenses <- fullServer.codeLens(params).asScala.map(_.asScala)
lenses <- fullServer
.codeLens(params)
.asScala
.map(_.asScala)
.withTimeout(10, TimeUnit.SECONDS)
.recover(_ => Nil)
} {
if (lenses.nonEmpty) codeLenses.trySuccess(lenses.toList)
else if (retries > 0) {
Expand Down

0 comments on commit 9417374

Please sign in to comment.