From b1c385682289d66c88d451af3ba24fbc9057c960 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Fri, 18 Oct 2024 11:18:25 +0200 Subject: [PATCH] improvement: Retry code actions detection for Scala CLI I added it in a previous PR, but must have lost it during a rebase. --- .../codeactions/BaseCodeActionLspSuite.scala | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/unit/src/main/scala/tests/codeactions/BaseCodeActionLspSuite.scala b/tests/unit/src/main/scala/tests/codeactions/BaseCodeActionLspSuite.scala index 3727112ba29..bd2c2d04958 100644 --- a/tests/unit/src/main/scala/tests/codeactions/BaseCodeActionLspSuite.scala +++ b/tests/unit/src/main/scala/tests/codeactions/BaseCodeActionLspSuite.scala @@ -126,6 +126,24 @@ abstract class BaseCodeActionLspSuite( if (renamePath.nonEmpty) input.replace("<<", "").replace(">>", "") else expectedCode + def assertCodeAction(retry: Int): Future[List[CodeAction]] = { + server + .assertCodeAction( + path, + changeFile(input), + expectedActions, + kind, + filterAction = filterAction, + ) + .recoverWith { + case _: Throwable if retry > 0 => + Thread.sleep(2000) + assertCodeAction(retry - 1) + case _: Throwable if expectError => + Future.successful(Nil) + } + } + test(name) { assume(assumeFunc()) cleanWorkspace() @@ -142,18 +160,7 @@ abstract class BaseCodeActionLspSuite( path, changeFile(input).replace("<<", "").replace(">>", ""), ) - codeActions <- - server - .assertCodeAction( - path, - changeFile(input), - expectedActions, - kind, - filterAction = filterAction, - ) - .recover { - case _: Throwable if expectError => Nil - } + codeActions <- assertCodeAction(retryAction) _ <- client.applyCodeAction(selectedActionIndex, codeActions, server) _ <- server.didSave(newPath) { _ => if (newPath != path)