@@ -786,6 +786,10 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
786786 |""" .stripMargin
787787 )
788788
789+ val actualScalaMajorVersion = actualScalaVersion.split(" \\ ." )
790+ .take(if (actualScalaVersion.startsWith(" 3" )) 1 else 2 )
791+ .mkString(" ." )
792+
789793 withBsp(inputs, Seq (" ." )) { (root, localClient, remoteServer) =>
790794 async {
791795 val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
@@ -821,24 +825,14 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
821825 uri.drop(idx + 1 )
822826 }
823827
824- if (actualScalaVersion.startsWith(" 2.13" )) {
825- expect(foundDepSources.exists(_.startsWith(" utest_2.13-0.7.10" )))
826- expect(foundDepSources.exists(_.startsWith(" os-lib_2.13-0.7.8" )))
827- }
828- else if (actualScalaVersion.startsWith(" 2.12" )) {
829- expect(foundDepSources.exists(_.startsWith(" utest_2.12-0.7.10" )))
830- expect(foundDepSources.exists(_.startsWith(" os-lib_2.12-0.7.8" )))
831- }
832- else {
833- expect(foundDepSources.exists(_.startsWith(" utest_3-0.7.10" )))
834- expect(foundDepSources.exists(_.startsWith(" os-lib_3-0.7.8" )))
835- }
828+ expect(foundDepSources.exists(_.startsWith(s " utest_ $actualScalaMajorVersion-0.7.10 " )))
829+ expect(foundDepSources.exists(_.startsWith(s " os-lib_ $actualScalaMajorVersion-0.7.8 " )))
836830
837831 expect(foundDepSources.exists(_.startsWith(" test-interface-1.0" )))
838832 expect(foundDepSources.forall(_.endsWith(" -sources.jar" )))
839833 }
840834
841- localClient.buildTargetDidChange()
835+ val changeFuture = localClient.buildTargetDidChange()
842836
843837 val newFileContent =
844838 """ object Messages {
@@ -851,6 +845,31 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
851845 val resp = await(remoteServer.buildTargetCompile(new b.CompileParams (targets)).asScala)
852846 expect(resp.getStatusCode == b.StatusCode .OK )
853847 }
848+
849+ expect(changeFuture.isCompleted)
850+
851+ {
852+ val resp = await {
853+ remoteServer
854+ .buildTargetDependencySources(new b.DependencySourcesParams (targets))
855+ .asScala
856+ }
857+ val foundTargets = resp.getItems.asScala.map(_.getTarget.getUri).toSeq
858+ expect(foundTargets == Seq (targetUri))
859+ val foundDepSources = resp.getItems.asScala
860+ .flatMap(_.getSources.asScala)
861+ .toSeq
862+ .map { uri =>
863+ val idx = uri.lastIndexOf('/' )
864+ uri.drop(idx + 1 )
865+ }
866+
867+ expect(foundDepSources.exists(_.startsWith(s " utest_ $actualScalaMajorVersion-0.7.10 " )))
868+ expect(! foundDepSources.exists(_.startsWith(s " os-lib_ $actualScalaMajorVersion-0.7.8 " )))
869+
870+ expect(foundDepSources.exists(_.startsWith(" test-interface-1.0" )))
871+ expect(foundDepSources.forall(_.endsWith(" -sources.jar" )))
872+ }
854873 }
855874 }
856875 }
@@ -1221,7 +1240,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
12211240 val ideOptionsPath = root / Constants .workspaceDirName / " ide-options-v2.json"
12221241 val jsonOptions = List (" --json-options" , ideOptionsPath.toString)
12231242 withBsp(inputs, Seq (" ." ), bspOptions = jsonOptions, reuseRoot = Some (root)) {
1224- (_, _ , remoteServer) =>
1243+ (_, localClient , remoteServer) =>
12251244 async {
12261245 val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
12271246 val targets = buildTargetsResp.getTargets.asScala.map(_.getId).toSeq
@@ -1247,9 +1266,16 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
12471266 | """ .stripMargin
12481267 os.write.over(root / sourceFilePath, updatedSourceFile)
12491268
1269+ expect(! localClient.logMessages().exists(_.getMessage.startsWith(
1270+ " Error reading API from class file: ReloadTest : java.lang.UnsupportedClassVersionError: ReloadTest has been compiled by a more recent version of the Java Runtime"
1271+ )))
1272+
12501273 val errorResponse =
12511274 await(remoteServer.buildTargetCompile(new b.CompileParams (targets.asJava)).asScala)
1252- expect(errorResponse.getStatusCode == b.StatusCode .ERROR )
1275+ expect(errorResponse.getStatusCode == b.StatusCode .OK )
1276+ expect(localClient.logMessages().exists(_.getMessage.startsWith(
1277+ " Error reading API from class file: ReloadTest : java.lang.UnsupportedClassVersionError: ReloadTest has been compiled by a more recent version of the Java Runtime"
1278+ )))
12531279
12541280 val reloadResponse =
12551281 extractWorkspaceReloadResponse(await(remoteServer.workspaceReload().asScala))
0 commit comments