@@ -22,9 +22,10 @@ import scala.jdk.CollectionConverters.*
22
22
import scala .util .control .NonFatal
23
23
import scala .util .{Failure , Properties , Success , Try }
24
24
25
- abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArgs {
25
+ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArgs
26
+ with ScriptWrapperTestDefinitions {
26
27
_ : TestScalaVersion =>
27
- private lazy val extraOptions = scalaVersionArgs ++ TestUtil .extraOptions
28
+ protected lazy val extraOptions : Seq [ String ] = scalaVersionArgs ++ TestUtil .extraOptions
28
29
29
30
import BspTestDefinitions .*
30
31
@@ -61,12 +62,12 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
61
62
pool.shutdown()
62
63
}
63
64
64
- private def extractMainTargets (targets : Seq [BuildTargetIdentifier ]): BuildTargetIdentifier =
65
+ protected def extractMainTargets (targets : Seq [BuildTargetIdentifier ]): BuildTargetIdentifier =
65
66
targets.collectFirst {
66
67
case t if ! t.getUri.contains(" -test" ) => t
67
68
}.get
68
69
69
- private def extractTestTargets (targets : Seq [BuildTargetIdentifier ]): BuildTargetIdentifier =
70
+ protected def extractTestTargets (targets : Seq [BuildTargetIdentifier ]): BuildTargetIdentifier =
70
71
targets.collectFirst {
71
72
case t if t.getUri.contains(" -test" ) => t
72
73
}.get
@@ -78,7 +79,8 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
78
79
pauseDuration : FiniteDuration = 5 .seconds,
79
80
bspOptions : List [String ] = List .empty,
80
81
reuseRoot : Option [os.Path ] = None ,
81
- stdErrOpt : Option [os.RelPath ] = None
82
+ stdErrOpt : Option [os.RelPath ] = None ,
83
+ extraOptionsOverride : Seq [String ] = extraOptions
82
84
)(
83
85
f : (
84
86
os.Path ,
@@ -93,7 +95,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
93
95
val stdErrPathOpt : Option [os.ProcessOutput ] = stdErrOpt.map(path => inputsRoot / path)
94
96
val stderr : os.ProcessOutput = stdErrPathOpt.getOrElse(os.Inherit )
95
97
96
- val proc = os.proc(TestUtil .cli, " bsp" , bspOptions ++ extraOptions , args)
98
+ val proc = os.proc(TestUtil .cli, " bsp" , bspOptions ++ extraOptionsOverride , args)
97
99
.spawn(cwd = root, stderr = stderr)
98
100
var remoteServer : b.BuildServer & b.ScalaBuildServer & b.JavaBuildServer & b.JvmBuildServer =
99
101
null
@@ -1606,21 +1608,21 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
1606
1608
)
1607
1609
1608
1610
val scalaDiagnostic = new Gson ().fromJson[b.ScalaDiagnostic ](
1609
- updateActionableDiagnostic.getData() .asInstanceOf [JsonElement ],
1611
+ updateActionableDiagnostic.getData.asInstanceOf [JsonElement ],
1610
1612
classOf [b.ScalaDiagnostic ]
1611
1613
)
1612
1614
1613
- val actions = scalaDiagnostic.getActions() .asScala.toList
1615
+ val actions = scalaDiagnostic.getActions.asScala.toList
1614
1616
assert(actions.size == 1 )
1615
- val changes = actions.head.getEdit() .getChanges() .asScala.toList
1617
+ val changes = actions.head.getEdit.getChanges.asScala.toList
1616
1618
assert(changes.size == 1 )
1617
1619
val textEdit = changes.head
1618
1620
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 )
1624
1626
}
1625
1627
}
1626
1628
}
@@ -1653,8 +1655,8 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
1653
1655
await(remoteServer.buildTargetCompile(new b.CompileParams (targets)).asScala)
1654
1656
1655
1657
val visibleDiagnostics =
1656
- localClient.diagnostics().map(_.getDiagnostics() .asScala).find(
1657
- ! _.isEmpty
1658
+ localClient.diagnostics().map(_.getDiagnostics.asScala).find(
1659
+ _.nonEmpty
1658
1660
).getOrElse(
1659
1661
Nil
1660
1662
)
@@ -1676,21 +1678,21 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
1676
1678
)
1677
1679
1678
1680
val scalaDiagnostic = new Gson ().fromJson[b.ScalaDiagnostic ](
1679
- updateActionableDiagnostic.getData() .asInstanceOf [JsonElement ],
1681
+ updateActionableDiagnostic.getData.asInstanceOf [JsonElement ],
1680
1682
classOf [b.ScalaDiagnostic ]
1681
1683
)
1682
1684
1683
- val actions = scalaDiagnostic.getActions() .asScala.toList
1685
+ val actions = scalaDiagnostic.getActions.asScala.toList
1684
1686
assert(actions.size == 1 )
1685
- val changes = actions.head.getEdit() .getChanges() .asScala.toList
1687
+ val changes = actions.head.getEdit.getChanges.asScala.toList
1686
1688
assert(changes.size == 1 )
1687
1689
val textEdit = changes.head
1688
1690
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 )
1694
1696
}
1695
1697
}
1696
1698
}
@@ -1938,11 +1940,11 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
1938
1940
}
1939
1941
1940
1942
val diagnostics = diagnosticsParams.flatMap(_.getDiagnostics.asScala)
1941
- .sortBy(_.getRange() .getEnd() .getCharacter())
1943
+ .sortBy(_.getRange.getEnd.getCharacter())
1942
1944
1943
1945
{
1944
1946
checkDiagnostic(
1945
- diagnostic = diagnostics.apply( 0 ) ,
1947
+ diagnostic = diagnostics.head ,
1946
1948
expectedMessage =
1947
1949
" Using 'latest' for toolkit is deprecated, use 'default' to get more stable behaviour" ,
1948
1950
expectedSeverity = b.DiagnosticSeverity .WARNING ,
@@ -1953,7 +1955,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
1953
1955
)
1954
1956
1955
1957
checkScalaAction(
1956
- diagnostic = diagnostics.apply( 0 ) ,
1958
+ diagnostic = diagnostics.head ,
1957
1959
expectedActionsSize = 1 ,
1958
1960
expectedTitle = " Change to: toolkit default" ,
1959
1961
expectedChanges = 1 ,
@@ -2090,7 +2092,7 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
2090
2092
expectedEndLine : Int ,
2091
2093
expectedEndCharacter : Int ,
2092
2094
expectedNewText : String
2093
- ) = {
2095
+ ): Unit = {
2094
2096
expect(diagnostic.getDataKind == " scala" )
2095
2097
2096
2098
val gson = new com.google.gson.Gson ()
@@ -2129,7 +2131,6 @@ abstract class BspTestDefinitions extends ScalaCliSuite with TestScalaVersionArg
2129
2131
}
2130
2132
2131
2133
object BspTestDefinitions {
2132
-
2133
2134
private final case class Details (
2134
2135
name : String ,
2135
2136
version : String ,
@@ -2138,7 +2139,4 @@ object BspTestDefinitions {
2138
2139
languages : List [String ]
2139
2140
)
2140
2141
private val detailsCodec : JsonValueCodec [Details ] = JsonCodecMaker .make
2141
-
2142
- private final case class TextEdit (range : b.Range , newText : String )
2143
-
2144
2142
}
0 commit comments