Skip to content

Commit

Permalink
Merge pull request #3879 from kpodsiad/fix/munit-te-warning
Browse files Browse the repository at this point in the history
fix: don't show MUnit warning for the Test Explorer when not necessary
  • Loading branch information
dos65 authored Apr 28, 2022
2 parents 8272e18 + ef3b655 commit b3a3816
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,12 @@ case class MillBuildTool(userConfig: () => UserConfiguration)
}
}

override val buildServerName: Option[String] = Some("mill-bsp")
override val buildServerName: Option[String] = Some(MillBuildTool.name)
}

object MillBuildTool {
val name: String = "mill-bsp"

def isMillRelatedPath(
path: AbsolutePath
): Boolean = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import scala.concurrent.Promise
import scala.reflect.ClassTag
import scala.util.Try

import scala.meta.internal.builds.MillBuildTool
import scala.meta.internal.builds.SbtBuildTool
import scala.meta.internal.metals.MetalsEnrichments._
import scala.meta.internal.pc.InterruptException
Expand Down Expand Up @@ -67,6 +68,8 @@ class BuildServerConnection private (

def isSbt: Boolean = name == SbtBuildTool.name

def isMill: Boolean = name == MillBuildTool.name

// although hasDebug is already available in BSP capabilities
// see https://github.com/build-server-protocol/build-server-protocol/pull/161
// most of the bsp servers such as bloop and sbt don't support it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,32 @@ class ProblemResolver(
case Right(_) => None
}

// 1.0.0-M3 or higher is valid
def outdatedMunitInterface =
if (!isTestExplorerProvider() || scalaTarget.isSbt) None
/**
* MUnit 1.0.0-M3 or higher is capable of running single tests
* Do not show warning when:
* - build server doesn't return test framework name - without it Metals isn't able to discover single tests
* - build target is a sbt one
* - client doesn't implement Test Explorer
*/
def outdatedMunitInterface = {
def returnTestFrameworkName =
currentBuildServer()
.map(_.main)
.forall(conn =>
// https://github.com/sbt/sbt/pull/6830 will be available from 1.7.0
if (conn.isSbt) SemVer.isCompatibleVersion("1.7.0", conn.version)
// https://github.com/com-lihaoyi/mill/pull/1755 should be available from 0.10.4
else if (conn.isMill)
SemVer.isCompatibleVersion("0.10.4", conn.version)
else true
)

val shouldNotDisplay =
!isTestExplorerProvider() ||
scalaTarget.isSbt ||
!returnTestFrameworkName

if (shouldNotDisplay) None
else {
def isInvalid(
major: Int,
Expand All @@ -249,6 +272,7 @@ class ProblemResolver(
OutdatedMunitInterfaceVersion
}
}
}

def outdatedJunitInterface =
if (!isTestExplorerProvider() || scalaTarget.isSbt) None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ case object OutdatedJunitInterfaceVersion extends ScalaProblem {

case object OutdatedMunitInterfaceVersion extends ScalaProblem {
override def message: String =
"Test Explorer will not work properly with this version of munit, please update it to at least org.scalameta.munit.1.0.0-M3"
"Running single tests in Test Explorer will not work properly with this version of munit, please update it to at least org.scalameta.munit.1.0.0-M3"
}

case class MissingJdkSources(candidates: List[AbsolutePath])
Expand Down

0 comments on commit b3a3816

Please sign in to comment.