Skip to content

Commit

Permalink
Moves the tests from ScalaJsToolchainSpec into frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
KristianAN committed Dec 19, 2024
1 parent 901f536 commit 7985bda
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 96 deletions.

This file was deleted.

9 changes: 0 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -385,15 +385,6 @@ lazy val jsBridge1 = project
)
)

lazy val jsBridge1Test = project
.dependsOn(jsBridge1 % "test->test", frontend % "test->test")
.in(file("bridges") / "scalajs-1-test")
.disablePlugins(ScriptedPlugin, ScalafixPlugin)
.settings(
name := s"$jsBridge1Name-test",
testSettings
)

val nativeBridge04Name = "bloop-native-bridge-0-4"
lazy val nativeBridge04 = project
.dependsOn(bloopShared % Provided)
Expand Down
71 changes: 71 additions & 0 deletions frontend/src/test/scala/bloop/LinkSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package bloop

import java.util.concurrent.TimeUnit

import scala.concurrent.duration.Duration
import bloop.util.TestUtil
import bloop.logging.RecordingLogger
import bloop.cli.Commands

import bloop.testing.BaseSuite
import bloop.cli.OptimizerConfig
import bloop.engine.Run

object LinkSpec extends BaseSuite {

val MainJSProject = "test-projectJS"
val TestJSProject = "test-projectJS-test"
private final val maxDuration = Duration.apply(60, TimeUnit.SECONDS)

val jsState0 =
TestUtil.loadTestProject(TestUtil.getBloopConfigDir("cross-test-build-scalajs-1.x"))

test("can link scalajs1.x project") {

val logger = new RecordingLogger
val action = Run(Commands.Link(List(MainJSProject)))
val resultingState =
TestUtil.blockingExecute(action, jsState0.copy(logger = logger), maxDuration)

assert(
resultingState.status.isOk
)
assert(
logger
.getMessagesAt(level = Some("info"))
.find(_.contains("Generated JavaScript file"))
.isDefined
)
}

test("can link scalajs-1.x project in release mode") {
val logger = new RecordingLogger
val mode = OptimizerConfig.Release
val state = jsState0.copy(logger = logger)
val action = Run(Commands.Link(List(MainJSProject), optimize = Some(mode)))
val resultingState = TestUtil.blockingExecute(action, state, maxDuration * 2)

assert(resultingState.status.isOk)
assert(
logger
.getMessagesAt(level = Some("debug"))
.find(_.contains("Optimizer: Batch mode: true"))
.isDefined
)
}

test("can run scalaJS project") {
val logger = new RecordingLogger
val state = jsState0.copy(logger = logger)
val action = Run(Commands.Run(List(MainJSProject)))
val resultingState = TestUtil.blockingExecute(action, state, maxDuration)

assert(resultingState.status.isOk)
assert(
logger
.getMessagesAt(level = Some("info"))
.find(_.contains("Hello, world!"))
.isDefined
)
}
}

0 comments on commit 7985bda

Please sign in to comment.