mirror of
https://github.com/sbt/sbt.git
synced 2026-08-22 06:07:24 +02:00
Merge pull request #6565 from adpi2/fix-6562
[BSP] Respond error after random failure when compiling
This commit is contained in:
@@ -9,7 +9,6 @@ package sbt
|
|||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
|
|
||||||
import sbt.Def.{ ScopedKey, Setting, dummyState }
|
import sbt.Def.{ ScopedKey, Setting, dummyState }
|
||||||
import sbt.Keys.{ TaskProgress => _, name => _, _ }
|
import sbt.Keys.{ TaskProgress => _, name => _, _ }
|
||||||
import sbt.Project.richInitializeTask
|
import sbt.Project.richInitializeTask
|
||||||
@@ -18,10 +17,12 @@ import sbt.SlashSyntax0._
|
|||||||
import sbt.internal.Aggregation.KeyValue
|
import sbt.internal.Aggregation.KeyValue
|
||||||
import sbt.internal.TaskName._
|
import sbt.internal.TaskName._
|
||||||
import sbt.internal._
|
import sbt.internal._
|
||||||
|
import sbt.internal.langserver.ErrorCodes
|
||||||
import sbt.internal.util.{ Terminal => ITerminal, _ }
|
import sbt.internal.util.{ Terminal => ITerminal, _ }
|
||||||
import sbt.librarymanagement.{ Resolver, UpdateReport }
|
import sbt.librarymanagement.{ Resolver, UpdateReport }
|
||||||
import sbt.std.Transform.DummyTaskMap
|
import sbt.std.Transform.DummyTaskMap
|
||||||
import sbt.util.{ Logger, Show }
|
import sbt.util.{ Logger, Show }
|
||||||
|
import sbt.BuildSyntax._
|
||||||
|
|
||||||
import scala.annotation.nowarn
|
import scala.annotation.nowarn
|
||||||
import scala.Console.RED
|
import scala.Console.RED
|
||||||
@@ -367,11 +368,13 @@ object EvaluateTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ((key, msg, ex) <- keyed if (msg.isDefined || ex.isDefined)) {
|
for ((key, msg, ex) <- keyed if msg.isDefined || ex.isDefined) {
|
||||||
val msgString = (msg.toList ++ ex.toList.map(ErrorHandling.reducedToString)).mkString("\n\t")
|
val msgString = (msg.toList ++ ex.toList.map(ErrorHandling.reducedToString)).mkString("\n\t")
|
||||||
val log = getStreams(key, streams).log
|
val log = getStreams(key, streams).log
|
||||||
val display = contextDisplay(state, ITerminal.isColorEnabled)
|
val display = contextDisplay(state, ITerminal.isColorEnabled)
|
||||||
log.error("(" + display.show(key) + ") " + msgString)
|
val errorMessage = "(" + display.show(key) + ") " + msgString
|
||||||
|
state.respondError(ErrorCodes.InternalError, errorMessage)
|
||||||
|
log.error(errorMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ package internal
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
import sbt.BuildSyntax._
|
import sbt.BuildSyntax._
|
||||||
import sbt.Def._
|
import sbt.Def._
|
||||||
import sbt.Keys._
|
import sbt.Keys._
|
||||||
@@ -28,6 +27,7 @@ import sbt.std.TaskExtra
|
|||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
import sjsonnew.shaded.scalajson.ast.unsafe.{ JNull, JValue }
|
import sjsonnew.shaded.scalajson.ast.unsafe.{ JNull, JValue }
|
||||||
import sjsonnew.support.scalajson.unsafe.{ CompactPrinter, Converter, Parser => JsonParser }
|
import sjsonnew.support.scalajson.unsafe.{ CompactPrinter, Converter, Parser => JsonParser }
|
||||||
|
import xsbti.CompileFailed
|
||||||
|
|
||||||
// import scala.annotation.nowarn
|
// import scala.annotation.nowarn
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
@@ -507,9 +507,12 @@ object BuildServerProtocol {
|
|||||||
private def bspCompileTask: Def.Initialize[Task[Int]] = Def.task {
|
private def bspCompileTask: Def.Initialize[Task[Int]] = Def.task {
|
||||||
Keys.compile.result.value match {
|
Keys.compile.result.value match {
|
||||||
case Value(_) => StatusCode.Success
|
case Value(_) => StatusCode.Success
|
||||||
case Inc(_) =>
|
case Inc(cause) =>
|
||||||
// Cancellation is not yet implemented
|
cause.getCause match {
|
||||||
StatusCode.Error
|
case _: CompileFailed => StatusCode.Error
|
||||||
|
case _: InterruptedException => StatusCode.Cancelled
|
||||||
|
case err => throw cause
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,18 +22,17 @@ import java.util.concurrent.atomic.{ AtomicBoolean, AtomicReference }
|
|||||||
|
|
||||||
import sbt.BasicCommandStrings.{ Shutdown, TerminateAction }
|
import sbt.BasicCommandStrings.{ Shutdown, TerminateAction }
|
||||||
import sbt.internal.langserver.{ CancelRequestParams, ErrorCodes, LogMessageParams, MessageType }
|
import sbt.internal.langserver.{ CancelRequestParams, ErrorCodes, LogMessageParams, MessageType }
|
||||||
import sbt.internal.langserver.{ CancelRequestParams, ErrorCodes }
|
|
||||||
import sbt.internal.protocol.{
|
import sbt.internal.protocol.{
|
||||||
JsonRpcNotificationMessage,
|
JsonRpcNotificationMessage,
|
||||||
JsonRpcRequestMessage,
|
JsonRpcRequestMessage,
|
||||||
JsonRpcResponseError,
|
JsonRpcResponseError,
|
||||||
JsonRpcResponseMessage
|
JsonRpcResponseMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
import sbt.internal.ui.{ UITask, UserThread }
|
import sbt.internal.ui.{ UITask, UserThread }
|
||||||
import sbt.internal.util.{ Prompt, ReadJsonFromInputStream, Terminal, Util }
|
import sbt.internal.util.{ Prompt, ReadJsonFromInputStream, Terminal, Util }
|
||||||
import sbt.internal.util.Terminal.TerminalImpl
|
import sbt.internal.util.Terminal.TerminalImpl
|
||||||
import sbt.internal.util.complete.{ Parser, Parsers }
|
import sbt.internal.util.complete.{ Parser, Parsers }
|
||||||
import sbt.protocol._
|
|
||||||
import sbt.util.Logger
|
import sbt.util.Logger
|
||||||
|
|
||||||
import scala.annotation.{ nowarn, tailrec }
|
import scala.annotation.{ nowarn, tailrec }
|
||||||
@@ -41,13 +40,14 @@ import scala.collection.mutable
|
|||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
import Serialization.{ attach, cancelReadSystemIn, readSystemIn }
|
import sbt.protocol._
|
||||||
|
import sbt.protocol.Serialization.{ attach, cancelReadSystemIn, readSystemIn, promptChannel }
|
||||||
|
|
||||||
|
import sbt.protocol.codec.JsonProtocol._
|
||||||
|
|
||||||
import sjsonnew._
|
import sjsonnew._
|
||||||
import sjsonnew.support.scalajson.unsafe.{ CompactPrinter, Converter }
|
import sjsonnew.support.scalajson.unsafe.{ CompactPrinter, Converter }
|
||||||
|
|
||||||
import BasicJsonProtocol._
|
|
||||||
import Serialization.{ attach, promptChannel }
|
|
||||||
import sbt.internal.util.ProgressState
|
import sbt.internal.util.ProgressState
|
||||||
|
|
||||||
final class NetworkChannel(
|
final class NetworkChannel(
|
||||||
@@ -259,7 +259,11 @@ final class NetworkChannel(
|
|||||||
case Some(request) =>
|
case Some(request) =>
|
||||||
pendingRequests -= request.id
|
pendingRequests -= request.id
|
||||||
jsonRpcRespondError(request.id, err)
|
jsonRpcRespondError(request.id, err)
|
||||||
case _ => logMessage("error", s"Error ${err.code}: ${err.message}")
|
case _ =>
|
||||||
|
import sbt.internal.protocol.codec.JsonRPCProtocol._
|
||||||
|
val msg =
|
||||||
|
s"unmatched json error for requestId $execId: ${CompactPrinter(Converter.toJsonUnsafe(err))}"
|
||||||
|
log.debug(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +406,6 @@ final class NetworkChannel(
|
|||||||
|
|
||||||
protected def onSettingQuery(execId: Option[String], req: SettingQuery) = {
|
protected def onSettingQuery(execId: Option[String], req: SettingQuery) = {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
StandardMain.exchange.withState { s =>
|
StandardMain.exchange.withState { s =>
|
||||||
val structure = Project.extract(s).structure
|
val structure = Project.extract(s).structure
|
||||||
sbt.internal.server.SettingQuery.handleSettingQueryEither(req, structure) match {
|
sbt.internal.server.SettingQuery.handleSettingQueryEither(req, structure) match {
|
||||||
@@ -420,7 +423,6 @@ final class NetworkChannel(
|
|||||||
if (initialized) {
|
if (initialized) {
|
||||||
try {
|
try {
|
||||||
StandardMain.exchange.withState { sstate =>
|
StandardMain.exchange.withState { sstate =>
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
def completionItems(s: State) = {
|
def completionItems(s: State) = {
|
||||||
Parser
|
Parser
|
||||||
.completions(s.combinedParser, cp.query, cp.level.getOrElse(9))
|
.completions(s.combinedParser, cp.query, cp.level.getOrElse(9))
|
||||||
@@ -515,7 +517,6 @@ final class NetworkChannel(
|
|||||||
StandardMain.exchange.currentExec.exists(_.source.exists(_.channelName == name)))) {
|
StandardMain.exchange.currentExec.exists(_.source.exists(_.channelName == name)))) {
|
||||||
runningEngine.cancelAndShutdown()
|
runningEngine.cancelAndShutdown()
|
||||||
|
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
respondResult(
|
respondResult(
|
||||||
ExecStatusEvent(
|
ExecStatusEvent(
|
||||||
"Task cancelled",
|
"Task cancelled",
|
||||||
@@ -806,7 +807,6 @@ final class NetworkChannel(
|
|||||||
): Option[T] = {
|
): Option[T] = {
|
||||||
if (closed.get) None
|
if (closed.get) None
|
||||||
else {
|
else {
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
val queue = VirtualTerminal.sendTerminalCapabilitiesQuery(name, jsonRpcRequest, query)
|
val queue = VirtualTerminal.sendTerminalCapabilitiesQuery(name, jsonRpcRequest, query)
|
||||||
Some(result(queue.take))
|
Some(result(queue.take))
|
||||||
}
|
}
|
||||||
@@ -833,7 +833,6 @@ final class NetworkChannel(
|
|||||||
override private[sbt] def getAttributes: Map[String, String] =
|
override private[sbt] def getAttributes: Map[String, String] =
|
||||||
if (closed.get) Map.empty
|
if (closed.get) Map.empty
|
||||||
else {
|
else {
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
val queue = VirtualTerminal.sendTerminalAttributesQuery(
|
val queue = VirtualTerminal.sendTerminalAttributesQuery(
|
||||||
name,
|
name,
|
||||||
jsonRpcRequest
|
jsonRpcRequest
|
||||||
@@ -851,7 +850,6 @@ final class NetworkChannel(
|
|||||||
}
|
}
|
||||||
override private[sbt] def setAttributes(attributes: Map[String, String]): Unit =
|
override private[sbt] def setAttributes(attributes: Map[String, String]): Unit =
|
||||||
if (!closed.get) {
|
if (!closed.get) {
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
val attrs = TerminalSetAttributesCommand(
|
val attrs = TerminalSetAttributesCommand(
|
||||||
iflag = attributes.getOrElse("iflag", ""),
|
iflag = attributes.getOrElse("iflag", ""),
|
||||||
oflag = attributes.getOrElse("oflag", ""),
|
oflag = attributes.getOrElse("oflag", ""),
|
||||||
@@ -865,7 +863,6 @@ final class NetworkChannel(
|
|||||||
}
|
}
|
||||||
override private[sbt] def getSizeImpl: (Int, Int) =
|
override private[sbt] def getSizeImpl: (Int, Int) =
|
||||||
if (!closed.get) {
|
if (!closed.get) {
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
val queue = VirtualTerminal.getTerminalSize(name, jsonRpcRequest)
|
val queue = VirtualTerminal.getTerminalSize(name, jsonRpcRequest)
|
||||||
val res = try queue.take
|
val res = try queue.take
|
||||||
catch { case _: InterruptedException => TerminalGetSizeResponse(1, 1) }
|
catch { case _: InterruptedException => TerminalGetSizeResponse(1, 1) }
|
||||||
@@ -873,7 +870,6 @@ final class NetworkChannel(
|
|||||||
} else (1, 1)
|
} else (1, 1)
|
||||||
override def setSize(width: Int, height: Int): Unit =
|
override def setSize(width: Int, height: Int): Unit =
|
||||||
if (!closed.get) {
|
if (!closed.get) {
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
val size = TerminalSetSizeCommand(width, height)
|
val size = TerminalSetSizeCommand(width, height)
|
||||||
val queue = VirtualTerminal.setTerminalSize(name, jsonRpcRequest, size)
|
val queue = VirtualTerminal.setTerminalSize(name, jsonRpcRequest, size)
|
||||||
try queue.take
|
try queue.take
|
||||||
@@ -881,7 +877,6 @@ final class NetworkChannel(
|
|||||||
}
|
}
|
||||||
private[this] def setRawMode(toggle: Boolean): Unit = {
|
private[this] def setRawMode(toggle: Boolean): Unit = {
|
||||||
if (!closed.get || false) {
|
if (!closed.get || false) {
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
val raw = TerminalSetRawModeCommand(toggle)
|
val raw = TerminalSetRawModeCommand(toggle)
|
||||||
val queue = VirtualTerminal.setTerminalRawMode(name, jsonRpcRequest, raw)
|
val queue = VirtualTerminal.setTerminalRawMode(name, jsonRpcRequest, raw)
|
||||||
try queue.take
|
try queue.take
|
||||||
@@ -892,7 +887,6 @@ final class NetworkChannel(
|
|||||||
override private[sbt] def exitRawMode(): Unit = setRawMode(false)
|
override private[sbt] def exitRawMode(): Unit = setRawMode(false)
|
||||||
override def setEchoEnabled(toggle: Boolean): Unit =
|
override def setEchoEnabled(toggle: Boolean): Unit =
|
||||||
if (!closed.get) {
|
if (!closed.get) {
|
||||||
import sbt.protocol.codec.JsonProtocol._
|
|
||||||
val echo = TerminalSetEchoCommand(toggle)
|
val echo = TerminalSetEchoCommand(toggle)
|
||||||
val queue = VirtualTerminal.setTerminalEcho(name, jsonRpcRequest, echo)
|
val queue = VirtualTerminal.setTerminalEcho(name, jsonRpcRequest, echo)
|
||||||
try queue.take
|
try queue.take
|
||||||
|
|||||||
@@ -15,4 +15,13 @@ lazy val reportWarning = project.in(file("report-warning"))
|
|||||||
scalacOptions += "-deprecation"
|
scalacOptions += "-deprecation"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// check that the buildTarget/compile request fails with the custom message defined below
|
||||||
|
lazy val respondError = project.in(file("respond-error"))
|
||||||
|
.settings(
|
||||||
|
Compile / compile := {
|
||||||
|
val _ = (Compile / compile).value
|
||||||
|
throw new MessageOnlyException("custom message")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
lazy val util = project
|
lazy val util = project
|
||||||
|
|||||||
@@ -16,19 +16,19 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("build/initialize") { _ =>
|
test("build/initialize") { _ =>
|
||||||
initializeRequest()
|
initializeRequest()
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"10"""") &&
|
(s contains """"id":"8"""") &&
|
||||||
(s contains """"resourcesProvider":true""")
|
(s contains """"resourcesProvider":true""")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
test("workspace/buildTargets") { _ =>
|
test("workspace/buildTargets") { _ =>
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
"""{ "jsonrpc": "2.0", "id": "11", "method": "workspace/buildTargets", "params": {} }"""
|
"""{ "jsonrpc": "2.0", "id": "16", "method": "workspace/buildTargets", "params": {} }"""
|
||||||
)
|
)
|
||||||
assert(processing("workspace/buildTargets"))
|
assert(processing("workspace/buildTargets"))
|
||||||
assert {
|
assert {
|
||||||
svr.waitForString(10.seconds) { s =>
|
svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"11"""") &&
|
(s contains """"id":"16"""") &&
|
||||||
(s contains """"displayName":"util"""")
|
(s contains """"displayName":"util"""")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -37,13 +37,13 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/sources") { _ =>
|
test("buildTarget/sources") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#util/Compile"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#util/Compile"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "12", "method": "buildTarget/sources", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "24", "method": "buildTarget/sources", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
assert(processing("buildTarget/sources"))
|
assert(processing("buildTarget/sources"))
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"12"""") &&
|
(s contains """"id":"24"""") &&
|
||||||
(s contains "util/src/main/scala")
|
(s contains "util/src/main/scala")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -51,13 +51,13 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/compile") { _ =>
|
test("buildTarget/compile") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#util/Compile"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#util/Compile"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "13", "method": "buildTarget/compile", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "32", "method": "buildTarget/compile", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
assert(processing("buildTarget/compile"))
|
assert(processing("buildTarget/compile"))
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"13"""") &&
|
(s contains """"id":"32"""") &&
|
||||||
(s contains """"statusCode":1""")
|
(s contains """"statusCode":1""")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -65,24 +65,24 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/scalacOptions") { _ =>
|
test("buildTarget/scalacOptions") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#util/Compile"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#util/Compile"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "14", "method": "buildTarget/scalacOptions", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "40", "method": "buildTarget/scalacOptions", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
assert(processing("buildTarget/scalacOptions"))
|
assert(processing("buildTarget/scalacOptions"))
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"14"""") &&
|
(s contains """"id":"40"""") &&
|
||||||
(s contains "scala-library-2.13.1.jar")
|
(s contains "scala-library-2.13.1.jar")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
test("workspace/reload") { _ =>
|
test("workspace/reload") { _ =>
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
"""{ "jsonrpc": "2.0", "id": "15", "method": "workspace/reload"}"""
|
"""{ "jsonrpc": "2.0", "id": "48", "method": "workspace/reload"}"""
|
||||||
)
|
)
|
||||||
assert(processing("workspace/reload"))
|
assert(processing("workspace/reload"))
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"15"""") &&
|
(s contains """"id":"48"""") &&
|
||||||
(s contains """"result":null""")
|
(s contains """"result":null""")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -90,13 +90,13 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/scalaMainClasses") { _ =>
|
test("buildTarget/scalaMainClasses") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Compile"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Compile"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "16", "method": "buildTarget/scalaMainClasses", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "56", "method": "buildTarget/scalaMainClasses", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
assert(processing("buildTarget/scalaMainClasses"))
|
assert(processing("buildTarget/scalaMainClasses"))
|
||||||
assert(svr.waitForString(30.seconds) { s =>
|
assert(svr.waitForString(30.seconds) { s =>
|
||||||
(s contains """"id":"16"""") &&
|
(s contains """"id":"56"""") &&
|
||||||
(s contains """"class":"main.Main"""")
|
(s contains """"class":"main.Main"""")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/run") { _ =>
|
test("buildTarget/run") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Compile"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Compile"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "17", "method": "buildTarget/run", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "64", "method": "buildTarget/run", "params": {
|
||||||
| "target": { "uri": "$x" },
|
| "target": { "uri": "$x" },
|
||||||
| "dataKind": "scala-main-class",
|
| "dataKind": "scala-main-class",
|
||||||
| "data": { "class": "main.Main" }
|
| "data": { "class": "main.Main" }
|
||||||
@@ -116,7 +116,7 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
(s contains """"message":"Hello World!"""")
|
(s contains """"message":"Hello World!"""")
|
||||||
})
|
})
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"17"""") &&
|
(s contains """"id":"64"""") &&
|
||||||
(s contains """"statusCode":1""")
|
(s contains """"statusCode":1""")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -124,13 +124,13 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/scalaTestClasses") { _ =>
|
test("buildTarget/scalaTestClasses") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Test"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Test"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "18", "method": "buildTarget/scalaTestClasses", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "72", "method": "buildTarget/scalaTestClasses", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
assert(processing("buildTarget/scalaTestClasses"))
|
assert(processing("buildTarget/scalaTestClasses"))
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"18"""") &&
|
(s contains """"id":"72"""") &&
|
||||||
(s contains """"tests.FailingTest"""") &&
|
(s contains """"tests.FailingTest"""") &&
|
||||||
(s contains """"tests.PassingTest"""")
|
(s contains """"tests.PassingTest"""")
|
||||||
})
|
})
|
||||||
@@ -139,13 +139,13 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/test: run all tests") { _ =>
|
test("buildTarget/test: run all tests") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Test"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Test"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "19", "method": "buildTarget/test", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "80", "method": "buildTarget/test", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
assert(processing("buildTarget/test"))
|
assert(processing("buildTarget/test"))
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"19"""") &&
|
(s contains """"id":"80"""") &&
|
||||||
(s contains """"statusCode":2""")
|
(s contains """"statusCode":2""")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/test: run one test class") { _ =>
|
test("buildTarget/test: run one test class") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Test"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#runAndTest/Test"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "20", "method": "buildTarget/test", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "84", "method": "buildTarget/test", "params": {
|
||||||
| "targets": [{ "uri": "$x" }],
|
| "targets": [{ "uri": "$x" }],
|
||||||
| "dataKind": "scala-test",
|
| "dataKind": "scala-test",
|
||||||
| "data": {
|
| "data": {
|
||||||
@@ -168,7 +168,7 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
)
|
)
|
||||||
assert(processing("buildTarget/test"))
|
assert(processing("buildTarget/test"))
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"20"""") &&
|
(s contains """"id":"84"""") &&
|
||||||
(s contains """"statusCode":1""")
|
(s contains """"statusCode":1""")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -176,7 +176,7 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/compile: report error") { _ =>
|
test("buildTarget/compile: report error") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#reportError/Compile"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#reportError/Compile"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "21", "method": "buildTarget/compile", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "88", "method": "buildTarget/compile", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
@@ -190,7 +190,7 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
test("buildTarget/compile: report warning") { _ =>
|
test("buildTarget/compile: report warning") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#reportWarning/Compile"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#reportWarning/Compile"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "22", "method": "buildTarget/compile", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "90", "method": "buildTarget/compile", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
@@ -201,22 +201,37 @@ object BuildServerTest extends AbstractServerTest {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("buildTarget/compile: respond error") { _ =>
|
||||||
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#respondError/Compile"
|
||||||
|
svr.sendJsonRpc(
|
||||||
|
s"""{ "jsonrpc": "2.0", "id": "92", "method": "buildTarget/compile", "params": {
|
||||||
|
| "targets": [{ "uri": "$x" }]
|
||||||
|
|} }""".stripMargin
|
||||||
|
)
|
||||||
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
|
s.contains(""""id":"92"""") &&
|
||||||
|
s.contains(""""error"""") &&
|
||||||
|
s.contains(""""code":-32603""") &&
|
||||||
|
s.contains("custom message")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
test("buildTarget/resources") { _ =>
|
test("buildTarget/resources") { _ =>
|
||||||
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#util/Compile"
|
val x = s"${svr.baseDirectory.getAbsoluteFile.toURI}#util/Compile"
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
s"""{ "jsonrpc": "2.0", "id": "23", "method": "buildTarget/resources", "params": {
|
s"""{ "jsonrpc": "2.0", "id": "96", "method": "buildTarget/resources", "params": {
|
||||||
| "targets": [{ "uri": "$x" }]
|
| "targets": [{ "uri": "$x" }]
|
||||||
|} }""".stripMargin
|
|} }""".stripMargin
|
||||||
)
|
)
|
||||||
assert(processing("buildTarget/resources"))
|
assert(processing("buildTarget/resources"))
|
||||||
assert(svr.waitForString(10.seconds) { s =>
|
assert(svr.waitForString(10.seconds) { s =>
|
||||||
(s contains """"id":"23"""") && (s contains "util/src/main/resources/")
|
(s contains """"id":"96"""") && (s contains "util/src/main/resources/")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private def initializeRequest(): Unit = {
|
private def initializeRequest(): Unit = {
|
||||||
svr.sendJsonRpc(
|
svr.sendJsonRpc(
|
||||||
"""{ "jsonrpc": "2.0", "id": "10", "method": "build/initialize",
|
"""{ "jsonrpc": "2.0", "id": "8", "method": "build/initialize",
|
||||||
| "params": {
|
| "params": {
|
||||||
| "displayName": "test client",
|
| "displayName": "test client",
|
||||||
| "version": "1.0.0",
|
| "version": "1.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user