Skip to content

Commit

Permalink
Added cmdline option -k/--keep-going
Browse files Browse the repository at this point in the history
See #477
  • Loading branch information
lefou committed Dec 21, 2018
1 parent 54bb990 commit 0cea8f6
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
18 changes: 15 additions & 3 deletions main/src/MillMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,18 @@ object MillMain {
}
)

var keepGoing = false
val keepGoingSignature = Arg[Config, Unit] (
name = "keep-going", shortName = Some('k'), doc = "Continue build, even after build failures",
(c,v) => {
keepGoing = true
c
}
)

val millArgSignature =
Cli.genericSignature.filter(a => !removed(a.name)) ++ Seq(interactiveSignature, disableTickerSignature, debugLogSignature)
Cli.genericSignature.filter(a => !removed(a.name)) ++
Seq(interactiveSignature, disableTickerSignature, debugLogSignature, keepGoingSignature)

Cli.groupArgs(
args.toList,
Expand Down Expand Up @@ -115,7 +125,8 @@ object MillMain {
| repl.pprinter(),
| build.millSelf.get,
| build.millDiscover,
| $debugLog
| $debugLog,
| keepGoing = $keepGoing
|)
|repl.pprinter() = replApplyHandler.pprinter
|import replApplyHandler.generatedEval._
Expand All @@ -131,7 +142,8 @@ object MillMain {
stateCache,
env,
setIdle,
debugLog
debugLog,
keepGoing = keepGoing
)

if (mill.main.client.Util.isJava9OrAbove) {
Expand Down
6 changes: 4 additions & 2 deletions main/src/main/MainRunner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class MainRunner(val config: ammonite.main.Cli.Config,
stateCache0: Option[Evaluator.State] = None,
env : Map[String, String],
setIdle: Boolean => Unit,
debugLog: Boolean)
debugLog: Boolean,
keepGoing: Boolean)
extends ammonite.MainRunner(
config, outprintStream, errPrintStream,
stdIn, outprintStream, errPrintStream
Expand Down Expand Up @@ -83,7 +84,8 @@ class MainRunner(val config: ammonite.main.Cli.Config,
stdIn,
debugEnabled = debugLog
),
env
env,
keepGoing = keepGoing
)

result match{
Expand Down
6 changes: 3 additions & 3 deletions main/src/main/MillServerMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ object MillServerMain extends mill.main.MillServerMain[Evaluator.State]{
MillMain.main0(
args,
stateCache,
mainInteractive,
mainInteractive = mainInteractive,
DummyInputStream,
stdout,
stderr,
env,
setIdle
setIdle = setIdle
)
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ class Server[T](lockBase: String,
stdout,
stderr,
env.asScala.toMap,
idle = _
idle = _,
)

sm.stateCache = newStateCache
Expand Down
6 changes: 4 additions & 2 deletions main/src/main/ReplApplyHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ object ReplApplyHandler{
pprinter0: pprint.PPrinter,
rootModule: mill.define.BaseModule,
discover: Discover[_],
debugLog: Boolean) = {
debugLog: Boolean,
keepGoing: Boolean) = {
new ReplApplyHandler(
pprinter0,
new Evaluator(
Expand All @@ -33,7 +34,8 @@ object ReplApplyHandler{
System.err,
System.in,
debugEnabled = debugLog
)
),
failFast = !keepGoing
)
)
}
Expand Down
5 changes: 3 additions & 2 deletions main/src/main/RunScript.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ object RunScript{
scriptArgs: Seq[String],
stateCache: Option[Evaluator.State],
log: Logger,
env : Map[String, String])
env : Map[String, String],
keepGoing: Boolean)
: (Res[(Evaluator, Seq[PathRef], Either[String, Seq[ujson.Value]])], Seq[(os.Path, Long)]) = {

val (evalState, interpWatched) = stateCache match{
Expand All @@ -54,7 +55,7 @@ object RunScript{
val evalRes =
for(s <- evalState)
yield new Evaluator(home, wd / 'out, wd / 'out, s.rootModule, log,
s.classLoaderSig, s.workerCache, env)
s.classLoaderSig, s.workerCache, env, failFast = !keepGoing)

val evaluated = for{
evaluator <- evalRes
Expand Down
3 changes: 2 additions & 1 deletion main/test/src/util/ScriptTestSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ abstract class ScriptTestSuite(fork: Boolean) extends TestSuite{
val stdIn = new ByteArrayInputStream(Array())
val disableTicker = false
val debugLog = false
val keepGoing = false
lazy val runner = new mill.main.MainRunner(
ammonite.main.Cli.Config(wd = wd), disableTicker,
stdOutErr, stdOutErr, stdIn, None, Map.empty,
b => (), debugLog
b => (), debugLog, keepGoing = keepGoing
)
def eval(s: String*) = {
if (!fork) runner.runScript(workspacePath / buildPath , s.toList)
Expand Down

0 comments on commit 0cea8f6

Please # to comment.