Skip to content

Commit

Permalink
wip: tests for bsp linking
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianAN committed Dec 17, 2024
1 parent d899e15 commit bff00ec
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion frontend/src/test/scala/bloop/bsp/BspBaseSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ abstract class BspBaseSuite extends BaseSuite with BspClientTest {
def simulateClientDroppingOut(): Unit = closeStreamsForcibly()
}

final class ManagedBspTestState(
final case class ManagedBspTestState(
state: State,
lastBspStatus: bsp.StatusCode,
currentCompileIteration: AtomicInt,
Expand Down
47 changes: 47 additions & 0 deletions frontend/src/test/scala/bloop/bsp/BspLinkSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package bloop.bsp

import bloop.cli.BspProtocol
import bloop.util.TestUtil
import bloop.logging.RecordingLogger
import bloop.cli.ExitStatus
import bloop.util.TestProject
import bloop.data.Project
import bloop.data.Platform
import bloop.engine.tasks.toolchains.ScalaJsToolchain
import bloop.engine.State

object TcpBspLinkSpec extends BspLinkSpec(BspProtocol.Tcp)
object LocalBspLinkSpec extends BspLinkSpec(BspProtocol.Local)

class BspLinkSpec(
override val protocol: BspProtocol
) extends BspBaseSuite {

val state0: State = {
def setUpScalajs(p: Project): Project = {
val platform = p.platform match {
case jsPlatform: Platform.Js =>
jsPlatform.copy(toolchain = Some(ScalaJsToolchain.apply(this.getClass.getClassLoader)))
case _ => p.platform
}
p.copy(platform = platform)
}

val configDir = TestUtil.getBloopConfigDir("cross-test-build-scalajs-1.x")
val logger = bloop.logging.BloopLogger.default(configDir.toString())
TestUtil.loadTestProject(configDir, logger, true, _.map(setUpScalajs))
}

test("can link scalajs cross project") {
TestUtil.withinWorkspace { workspace =>
val logger = new RecordingLogger(ansiCodesSupported = false)
loadBspBuildFromResources(s"cross-test-build-scalajs-1.x", workspace, logger) { build =>
val project: TestProject = build.projectFor("test-projectJS")
val newB = build.copy(state = build.state.copy(state = state0))
val compiledState =
newB.state.compile(project, arguments = Some(List("--link")))
assert(compiledState.status == ExitStatus.Ok)
}
}
}
}

0 comments on commit bff00ec

Please sign in to comment.