Skip to content

Commit

Permalink
fix: rename conflicting classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamil Podsiadlo committed Feb 25, 2022
1 parent 135e0c9 commit fe213b8
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 25 deletions.
8 changes: 4 additions & 4 deletions frontend/src/main/scala/bloop/bsp/BloopBspServices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ final class BloopBspServices(
val task = TestTask.findTestNamesWithFramework(project, state)
val item = task.map { classes =>
classes.groupBy(_.framework).map { case (framework, classes) =>
ScalaTestClassesItem(id, Some(framework), classes.flatMap(_.classes))
ScalaTestClassesItem(id, classes.flatMap(_.classes), Some(framework))
}.toList
}
item
Expand Down Expand Up @@ -596,12 +596,12 @@ final class BloopBspServices(
case bsp.DebugSessionParamsDataKind.ScalaTestSuites =>
convert[List[String]](
classNames => {
val testClasses = ScalaTestClasses(classNames)
val testClasses = ScalaRunTestClasses(classNames)
BloopDebuggeeRunner.forTestSuite(projects, testClasses, state, ioScheduler)
}
)
case "scala-test-selection" =>
convert[ScalaTestClasses](
convert[ScalaRunTestClasses](
testClasses => {
BloopDebuggeeRunner.forTestSuite(projects, testClasses, state, ioScheduler)
}
Expand Down Expand Up @@ -671,7 +671,7 @@ final class BloopBspServices(
): Task[State] = {
val testFilter = TestInternals.parseFilters(Nil) // Don't support test only for now
val handler = new BspLoggingEventHandler(id, state.logger, client)
Tasks.test(state, List(project), Nil, testFilter, ScalaTestClasses.empty, handler, mode = RunMode.Normal)
Tasks.test(state, List(project), Nil, testFilter, ScalaRunTestClasses.empty, handler, mode = RunMode.Normal)
}

val originId = params.originId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ import io.circe.Encoder
/**
* Below datatypes are based on https://github.com/build-server-protocol/build-server-protocol/issues/249#issuecomment-983435766
*/
case class ScalaTestClasses(
case class ScalaRunTestClasses(
classes: List[ScalaTestSuiteSelection],
jvmOptions: List[String],
env: Map[String, String],
) {
def classNames: List[String] = classes.map(_.className)
}

object ScalaTestClasses {
implicit val decoder: Decoder[ScalaTestClasses] = deriveDecoder
implicit val encoder: Encoder[ScalaTestClasses] = deriveEncoder
val empty: ScalaTestClasses = ScalaTestClasses(Nil, Nil, Map.empty)
object ScalaRunTestClasses {
implicit val decoder: Decoder[ScalaRunTestClasses] = deriveDecoder
implicit val encoder: Encoder[ScalaRunTestClasses] = deriveEncoder
val empty: ScalaRunTestClasses = ScalaRunTestClasses(Nil, Nil, Map.empty)

def apply(classes: List[String]): ScalaTestClasses = ScalaTestClasses(
def apply(classes: List[String]): ScalaRunTestClasses = ScalaRunTestClasses(
classes.map(className => ScalaTestSuiteSelection(className, Nil)),
Nil,
Map.empty
)

def forSuiteSelection(classes: List[ScalaTestSuiteSelection]): ScalaTestClasses = ScalaTestClasses(
def forSuiteSelection(classes: List[ScalaTestSuiteSelection]): ScalaRunTestClasses = ScalaRunTestClasses(
classes,
Nil,
Map.empty
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/main/scala/bloop/dap/BloopDebuggeeRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import monix.execution.Scheduler
import java.net.URLClassLoader
import scala.collection.mutable
import java.nio.file.Path
import bloop.bsp.ScalaTestClasses
import bloop.bsp.ScalaRunTestClasses

abstract class BloopDebuggeeRunner(initialState: State, ioScheduler: Scheduler)
extends DebuggeeRunner {
Expand Down Expand Up @@ -69,7 +69,7 @@ private final class MainClassDebugAdapter(

private final class TestSuiteDebugAdapter(
projects: Seq[Project],
testClasses: ScalaTestClasses,
testClasses: ScalaRunTestClasses,
val classPathEntries: Seq[ClassPathEntry],
val javaRuntime: Option[JavaRuntime],
val evaluationClassLoader: Option[ClassLoader],
Expand Down Expand Up @@ -155,7 +155,7 @@ object BloopDebuggeeRunner {

def forTestSuite(
projects: Seq[Project],
testClasses: ScalaTestClasses,
testClasses: ScalaRunTestClasses,
state: State,
ioScheduler: Scheduler
): Either[String, DebuggeeRunner] = {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main/scala/bloop/engine/Interpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import bloop.ScalaInstance
import scala.collection.immutable.Nil
import scala.annotation.tailrec
import java.io.IOException
import bloop.bsp.ScalaTestClasses
import bloop.bsp.ScalaRunTestClasses

object Interpreter {
// This is stack-safe because of Monix's trampolined execution
Expand Down Expand Up @@ -360,7 +360,7 @@ object Interpreter {
projectsToTest,
cmd.args,
testFilter,
ScalaTestClasses.empty,
ScalaRunTestClasses.empty,
handler,
cmd.parallel,
RunMode.Normal
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main/scala/bloop/engine/tasks/Tasks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import sbt.internal.inc.{Analysis, AnalyzingCompiler, ConcreteAnalysisContents,
import sbt.internal.inc.classpath.ClasspathUtilities
import sbt.testing._
import xsbti.compile.{ClasspathOptionsUtil, CompileAnalysis, MiniSetup, PreviousResult}
import bloop.bsp.ScalaTestClasses
import bloop.bsp.ScalaRunTestClasses
import sbt.internal.inc.PlainVirtualFileConverter
import sbt.internal.inc.classpath.ClasspathUtil

Expand Down Expand Up @@ -105,7 +105,7 @@ object Tasks {
projectsToTest: List[Project],
userTestOptions: List[String],
testFilter: String => Boolean,
testClasses: ScalaTestClasses,
testClasses: ScalaRunTestClasses,
testEventHandler: BloopTestSuiteEventHandler,
runInParallel: Boolean = false,
mode: RunMode
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/main/scala/bloop/engine/tasks/TestTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import xsbti.compile.CompileAnalysis

import scala.util.control.NonFatal
import scala.util.{Failure, Success}
import bloop.bsp.ScalaTestClasses
import bloop.bsp.ScalaRunTestClasses

final case class TestFrameworkWithClasses(
framework: String,
Expand Down Expand Up @@ -48,7 +48,7 @@ object TestTask {
cwd: AbsolutePath,
rawTestOptions: List[String],
testFilter: String => Boolean,
testClasses: ScalaTestClasses,
testClasses: ScalaRunTestClasses,
handler: LoggingEventHandler,
mode: RunMode
): Task[Int] = {
Expand Down Expand Up @@ -268,7 +268,7 @@ object TestTask {
frameworks: List[Framework],
analysis: CompileAnalysis,
testFilter: String => Boolean,
testClasses: ScalaTestClasses
testClasses: ScalaRunTestClasses
): Map[Framework, List[TaskDef]] = {
import state.logger
val tests = discoverTests(analysis, frameworks)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/test/scala/bloop/bsp/BspProtocolSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class BspProtocolSpec(
("utest", List("hello.EternalUTest", "hello.UTestTest")),
("ScalaTest", List("hello.ScalaTestTest", "hello.WritingTest", "hello.ResourcesTest")),
).map { case (framework, classes) =>
ScalaTestClassesItem(project.bspId, Some(framework), classes)
ScalaTestClassesItem(project.bspId, classes, Some(framework))
}

val testSuites = compiledState.testClasses(project)
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/test/scala/bloop/dap/DebugServerSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit.{MILLISECONDS, SECONDS}
import scala.collection.mutable
import scala.concurrent.duration.{Duration, FiniteDuration}
import scala.concurrent.{Future, Promise, TimeoutException}
import bloop.bsp.ScalaTestClasses
import bloop.bsp.ScalaRunTestClasses
import bloop.bsp.ScalaTestSuiteSelection

object DebugServerSpec extends DebugBspBaseSuite {
Expand Down Expand Up @@ -818,7 +818,7 @@ object DebugServerSpec extends DebugBspBaseSuite {

loadBspState(workspace, List(project), logger) { state =>
val testClasses =
ScalaTestClasses(
ScalaRunTestClasses(
List(
ScalaTestSuiteSelection(
"MySuite",
Expand Down Expand Up @@ -954,7 +954,7 @@ object DebugServerSpec extends DebugBspBaseSuite {
private def testRunner(
project: TestProject,
state: ManagedBspTestState,
testClasses: ScalaTestClasses = ScalaTestClasses(List("MySuite"))
testClasses: ScalaRunTestClasses = ScalaRunTestClasses(List("MySuite"))
): DebuggeeRunner = {
val testState = state.compile(project).toTestState
BloopDebuggeeRunner.forTestSuite(
Expand Down

0 comments on commit fe213b8

Please sign in to comment.