Skip to content

Commit

Permalink
refactor: Don't try to download artifacts in ProblemResolverSuite
Browse files Browse the repository at this point in the history
The tests often timeout if coursier with retries is involved and besides mtags are not published aside from 2.13.x so this will always fail.
  • Loading branch information
tgodzik committed May 28, 2024
1 parent 99831af commit cd0f91a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/unit/src/main/scala/tests/BaseLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ abstract class BaseLspSuite(
protected def useVirtualDocuments = useVirtualDocs

protected def mtagsResolver: MtagsResolver =
new TestMtagsResolver
new TestMtagsResolver(checkCoursier = true)

override def afterAll(): Unit = {
if (server != null) {
Expand Down
15 changes: 9 additions & 6 deletions tests/unit/src/main/scala/tests/TestMtagsResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ import scala.meta.internal.metals.ScalaVersions
* For `unit` we don't publish mtags at all but there are some tests that trigger docker check.
* So for these cases, do fallback on previous mechanic by checking declared supported versions.
*/
class TestMtagsResolver extends MtagsResolver {
class TestMtagsResolver(checkCoursier: Boolean) extends MtagsResolver {

val default: MtagsResolver = MtagsResolver.default()

private def localCheck(scalaVersion: String) =
if (ScalaVersions.isSupportedAtReleaseMomentScalaVersion(scalaVersion))
Some(MtagsBinaries.BuildIn)
else None

override def resolve(scalaVersion: String): Option[MtagsBinaries] = {
default.resolve(scalaVersion).orElse {
if (ScalaVersions.isSupportedAtReleaseMomentScalaVersion(scalaVersion))
Some(MtagsBinaries.BuildIn)
else None
}
if (checkCoursier)
default.resolve(scalaVersion).orElse(localCheck(scalaVersion))
else localCheck(scalaVersion)
}

override def isSupportedInOlderVersion(version: String): Boolean =
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/src/main/scala/tests/TestScala3Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object TestScala3Compiler {
def compiler(name: String, input: InputProperties)(implicit
ec: ExecutionContext
): Option[PresentationCompiler] = {
val resolver = new TestMtagsResolver()
val resolver = new TestMtagsResolver(checkCoursier = true)
resolver.resolve(V.scala3) match {
case Some(mtags: MtagsBinaries.Artifacts) =>
val time = new FakeTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ class ProblemResolverSuite extends FunSuite {

val problemResolver = new ProblemResolver(
AbsolutePath(workspace),
new TestMtagsResolver,
new TestMtagsResolver(checkCoursier = false),
() => None,
() => javaHome,
() => isTestExplorerProvider,
Expand Down

0 comments on commit cd0f91a

Please sign in to comment.