Skip to content

Commit bf452a0

Browse files
authored
Declare BSP server as capable of providing output paths (#3645)
1 parent da97132 commit bf452a0

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ class BspServer(
173173
capabilities.setJvmTestEnvironmentProvider(true)
174174
capabilities.setCanReload(true)
175175
capabilities.setDependencyModulesProvider(true)
176+
capabilities.setOutputPathsProvider(true)
176177
capabilities
177178
}
178179

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

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,35 @@ trait BspSuite { _: ScalaCliSuite =>
8181
TestBspClient,
8282
b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & b.JvmBuildServer
8383
) => Future[T]
84+
): T = withBspInitResults(
85+
inputs,
86+
args,
87+
attempts,
88+
pauseDuration,
89+
bspOptions,
90+
bspEnvs,
91+
reuseRoot,
92+
stdErrOpt,
93+
extraOptionsOverride
94+
)((root, client, server, _: b.InitializeBuildResult) => f(root, client, server))
95+
96+
def withBspInitResults[T](
97+
inputs: TestInputs,
98+
args: Seq[String],
99+
attempts: Int = if (TestUtil.isCI) 3 else 1,
100+
pauseDuration: FiniteDuration = 5.seconds,
101+
bspOptions: List[String] = List.empty,
102+
bspEnvs: Map[String, String] = Map.empty,
103+
reuseRoot: Option[os.Path] = None,
104+
stdErrOpt: Option[os.RelPath] = None,
105+
extraOptionsOverride: Seq[String] = extraOptions
106+
)(
107+
f: (
108+
os.Path,
109+
TestBspClient,
110+
b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & b.JvmBuildServer,
111+
b.InitializeBuildResult
112+
) => Future[T]
84113
): T = {
85114

86115
def attempt(): Try[T] = Try {
@@ -118,11 +147,14 @@ trait BspSuite { _: ScalaCliSuite =>
118147
val (localClient, remoteServer0, _) =
119148
TestBspClient.connect(proc.stdout, proc.stdin, pool)
120149
remoteServer = remoteServer0
121-
Await.result(
150+
val initRes: b.InitializeBuildResult = Await.result(
122151
whileBspServerIsRunning(remoteServer.buildInitialize(initParams(root)).asScala),
123152
Duration.Inf
124153
)
125-
Await.result(whileBspServerIsRunning(f(root, localClient, remoteServer)), Duration.Inf)
154+
Await.result(
155+
whileBspServerIsRunning(f(root, localClient, remoteServer, initRes)),
156+
Duration.Inf
157+
)
126158
}
127159
finally {
128160
if (remoteServer != null)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,9 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
844844
|}
845845
|""".stripMargin
846846
)
847-
withBsp(inputs, Seq(".")) { (root, _, remoteServer) =>
847+
withBspInitResults(inputs, Seq(".")) { (root, _, remoteServer, buildInitRes) =>
848+
val serverCapabilities: b.BuildServerCapabilities = buildInitRes.getCapabilities
849+
expect(serverCapabilities.getOutputPathsProvider)
848850
async {
849851
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
850852
val target = {

0 commit comments

Comments
 (0)