mirror of https://github.com/sbt/sbt.git
Adding a test verifying task progress reports (task start/progress/finish)
This commit is contained in:
parent
2f589b6713
commit
9986fb6eed
|
|
@ -2353,9 +2353,7 @@ object Defaults extends BuildCommon {
|
|||
)
|
||||
}
|
||||
def onProgress(s: Setup) = {
|
||||
val cp: BspCompileProgress = s.progress.asScala
|
||||
.map(p => new BspCompileProgress(task, Some(p)))
|
||||
.getOrElse(new BspCompileProgress(task, None))
|
||||
val cp = new BspCompileProgress(task, s.progress.asScala)
|
||||
s.withProgress(cp)
|
||||
}
|
||||
val compilers: Compilers = ci.compilers
|
||||
|
|
|
|||
|
|
@ -1,3 +1,10 @@
|
|||
/*
|
||||
* sbt
|
||||
* Copyright 2011 - 2018, Lightbend, Inc.
|
||||
* Copyright 2008 - 2010, Mark Harrah
|
||||
* Licensed under Apache License 2.0 (see LICENSE)
|
||||
*/
|
||||
|
||||
package sbt.internal.server
|
||||
|
||||
import xsbti.compile.CompileProgress
|
||||
|
|
@ -18,7 +25,14 @@ private[sbt] final class BspCompileProgress(
|
|||
if (shouldReportPercentage) {
|
||||
task.notifyProgress(percentage, total)
|
||||
}
|
||||
underlying.foreach(_.advance(current, total, prevPhase, nextPhase))
|
||||
true
|
||||
underlying.fold(true)(_.advance(current, total, prevPhase, nextPhase))
|
||||
}
|
||||
|
||||
override def startUnit(phase: String, unitPath: String): Unit = {
|
||||
underlying.foreach(_.startUnit(phase, unitPath))
|
||||
}
|
||||
|
||||
override def afterEarlyOutput(success: Boolean): Unit = {
|
||||
underlying.foreach(_.afterEarlyOutput(success))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,6 +94,35 @@ object BuildServerTest extends AbstractServerTest {
|
|||
assert(res.statusCode == StatusCode.Success)
|
||||
}
|
||||
|
||||
test("buildTarget/compile - reports compilation progress") { _ =>
|
||||
val buildTarget = buildTargetUri("runAndTest", "Compile")
|
||||
svr.sendJsonRpc(
|
||||
s"""{ "jsonrpc": "2.0", "id": "33", "method": "buildTarget/compile", "params": {
|
||||
| "targets": [{ "uri": "$buildTarget" }]
|
||||
|} }""".stripMargin
|
||||
)
|
||||
|
||||
assert(svr.waitForString(10.seconds) { s =>
|
||||
s.contains("build/taskStart") &&
|
||||
s.contains(""""message":"Compiling runAndTest"""")
|
||||
})
|
||||
|
||||
assert(svr.waitForString(10.seconds) { s =>
|
||||
s.contains("build/taskProgress") &&
|
||||
s.contains(""""message":"Compiling runAndTest (15%)"""")
|
||||
})
|
||||
|
||||
assert(svr.waitForString(10.seconds) { s =>
|
||||
s.contains("build/taskProgress") &&
|
||||
s.contains(""""message":"Compiling runAndTest (100%)"""")
|
||||
})
|
||||
|
||||
assert(svr.waitForString(10.seconds) { s =>
|
||||
s.contains("build/taskFinish") &&
|
||||
s.contains(""""message":"Compiled runAndTest"""")
|
||||
})
|
||||
}
|
||||
|
||||
test("buildTarget/scalacOptions") { _ =>
|
||||
val buildTarget = buildTargetUri("util", "Compile")
|
||||
val badBuildTarget = buildTargetUri("badBuildTarget", "Compile")
|
||||
|
|
|
|||
Loading…
Reference in New Issue