@@ -22,9 +22,10 @@ import scala.jdk.CollectionConverters.*
2222import scala .util .control .NonFatal
2323import scala .util .{Failure , Properties , Success , Try }
2424
25- abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArgs {
25+ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArgs
26+ with ScriptWrapperTestDefinitions {
2627 _ : TestScalaVersion =>
27- private lazy val extraOptions = scalaVersionArgs ++ TestUtil .extraOptions
28+ protected lazy val extraOptions : Seq [ String ] = scalaVersionArgs ++ TestUtil .extraOptions
2829
2930 import BspTestDefinitions .*
3031
@@ -61,12 +62,12 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
6162 pool.shutdown()
6263 }
6364
64- private def extractMainTargets (targets : Seq [BuildTargetIdentifier ]): BuildTargetIdentifier =
65+ protected def extractMainTargets (targets : Seq [BuildTargetIdentifier ]): BuildTargetIdentifier =
6566 targets.collectFirst {
6667 case t if ! t.getUri.contains(" -test" ) => t
6768 }.get
6869
69- private def extractTestTargets (targets : Seq [BuildTargetIdentifier ]): BuildTargetIdentifier =
70+ protected def extractTestTargets (targets : Seq [BuildTargetIdentifier ]): BuildTargetIdentifier =
7071 targets.collectFirst {
7172 case t if t.getUri.contains(" -test" ) => t
7273 }.get
@@ -78,7 +79,8 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
7879 pauseDuration : FiniteDuration = 5 .seconds,
7980 bspOptions : List [String ] = List .empty,
8081 reuseRoot : Option [os.Path ] = None ,
81- stdErrOpt : Option [os.RelPath ] = None
82+ stdErrOpt : Option [os.RelPath ] = None ,
83+ extraOptionsOverride : Seq [String ] = extraOptions
8284 )(
8385 f : (
8486 os.Path ,
@@ -93,7 +95,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
9395 val stdErrPathOpt : Option [os.ProcessOutput ] = stdErrOpt.map(path => inputsRoot / path)
9496 val stderr : os.ProcessOutput = stdErrPathOpt.getOrElse(os.Inherit )
9597
96- val proc = os.proc(TestUtil .cli, " bsp" , bspOptions ++ extraOptions , args)
98+ val proc = os.proc(TestUtil .cli, " bsp" , bspOptions ++ extraOptionsOverride , args)
9799 .spawn(cwd = root, stderr = stderr)
98100 var remoteServer : b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & b.JvmBuildServer =
99101 null
@@ -1606,21 +1608,21 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
16061608 )
16071609
16081610 val scalaDiagnostic = new Gson ().fromJson[b.ScalaDiagnostic ](
1609- updateActionableDiagnostic.getData() .asInstanceOf [JsonElement ],
1611+ updateActionableDiagnostic.getData.asInstanceOf [JsonElement ],
16101612 classOf [b.ScalaDiagnostic ]
16111613 )
16121614
1613- val actions = scalaDiagnostic.getActions() .asScala.toList
1615+ val actions = scalaDiagnostic.getActions.asScala.toList
16141616 assert(actions.size == 1 )
1615- val changes = actions.head.getEdit() .getChanges() .asScala.toList
1617+ val changes = actions.head.getEdit.getChanges.asScala.toList
16161618 assert(changes.size == 1 )
16171619 val textEdit = changes.head
16181620
1619- expect(textEdit.getNewText() .contains(" com.lihaoyi::os-lib:" ))
1620- expect(textEdit.getRange() .getStart.getLine == 0 )
1621- expect(textEdit.getRange() .getStart.getCharacter == 15 )
1622- expect(textEdit.getRange() .getEnd.getLine == 0 )
1623- expect(textEdit.getRange() .getEnd.getCharacter == 40 )
1621+ expect(textEdit.getNewText.contains(" com.lihaoyi::os-lib:" ))
1622+ expect(textEdit.getRange.getStart.getLine == 0 )
1623+ expect(textEdit.getRange.getStart.getCharacter == 15 )
1624+ expect(textEdit.getRange.getEnd.getLine == 0 )
1625+ expect(textEdit.getRange.getEnd.getCharacter == 40 )
16241626 }
16251627 }
16261628 }
@@ -1653,8 +1655,8 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
16531655 await(remoteServer.buildTargetCompile(new b.CompileParams (targets)).asScala)
16541656
16551657 val visibleDiagnostics =
1656- localClient.diagnostics().map(_.getDiagnostics() .asScala).find(
1657- ! _.isEmpty
1658+ localClient.diagnostics().map(_.getDiagnostics.asScala).find(
1659+ _.nonEmpty
16581660 ).getOrElse(
16591661 Nil
16601662 )
@@ -1676,21 +1678,21 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
16761678 )
16771679
16781680 val scalaDiagnostic = new Gson ().fromJson[b.ScalaDiagnostic ](
1679- updateActionableDiagnostic.getData() .asInstanceOf [JsonElement ],
1681+ updateActionableDiagnostic.getData.asInstanceOf [JsonElement ],
16801682 classOf [b.ScalaDiagnostic ]
16811683 )
16821684
1683- val actions = scalaDiagnostic.getActions() .asScala.toList
1685+ val actions = scalaDiagnostic.getActions.asScala.toList
16841686 assert(actions.size == 1 )
1685- val changes = actions.head.getEdit() .getChanges() .asScala.toList
1687+ val changes = actions.head.getEdit.getChanges.asScala.toList
16861688 assert(changes.size == 1 )
16871689 val textEdit = changes.head
16881690
1689- expect(textEdit.getNewText() .contains(" \n case TestB() => ???" ))
1690- expect(textEdit.getRange() .getStart.getLine == 7 )
1691- expect(textEdit.getRange() .getStart.getCharacter == 19 )
1692- expect(textEdit.getRange() .getEnd.getLine == 7 )
1693- expect(textEdit.getRange() .getEnd.getCharacter == 19 )
1691+ expect(textEdit.getNewText.contains(" \n case TestB() => ???" ))
1692+ expect(textEdit.getRange.getStart.getLine == 7 )
1693+ expect(textEdit.getRange.getStart.getCharacter == 19 )
1694+ expect(textEdit.getRange.getEnd.getLine == 7 )
1695+ expect(textEdit.getRange.getEnd.getCharacter == 19 )
16941696 }
16951697 }
16961698 }
@@ -1938,11 +1940,11 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
19381940 }
19391941
19401942 val diagnostics = diagnosticsParams.flatMap(_.getDiagnostics.asScala)
1941- .sortBy(_.getRange() .getEnd() .getCharacter())
1943+ .sortBy(_.getRange.getEnd.getCharacter())
19421944
19431945 {
19441946 checkDiagnostic(
1945- diagnostic = diagnostics.apply( 0 ) ,
1947+ diagnostic = diagnostics.head ,
19461948 expectedMessage =
19471949 " Using 'latest' for toolkit is deprecated, use 'default' to get more stable behaviour" ,
19481950 expectedSeverity = b.DiagnosticSeverity .WARNING ,
@@ -1953,7 +1955,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
19531955 )
19541956
19551957 checkScalaAction(
1956- diagnostic = diagnostics.apply( 0 ) ,
1958+ diagnostic = diagnostics.head ,
19571959 expectedActionsSize = 1 ,
19581960 expectedTitle = " Change to: toolkit default" ,
19591961 expectedChanges = 1 ,
@@ -2090,7 +2092,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
20902092 expectedEndLine : Int ,
20912093 expectedEndCharacter : Int ,
20922094 expectedNewText : String
2093- ) = {
2095+ ): Unit = {
20942096 expect(diagnostic.getDataKind == " scala" )
20952097
20962098 val gson = new com.google.gson.Gson ()
@@ -2129,7 +2131,6 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
21292131}
21302132
21312133object BspTestDefinitions {
2132-
21332134 private final case class Details (
21342135 name : String ,
21352136 version : String ,
@@ -2138,7 +2139,4 @@ object BspTestDefinitions {
21382139 languages : List [String ]
21392140 )
21402141 private val detailsCodec : JsonValueCodec [Details ] = JsonCodecMaker .make
2141-
2142- private final case class TextEdit (range : b.Range , newText : String )
2143-
21442142}
0 commit comments