diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-03 19:16:23 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-03 19:16:23 -0800 |
commit | ec39948ed1333699daf246e2ba37ccec67db5bd2 (patch) | |
tree | a9d46242337543bcf589c33a596e7edf91b64664 /core | |
parent | 6fa39162250c2477b3c9d322c453dfd51646245b (diff) | |
download | mill-ec39948ed1333699daf246e2ba37ccec67db5bd2.tar.gz mill-ec39948ed1333699daf246e2ba37ccec67db5bd2.tar.bz2 mill-ec39948ed1333699daf246e2ba37ccec67db5bd2.zip |
Make use of `CrossScalaModule` in `HelloWorldTests`
Also standardize the `HelloWorldTests` onto the typical project layout, where the module of interest is nested within a top-level `BaseModule`
Diffstat (limited to 'core')
-rw-r--r-- | core/src/mill/eval/Evaluator.scala | 3 | ||||
-rw-r--r-- | core/src/mill/eval/Result.scala | 12 | ||||
-rw-r--r-- | core/src/mill/main/ReplApplyHandler.scala | 4 | ||||
-rw-r--r-- | core/src/mill/main/RunScript.scala | 3 | ||||
-rw-r--r-- | core/test/src/mill/eval/FailureTests.scala | 3 | ||||
-rw-r--r-- | core/test/src/mill/util/TestEvaluator.scala | 3 | ||||
-rw-r--r-- | core/test/src/mill/util/TestUtil.scala | 3 |
7 files changed, 23 insertions, 8 deletions
diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala index 9d65e95f..bb78a020 100644 --- a/core/src/mill/eval/Evaluator.scala +++ b/core/src/mill/eval/Evaluator.scala @@ -6,6 +6,7 @@ import ammonite.main.Router.EntryPoint import ammonite.ops._ import ammonite.runtime.SpecialClassLoader import mill.define.{Ctx => _, _} +import mill.eval.Result.OuterStack import mill.util import mill.util._ import mill.util.Strict.Agg @@ -274,7 +275,7 @@ class Evaluator[T](val outPath: Path, } }catch{ case NonFatal(e) => - Result.Exception(e, currentStack) + Result.Exception(e, new OuterStack(currentStack)) }finally{ System.setErr(err) System.setOut(out) diff --git a/core/src/mill/eval/Result.scala b/core/src/mill/eval/Result.scala index 174dfcd1..f5293c8c 100644 --- a/core/src/mill/eval/Result.scala +++ b/core/src/mill/eval/Result.scala @@ -10,11 +10,19 @@ sealed trait Result[+T]{ object Result{ implicit def create[T](t: => T): Result[T] = { try Success(t) - catch { case e: Throwable => Exception(e, new java.lang.Exception().getStackTrace) } + catch { case e: Throwable => Exception(e, new OuterStack(new java.lang.Exception().getStackTrace)) } } case class Success[T](value: T) extends Result[T] case object Skipped extends Result[Nothing] sealed trait Failing extends Result[Nothing] case class Failure(msg: String) extends Failing - case class Exception(throwable: Throwable, outerStack: Seq[StackTraceElement]) extends Failing + case class Exception(throwable: Throwable, outerStack: OuterStack) extends Failing + class OuterStack(val value: Seq[StackTraceElement]){ + override def hashCode() = value.hashCode() + + override def equals(obj: scala.Any) = obj match{ + case o: OuterStack => value.equals(o.value) + case _ => false + } + } }
\ No newline at end of file diff --git a/core/src/mill/main/ReplApplyHandler.scala b/core/src/mill/main/ReplApplyHandler.scala index 387951b2..66f80630 100644 --- a/core/src/mill/main/ReplApplyHandler.scala +++ b/core/src/mill/main/ReplApplyHandler.scala @@ -54,7 +54,9 @@ class ReplApplyHandler(pprinter0: pprint.PPrinter, case Result.Failure(m) => msg.append(m + "\n") case Result.Exception(t, outerStack) => msg.append( - t.toString + t.getStackTrace.dropRight(outerStack.length).map("\n " + _).mkString + "\n" + t.toString + + t.getStackTrace.dropRight(outerStack.value.length).map("\n " + _).mkString + + "\n" ) } diff --git a/core/src/mill/main/RunScript.scala b/core/src/mill/main/RunScript.scala index 55fd8937..e5c92e3e 100644 --- a/core/src/mill/main/RunScript.scala +++ b/core/src/mill/main/RunScript.scala @@ -173,7 +173,8 @@ object RunScript{ } val fss = fs.map{ case Result.Exception(t, outerStack) => - t.toString + t.getStackTrace.dropRight(outerStack.length).map("\n " + _).mkString + t.toString + + t.getStackTrace.dropRight(outerStack.value.length).map("\n " + _).mkString case Result.Failure(t) => t } s"$ks ${fss.mkString(", ")}" diff --git a/core/test/src/mill/eval/FailureTests.scala b/core/test/src/mill/eval/FailureTests.scala index 48209b4e..91b1851d 100644 --- a/core/test/src/mill/eval/FailureTests.scala +++ b/core/test/src/mill/eval/FailureTests.scala @@ -2,6 +2,7 @@ package mill.eval import mill.T import mill.util.{TestEvaluator, TestUtil} import ammonite.ops.{Path, pwd, rm} +import mill.eval.Result.OuterStack import utest._ import utest.framework.TestPath import mill.util.TestEvaluator.implicitDisover @@ -43,7 +44,7 @@ object FailureTests extends TestSuite{ check.fail( target = singleton.single, expectedFailCount = 1, - expectedRawValues = Seq(Result.Exception(ex, Nil)) + expectedRawValues = Seq(Result.Exception(ex, new OuterStack(Nil))) ) } 'evaluatePair - { diff --git a/core/test/src/mill/util/TestEvaluator.scala b/core/test/src/mill/util/TestEvaluator.scala index ee92c2c2..8ef12417 100644 --- a/core/test/src/mill/util/TestEvaluator.scala +++ b/core/test/src/mill/util/TestEvaluator.scala @@ -3,6 +3,7 @@ package mill.util import ammonite.ops.{Path, pwd} import mill.define.Discover.applyImpl import mill.define.{Discover, Input, Target, Task} +import mill.eval.Result.OuterStack import mill.eval.{Evaluator, Result} import mill.util.Strict.Agg import utest.assert @@ -57,7 +58,7 @@ class TestEvaluator[T <: TestUtil.TestBuild](module: T) val res = evaluator.evaluate(Agg(target)) val cleaned = res.rawValues.map{ - case Result.Exception(ex, _) => Result.Exception(ex, Nil) + case Result.Exception(ex, _) => Result.Exception(ex, new OuterStack(Nil)) case x => x } diff --git a/core/test/src/mill/util/TestUtil.scala b/core/test/src/mill/util/TestUtil.scala index 1413e9c6..59ef74df 100644 --- a/core/test/src/mill/util/TestUtil.scala +++ b/core/test/src/mill/util/TestUtil.scala @@ -4,6 +4,7 @@ import ammonite.main.Router.Overrides import ammonite.ops.pwd import mill.define._ import mill.eval.Result +import mill.eval.Result.OuterStack import utest.assert import mill.util.Strict.Agg import utest.framework.TestPath @@ -49,7 +50,7 @@ object TestUtil { var exception = Option.empty[Throwable] override def evaluate(args: Ctx) = { failure.map(Result.Failure) orElse - exception.map(Result.Exception(_, Nil)) getOrElse + exception.map(Result.Exception(_, new OuterStack(Nil))) getOrElse Result.Success(counter + args.args.map(_.asInstanceOf[Int]).sum) } override def sideHash = counter + failure.hashCode() + exception.hashCode() |