Skip to content

Commit 26edbe6

Browse files
Minor refacto in BspTestDefinitions
For the subsequent commit.
1 parent 5dbd201 commit 26edbe6

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,18 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
5858
}
5959

6060
def withBsp[T](
61-
root: os.Path,
61+
inputs: TestInputs,
6262
args: Seq[String]
6363
)(
64-
f: (TestBspClient, b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer) => Future[T]
64+
f: (
65+
os.Path,
66+
TestBspClient,
67+
b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer
68+
) => Future[T]
6569
): T = {
6670

71+
val root = inputs.root()
72+
6773
val proc = os.proc(TestUtil.cli, "bsp", extraOptions, args)
6874
.spawn(cwd = root)
6975
var remoteServer: b.BuildServer with b.ScalaBuildServer with b.JavaBuildServer = null
@@ -73,7 +79,7 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
7379
TestBspClient.connect(proc.stdout, proc.stdin, pool)
7480
remoteServer = remoteServer0
7581
Await.result(remoteServer.buildInitialize(initParams(root)).asScala, 3.minutes)
76-
Await.result(f(localClient, remoteServer), 3.minutes)
82+
Await.result(f(root, localClient, remoteServer), 3.minutes)
7783
}
7884
finally {
7985
if (remoteServer != null)
@@ -132,9 +138,8 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
132138
|""".stripMargin
133139
)
134140
)
135-
val root = inputs.root()
136141

137-
withBsp(root, Seq(".")) { (localClient, remoteServer) =>
142+
withBsp(inputs, Seq(".")) { (root, localClient, remoteServer) =>
138143
async {
139144
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
140145
val target = {
@@ -260,9 +265,8 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
260265
|""".stripMargin
261266
)
262267
)
263-
val root = inputs.root()
264268

265-
withBsp(root, Seq(".")) { (localClient, remoteServer) =>
269+
withBsp(inputs, Seq(".")) { (root, localClient, remoteServer) =>
266270
async {
267271
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
268272
val target = {
@@ -328,9 +332,8 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
328332
|""".stripMargin
329333
)
330334
)
331-
val root = inputs.root()
332335

333-
withBsp(root, Seq(".")) { (localClient, remoteServer) =>
336+
withBsp(inputs, Seq(".")) { (root, localClient, remoteServer) =>
334337
async {
335338
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
336339
val target = {
@@ -397,12 +400,11 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
397400
|""".stripMargin
398401
)
399402
)
400-
val root = inputs.root()
401-
402403
val extraArgs =
403404
if (Properties.isWin) Seq("-v", "-v", "-v")
404405
else Nil
405-
withBsp(root, Seq(".") ++ extraArgs) { (localClient, remoteServer) =>
406+
407+
withBsp(inputs, Seq(".") ++ extraArgs) { (root, localClient, remoteServer) =>
406408
async {
407409
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
408410
val target = {
@@ -515,9 +517,8 @@ abstract class BspTestDefinitions(val scalaVersionOpt: Option[String])
515517
|""".stripMargin
516518
)
517519
)
518-
val root = inputs.root()
519520

520-
withBsp(root, Seq(".")) { (localClient, remoteServer) =>
521+
withBsp(inputs, Seq(".")) { (root, localClient, remoteServer) =>
521522
async {
522523
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
523524
val target = {

0 commit comments

Comments
 (0)