mirror of https://github.com/sbt/sbt.git
Fix server completion tests
This commit is contained in:
parent
03ca5365f5
commit
b5afcf8a0c
|
|
@ -1,12 +1,11 @@
|
|||
target/
|
||||
__pycache__
|
||||
out
|
||||
node_modules
|
||||
vscode-sbt-scala/client/server
|
||||
npm-debug.log
|
||||
*.vsix
|
||||
*_pid*.log
|
||||
!sbt/src/server-test/completions/target
|
||||
!server-test/src/server-test/completions/target
|
||||
.big
|
||||
.idea
|
||||
.bloop
|
||||
|
|
|
|||
|
|
@ -403,8 +403,6 @@ object Scoped:
|
|||
)((thisTask, deps) => thisTask.dependsOn(deps: _*))
|
||||
def failure: Initialize[Task[Incomplete]] = init(_.failure)
|
||||
def result: Initialize[Task[Result[A1]]] = init(_.result)
|
||||
def xtriggeredBy[A2](tasks: Initialize[Task[A2]]*): Initialize[Task[A1]] =
|
||||
nonLocal(tasks.toSeq.asInstanceOf[Seq[AnyInitTask]], Def.triggeredBy)
|
||||
def triggeredBy[A2](tasks: Initialize[Task[A2]]*): Initialize[Task[A1]] =
|
||||
nonLocal(tasks.toSeq.asInstanceOf[Seq[AnyInitTask]], Def.triggeredBy)
|
||||
def runBefore[A2](tasks: Initialize[Task[A2]]*): Initialize[Task[A1]] =
|
||||
|
|
|
|||
|
|
@ -1007,7 +1007,7 @@ object Defaults extends BuildCommon {
|
|||
discoveredMainClasses := compile
|
||||
.map(discoverMainClasses)
|
||||
.storeAs(discoveredMainClasses)
|
||||
.xtriggeredBy(compile)
|
||||
.triggeredBy(compile)
|
||||
.value,
|
||||
discoveredSbtPlugins := discoverSbtPluginNames.value,
|
||||
// This fork options, scoped to the configuration is used for tests
|
||||
|
|
@ -1268,9 +1268,11 @@ object Defaults extends BuildCommon {
|
|||
testFrameworks.value.flatMap(f => f.create(loader, log).map(x => (f, x))).toMap
|
||||
},
|
||||
definedTests := detectTests.value,
|
||||
definedTestNames := (definedTests map (_.map(
|
||||
_.name
|
||||
).distinct) storeAs definedTestNames triggeredBy compile).value,
|
||||
definedTestNames := definedTests
|
||||
.map(_.map(_.name).distinct)
|
||||
.storeAs(definedTestNames)
|
||||
.triggeredBy(compile)
|
||||
.value,
|
||||
testQuick / testFilter := testQuickFilter.value,
|
||||
executeTests := {
|
||||
import sbt.TupleSyntax.*
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ import java.util.concurrent.atomic.AtomicBoolean
|
|||
import scala.collection.mutable
|
||||
|
||||
import scala.util.control.NonFatal
|
||||
import scala.util.{ Failure, Success }
|
||||
import scala.util.{ Try, Failure, Success }
|
||||
import scala.annotation.nowarn
|
||||
import sbt.testing.Framework
|
||||
|
||||
|
|
@ -790,12 +790,12 @@ object BuildServerProtocol {
|
|||
}
|
||||
}
|
||||
|
||||
private val jsonParser: Parser[JValue] = (Parsers.any.*).map(_.mkString)
|
||||
.map(JsonParser.parseUnsafe)
|
||||
private val jsonParser: Parser[Try[JValue]] = Parsers.any.*.map(_.mkString)
|
||||
.map(JsonParser.parseFromString)
|
||||
|
||||
private def bspRunTask: Def.Initialize[InputTask[Unit]] =
|
||||
Def.input((s: State) => jsonParser).flatMapTask { json =>
|
||||
val runParams = Converter.fromJson[RunParams](json).get
|
||||
Def.input(_ => jsonParser).flatMapTask { json =>
|
||||
val runParams = json.flatMap(Converter.fromJson[RunParams]).get
|
||||
val defaultClass = Keys.mainClass.value
|
||||
val defaultJvmOptions = Keys.javaOptions.value
|
||||
|
||||
|
|
@ -837,8 +837,8 @@ object BuildServerProtocol {
|
|||
}
|
||||
|
||||
private def bspTestTask: Def.Initialize[InputTask[Unit]] =
|
||||
Def.input((s: State) => jsonParser).flatMapTask { json =>
|
||||
val testParams = Converter.fromJson[TestParams](json).get
|
||||
Def.input(_ => jsonParser).flatMapTask { json =>
|
||||
val testParams = json.flatMap(Converter.fromJson[TestParams]).get
|
||||
val workspace = bspFullWorkspace.value
|
||||
|
||||
val resultTask: Def.Initialize[Task[Result[Seq[Unit]]]] = testParams.dataKind match {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ private[sbt] object LanguageServerProtocol {
|
|||
onCancellationRequest(Option(r.id), param)
|
||||
|
||||
case r: JsonRpcRequestMessage if r.method == "sbt/completion" =>
|
||||
import sbt.protocol.codec.JsonProtocol._
|
||||
val param = Converter.fromJson[CP](json(r)).get
|
||||
onCompletionRequest(Option(r.id), param)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
val hello = taskKey[Unit]("Say hello")
|
||||
|
||||
scalaVersion := "3.3.1"
|
||||
hello := {}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ class ServerCompletionsTest extends AbstractServerTest {
|
|||
override val testDirectory: String = "completions"
|
||||
|
||||
test("return basic completions on request") {
|
||||
pending // TODO fix completion request failed
|
||||
val completionStr = """{ "query": "" }"""
|
||||
svr.sendJsonRpc(
|
||||
s"""{ "jsonrpc": "2.0", "id": 15, "method": "sbt/completion", "params": $completionStr }"""
|
||||
|
|
@ -35,7 +34,6 @@ class ServerCompletionsTest extends AbstractServerTest {
|
|||
}
|
||||
|
||||
test("return completions for user classes") {
|
||||
pending // TODO fix empty items
|
||||
val completionStr = """{ "query": "testOnly org." }"""
|
||||
svr.sendJsonRpc(
|
||||
s"""{ "jsonrpc": "2.0", "id": 17, "method": "sbt/completion", "params": $completionStr }"""
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ case class TestServer(
|
|||
try IO.read(portfile).isEmpty
|
||||
catch { case _: IOException => true }
|
||||
def waitForPortfile(duration: FiniteDuration): Unit = {
|
||||
hostLog(s"wait $duration until the server is ready to respond")
|
||||
val deadline = duration.fromNow
|
||||
var nextLog = 10.seconds.fromNow
|
||||
while (portfileIsEmpty() && !deadline.isOverdue && process.isAlive) {
|
||||
|
|
@ -195,9 +196,7 @@ case class TestServer(
|
|||
if (deadline.isOverdue) sys.error(s"Timeout. $portfile is not found.")
|
||||
if (!process.isAlive) sys.error(s"Server unexpectedly terminated.")
|
||||
}
|
||||
private val waitDuration: FiniteDuration = 1.minute
|
||||
hostLog(s"wait $waitDuration until the server is ready to respond")
|
||||
waitForPortfile(waitDuration)
|
||||
waitForPortfile(1.minute)
|
||||
|
||||
@tailrec
|
||||
private def connect(attempt: Int): Socket = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue