# verify that reloading occurs if watchOnStart returns Watch.Reload
$ copy-file changes/extra.sbt extra.sbt

> ~compile
> checkReloaded

# verify that the watch terminates when we reach the specified count
> resetCount
> set watchOnIteration := { (count: Int) => if (count == 2) Watch.CancelWatch else Watch.Ignore }
> ~compile
> checkCount 2

# verify that the watch terminates and returns an error when we reach the specified count
> resetCount
> set watchOnIteration := { (count: Int) => if (count == 2) new Watch.HandleError(new Exception("")) else Watch.Ignore }
# Returning Watch.HandleError causes the '~' command to fail
-> ~compile
> checkCount 2

# verify that a re-build is triggered when we reach the specified count
> resetCount
> set watchOnIteration := { (count: Int) => if (count == 2) Watch.Trigger else if (count == 3) Watch.CancelWatch else Watch.Ignore }
> ~compile
> checkCount 3
