Skip to content

Commit dc40778

Browse files
committed
Use common sense options in Bsp operations change test that fails, but in reality does not test anything with the last call to compile.
1 parent 1180818 commit dc40778

File tree

5 files changed

+25
-27
lines changed

5 files changed

+25
-27
lines changed

modules/build/src/main/scala/scala/build/bsp/BspImpl.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ final class BspImpl(
8080
event
8181
}
8282
val params = new b.DidChangeBuildTarget(events.asJava)
83+
pprint.err.log(params)
8384
actualLocalClient.onBuildTargetDidChange(params)
8485
}
8586

@@ -369,6 +370,7 @@ final class BspImpl(
369370
new b.CompileResult(b.StatusCode.ERROR)
370371
)
371372
case Right(params) =>
373+
println(params)
372374
for (targetId <- currentBloopSession.bspServer.targetIds)
373375
actualLocalClient.resetBuildExceptionDiagnostics(targetId)
374376

modules/build/src/main/scala/scala/build/bsp/BspServer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,10 @@ class BspServer(
192192
): CompletableFuture[b.CleanCacheResult] =
193193
super.buildTargetCleanCache(check(params))
194194

195-
override def buildTargetCompile(params: b.CompileParams): CompletableFuture[b.CompileResult] =
195+
override def buildTargetCompile(params: b.CompileParams): CompletableFuture[b.CompileResult] = {
196+
pprint.err.log(params)
196197
compile(() => super.buildTargetCompile(check(params)))
198+
}
197199

198200
override def buildTargetDependencySources(
199201
params: b.DependencySourcesParams

modules/build/src/test/scala/scala/build/input/compose/InputsComposerTest.scala

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,19 @@ class InputsComposerTest extends TestUtil.ScalaCliBuildSuite {
101101

102102
val buildOrder = inputs.modulesBuildOrder
103103

104-
def baseProjectName(projectName: ProjectName): String = {
104+
def baseProjectName(projectName: ProjectName): String =
105105
projectName.name.take(projectName.name.indexOf("_"))
106-
}
107106

108-
assert(buildOrder.map(_.projectName).map(baseProjectName) == Seq("utils", "core", "root1", "root2", "uberRoot"), clue = buildOrder.map(_.projectName).map(baseProjectName))
107+
assert(
108+
buildOrder.map(_.projectName).map(baseProjectName) == Seq(
109+
"utils",
110+
"core",
111+
"root1",
112+
"root2",
113+
"uberRoot"
114+
),
115+
clue = buildOrder.map(_.projectName).map(baseProjectName)
116+
)
109117
}
110118
}
111119
}

modules/cli/src/main/scala/scala/cli/commands/bsp/Bsp.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,29 +135,30 @@ object Bsp extends ScalaCommand[BspOptions] {
135135

136136
val inputsAndBuildOptions = preprocessInputs(args.all).orExit(logger)
137137

138-
// TODO reported override option values
139-
// FIXME Only some options need to be unified for the whole project, like scala version, JVM
140138
val combinedBuildOptions = inputsAndBuildOptions._2.reduceLeft(_ orElse _)
141139
val inputs = inputsAndBuildOptions._1
142140

143141
if (options.shared.logging.verbosity >= 3)
144142
pprint.err.log(combinedBuildOptions)
145143

146-
// FIXME Why do we need shared options to be combined with combinedBuildOptions to pass BspTestsDefault.test workspace update after adding file to main scope ???
147144
/** values used for launching the bsp, especially for launching a bloop server, they include
148-
* options extracted from sources in the bloop rifle config and in buildOptions
145+
* options extracted from sources in the bloop rifle config
149146
*/
150147
val initialBspOptions = {
151148
val sharedOptions = getSharedOptions()
152149
val launcherOptions = getLauncherOptions()
153150
val envs = getEnvsFromFile()
154151
val bspBuildOptions = buildOptions(sharedOptions, launcherOptions, envs)
155-
.orElse(combinedBuildOptions)
152+
153+
// For correctly launching a bloop server we need all options, including ones from sources, e.g. for using a correct version of JVM
154+
// FIXME pick highest JVM version for launching bloop out of all specified
155+
val bloopRifleConfigOptions = bspBuildOptions.orElse(combinedBuildOptions)
156+
156157
refreshPowerMode(launcherOptions, sharedOptions, envs)
157158

158159
BspReloadableOptions(
159160
buildOptions = bspBuildOptions,
160-
bloopRifleConfig = sharedOptions.bloopRifleConfig(Some(bspBuildOptions))
161+
bloopRifleConfig = sharedOptions.bloopRifleConfig(Some(bloopRifleConfigOptions))
161162
.orExit(sharedOptions.logger),
162163
logger = sharedOptions.logging.logger,
163164
verbosity = sharedOptions.logging.verbosity

modules/integration/src/test/scala/scala/cli/integration/BspTestDefinitions.scala

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.cli.integration
22

3-
import ch.epfl.scala.bsp4j.{BuildTargetEvent, BuildTargetIdentifier, JvmTestEnvironmentParams}
3+
import ch.epfl.scala.bsp4j.{BuildTargetEvent, BuildTargetIdentifier, JvmTestEnvironmentParams, SourcesParams}
44
import ch.epfl.scala.bsp4j as b
55
import com.eed3si9n.expecty.Expecty.expect
66
import com.github.plokhotnyuk.jsoniter_scala.core.*
@@ -12,7 +12,6 @@ import org.eclipse.lsp4j.jsonrpc.messages.ResponseError
1212
import java.net.URI
1313
import java.nio.file.Paths
1414
import java.util.concurrent.{ExecutorService, ScheduledExecutorService}
15-
1615
import scala.annotation.tailrec
1716
import scala.async.Async.{async, await}
1817
import scala.cli.integration.compose.ComposeBspTestDefinitions
@@ -901,7 +900,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
901900
}
902901
}
903902

904-
test("test workspace update after adding file to main scope") {
903+
test("tes scope uses artifacts from main scope") {
905904
val inputs = TestInputs(
906905
os.rel / "Messages.scala" ->
907906
"""//> using dep "com.lihaoyi::os-lib:0.7.8"
@@ -974,20 +973,6 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
974973
expect(foundDepSources.exists(_.startsWith("test-interface-1.0")))
975974
expect(foundDepSources.forall(_.endsWith("-sources.jar")))
976975
}
977-
978-
localClient.buildTargetDidChange()
979-
980-
val newFileContent =
981-
"""object Messages {
982-
| def msg = "Hello2"
983-
|}
984-
|""".stripMargin
985-
os.write.over(root / "Messages.scala", newFileContent)
986-
987-
{
988-
val resp = await(remoteServer.buildTargetCompile(new b.CompileParams(targets)).asScala)
989-
expect(resp.getStatusCode == b.StatusCode.OK)
990-
}
991976
}
992977
}
993978
}

0 commit comments

Comments
 (0)