@@ -786,6 +786,10 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
786
786
|""" .stripMargin
787
787
)
788
788
789
+ val actualScalaMajorVersion = actualScalaVersion.split(" \\ ." )
790
+ .take(if (actualScalaVersion.startsWith(" 3" )) 1 else 2 )
791
+ .mkString(" ." )
792
+
789
793
withBsp(inputs, Seq (" ." )) { (root, localClient, remoteServer) =>
790
794
async {
791
795
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
@@ -821,24 +825,14 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
821
825
uri.drop(idx + 1 )
822
826
}
823
827
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 " )))
836
830
837
831
expect(foundDepSources.exists(_.startsWith(" test-interface-1.0" )))
838
832
expect(foundDepSources.forall(_.endsWith(" -sources.jar" )))
839
833
}
840
834
841
- localClient.buildTargetDidChange()
835
+ val changeFuture = localClient.buildTargetDidChange()
842
836
843
837
val newFileContent =
844
838
""" object Messages {
@@ -851,6 +845,31 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
851
845
val resp = await(remoteServer.buildTargetCompile(new b.CompileParams (targets)).asScala)
852
846
expect(resp.getStatusCode == b.StatusCode .OK )
853
847
}
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
+ }
854
873
}
855
874
}
856
875
}
@@ -1221,7 +1240,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
1221
1240
val ideOptionsPath = root / Constants .workspaceDirName / " ide-options-v2.json"
1222
1241
val jsonOptions = List (" --json-options" , ideOptionsPath.toString)
1223
1242
withBsp(inputs, Seq (" ." ), bspOptions = jsonOptions, reuseRoot = Some (root)) {
1224
- (_, _ , remoteServer) =>
1243
+ (_, localClient , remoteServer) =>
1225
1244
async {
1226
1245
val buildTargetsResp = await(remoteServer.workspaceBuildTargets().asScala)
1227
1246
val targets = buildTargetsResp.getTargets.asScala.map(_.getId).toSeq
@@ -1247,9 +1266,16 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
1247
1266
| """ .stripMargin
1248
1267
os.write.over(root / sourceFilePath, updatedSourceFile)
1249
1268
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
+
1250
1273
val errorResponse =
1251
1274
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
+ )))
1253
1279
1254
1280
val reloadResponse =
1255
1281
extractWorkspaceReloadResponse(await(remoteServer.workspaceReload().asScala))
0 commit comments