-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
bleep list-tests <...projects>
command
also continue with warning if BSP wanted to test/compile a non-existing project
- Loading branch information
1 parent
37bb98e
commit 373b6f6
Showing
4 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package bleep | ||
package commands | ||
|
||
import bleep.internal.TransitiveProjects | ||
import bloop.rifle.BuildServer | ||
import ch.epfl.scala.bsp4j | ||
import ch.epfl.scala.bsp4j.ScalaTestClassesParams | ||
|
||
import scala.jdk.CollectionConverters.* | ||
|
||
case class ListTests(projects: Array[model.CrossProjectName]) extends BleepCommandRemote(watch = false) { | ||
|
||
override def watchableProjects(started: Started): TransitiveProjects = | ||
TransitiveProjects(started.build, projects) | ||
|
||
override def runWithServer(started: Started, bloop: BuildServer): Either[BleepException, Unit] = { | ||
val all: Iterator[(model.CrossProjectName, String)] = testsByCrossProject(started, bloop) | ||
|
||
all.toList.groupBy { case (pn, cls) => pn.name }.foreach { case (pn, tuples) => | ||
started.logger.info(s"${pn.value}:") | ||
tuples.foreach { case (_, cls) => started.logger.info(s" $cls") } | ||
} | ||
|
||
Right(()) | ||
} | ||
|
||
private def testsByCrossProject(started: Started, bloop: BuildServer): Iterator[(model.CrossProjectName, String)] = { | ||
val targets = BleepCommandRemote.buildTargets(started.buildPaths, projects) | ||
val result = bloop.buildTargetScalaTestClasses(new ScalaTestClassesParams(targets)).get() | ||
|
||
for { | ||
item <- result.getItems.iterator().asScala | ||
projectName <- BleepCommandRemote.projectFromBuildTarget(started)(item.getTarget).iterator | ||
cls <- item.getClasses.iterator.asScala | ||
} yield (projectName, cls) | ||
} | ||
} |