Abort early in watch multi commands

During refactoring of Continuous, I inadvertently changed the semantics
of `~` so that all multi commands were run regardless of whether or not
an earlier command had failed. I fixed the issue and added a regression
test.
This commit is contained in:
Ethan Atkins 2019-08-27 10:37:24 -07:00
parent 110f54a044
commit 6ec9edb733
5 changed files with 15 additions and 2 deletions

View File

@ -243,7 +243,7 @@ private[sbt] object Continuous extends DeprecatedContinuous {
case exec :: rest =>
val updatedState = MainLoop.processCommand(exec, s.copy(remainingCommands = rest))
val remaining =
updatedState.remainingCommands.takeWhile(_.commandLine != FailureWall)
updatedState.remainingCommands.takeWhile(_.commandLine != failureCommandName)
remaining match {
case Nil =>
updatedState.remainingCommands.forall(_.commandLine != failureCommandName)
@ -351,7 +351,7 @@ private[sbt] object Continuous extends DeprecatedContinuous {
currentCount.getAndIncrement()
callbacks.beforeCommand()
// abort as soon as one of the tasks fails
valid.takeWhile(_._3.apply())
valid.takeWhile { case (_, _, task) => task() }
updateLegacyWatchState(s, configs.flatMap(_.inputs().map(_.glob)), currentCount.get())
()
}

View File

@ -0,0 +1,8 @@
import java.nio.file._
watchOnIteration := { (_, _, _) => Watch.CancelWatch }
val copyFile = taskKey[Unit]("copy a file")
copyFile := {
val base = baseDirectory.value.toPath
Files.copy(base / "changes" / "Foo.txt", base / "Foo.txt")
}

View File

@ -0,0 +1 @@
foo

View File

@ -0,0 +1 @@
object Foo {

View File

@ -0,0 +1,3 @@
> ~compile; copyFile
$ absent Foo.txt