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

feat: add framework name to the test classes BSP request #1755

Merged
merged 3 commits into from
Apr 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 8 additions & 0 deletions bsp/src/mill/bsp/MillBuildServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import ch.epfl.scala.bsp4j.{
CompileProvider,
CompileResult,
DebugProvider,
DebugSessionAddress,
DebugSessionParams,
DependencyModule,
DependencyModulesItem,
DependencyModulesParams,
Expand Down Expand Up @@ -625,6 +627,12 @@ class MillBuildServer(
new CleanCacheResult(msg, cleaned)
}

override def debugSessionStart(debugParams: DebugSessionParams)
: CompletableFuture[DebugSessionAddress] =
completable(s"debugSessionStart ${debugParams}") { state =>
throw new NotImplementedError("debugSessionStart endpoint is not implemented")
}
Comment on lines +630 to +634
Copy link
Contributor Author

@kpodsiad kpodsiad Apr 22, 2022

Choose a reason for hiding this comment

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

There's a DebugProvider capability that is not set by the Mill so it's safe to throw an error here from the BSP server perspective.


def completableTasks[T: ClassTag, V](
hint: String,
targetIds: Seq[BuildTargetIdentifier],
Expand Down
7 changes: 4 additions & 3 deletions bsp/src/mill/bsp/MillScalaBuildServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,23 @@ trait MillScalaBuildServer extends ScalaBuildServer { this: MillBuildServer =>
val testFramework = m.testFramework()
val compResult = m.compile()

val classFingerprint: Agg[(Class[_], Fingerprint)] = Jvm.inprocess(
val (frameworkName, classFingerprint): (String, Agg[(Class[_], Fingerprint)]) = Jvm.inprocess(
classpath.map(_.path),
classLoaderOverrideSbtTesting = true,
isolated = true,
closeContextClassLoaderWhenDone = false,
cl => {
val framework = TestRunner.framework(testFramework)(cl)
TestRunner.discoverTests(
val discoveredTests = TestRunner.discoverTests(
cl,
framework,
Agg(compResult.classes.path)
)
(framework.name(), discoveredTests)
}
)
val classes = Seq.from(classFingerprint.map(classF => classF._1.getName.stripSuffix("$")))
new ScalaTestClassesItem(id, classes.asJava)
new ScalaTestClassesItem(id, classes.asJava, frameworkName)
}
case (id, _) => T.task {
// Not a test module, so no test classes
Expand Down
2 changes: 1 addition & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ object Deps {
val utest = ivy"com.lihaoyi::utest:0.7.11"
val windowsAnsi = ivy"io.github.alexarchambault.windows-ansi:windows-ansi:0.0.3"
val zinc = ivy"org.scala-sbt::zinc:1.6.1"
val bsp = ivy"ch.epfl.scala:bsp4j:2.0.0"
val bsp = ivy"ch.epfl.scala:bsp4j:2.1.0-M1"
val fansi = ivy"com.lihaoyi::fansi:0.3.1"
val jarjarabrams = ivy"com.eed3si9n.jarjarabrams::jarjar-abrams-core:1.8.1"
}
Expand Down