diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-25 19:46:53 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-25 19:46:53 -0800 |
commit | 5557966d2e96c1711978a8b1606bd6c20d26030c (patch) | |
tree | a858babfe9f06a9e7e5d9763ca6fa39d2cfe8b27 /core/src/main/scala | |
parent | c7102daadc19a7f763b21d5bb16de7a07932168a (diff) | |
download | mill-5557966d2e96c1711978a8b1606bd6c20d26030c.tar.gz mill-5557966d2e96c1711978a8b1606bd6c20d26030c.tar.bz2 mill-5557966d2e96c1711978a8b1606bd6c20d26030c.zip |
improve task failure pretty-printing
Diffstat (limited to 'core/src/main/scala')
-rw-r--r-- | core/src/main/scala/mill/Main.scala | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/core/src/main/scala/mill/Main.scala b/core/src/main/scala/mill/Main.scala index cf840a51..829b684c 100644 --- a/core/src/main/scala/mill/Main.scala +++ b/core/src/main/scala/mill/Main.scala @@ -117,7 +117,7 @@ object Main { def evaluate(evaluator: Evaluator, target: Task[Any], - watch: Path => Unit): Either[String, Int] = { + watch: Path => Unit): Option[String] = { val evaluated = evaluator.evaluate(OSet(target)) evaluated.transitive.foreach { case t: define.Source => watch(t.handle.path) @@ -125,10 +125,10 @@ object Main { } val errorStr = - (for((k, fs) <- evaluated.failing.items) yield { + (for((k, fs) <- evaluated.failing.items()) yield { val ks = k match{ case Left(t) => t.toString - case Right(t) => t.segments.mkString(".") + case Right(t) => renderSelector(t.segments.toList) } val fss = fs.map{ case Result.Exception(t) => t.toString @@ -138,10 +138,8 @@ object Main { }).mkString("\n") evaluated.failing.keyCount match { - case 0 => - Right(0) - case n => - Left(s"$n targets failed\n$errorStr") + case 0 => None + case n => Some(s"$n targets failed\n$errorStr") } } @@ -154,26 +152,23 @@ object Main { val Seq(selectorString, rest @_*) = args - val res = - for { - sel <- parseArgs(selectorString) - disc <- discoverMirror(obj) - val crossSelectors = sel.map{case Mirror.Segment.Cross(x) => x.toList.map(_.toString) case _ => Nil} - target <- resolve(sel, disc.mirror, obj, rest, crossSelectors, Nil) - val mapping = Discovered.mapping(obj)(disc) - val workspacePath = pwd / 'out - val evaluator = new Evaluator(workspacePath, mapping, log.info) - r <- evaluate(evaluator, target, watch) - } yield { - r + val res = for { + sel <- parseArgs(selectorString) + disc <- discoverMirror(obj) + crossSelectors = sel.map{ + case Mirror.Segment.Cross(x) => x.toList.map(_.toString) + case _ => Nil } + target <- resolve(sel, disc.mirror, obj, rest, crossSelectors, Nil) + evaluator = new Evaluator(pwd / 'out, Discovered.mapping(obj)(disc), log.info) + _ <- evaluate(evaluator, target, watch).toLeft(()) + } yield () res match { case Left(err) => log.error(err) 1 - case Right(n) => - n + case Right(_) => 0 } } |