diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-18 13:04:04 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-18 13:04:04 -0800 |
commit | 910b49da3f068768fd5826407759aa4defbcfdf4 (patch) | |
tree | 940abe301f8545e7accb351e7cfffc140da30291 /core/src/test | |
parent | 8e8173e3afe60e162067fdc3440e451cc2d0da9c (diff) | |
download | mill-910b49da3f068768fd5826407759aa4defbcfdf4.tar.gz mill-910b49da3f068768fd5826407759aa4defbcfdf4.tar.bz2 mill-910b49da3f068768fd5826407759aa4defbcfdf4.zip |
Inject logging callback into Evaluator, so we can silence the logging in our unit tests
Diffstat (limited to 'core/src/test')
4 files changed, 4 insertions, 82 deletions
diff --git a/core/src/test/scala/mill/MacroErrorTests.scala b/core/src/test/scala/mill/MacroErrorTests.scala deleted file mode 100644 index b9de5594..00000000 --- a/core/src/test/scala/mill/MacroErrorTests.scala +++ /dev/null @@ -1,78 +0,0 @@ -package mill - -import utest._ - -object MacroErrorTests extends TestSuite{ - - val tests = Tests{ - - 'errors{ - val expectedMsg = - "T{} members must be defs defined in a Cacher class/trait/object body" - - val err = compileError("object Foo extends mill.define.Task.Module{ val x = T{1} }") - assert(err.msg == expectedMsg) - } - - 'badTmacro - { - // Make sure we can reference values from outside the T{...} block as part - // of our `Target#apply()` calls, but we cannot reference any values that - // come from inside the T{...} block - 'pos - { - val e = compileError(""" - val a = T{ 1 } - val arr = Array(a) - val b = { - val c = 0 - T{ - arr(c)() - } - } - """) - assert(e.msg.contains("must be defs")) - } - 'neg - { - - val expectedMsg = - "Target#apply() call cannot use `value n` defined within the T{...} block" - val err = compileError("""new mill.define.Task.Module{ - def a = T{ 1 } - val arr = Array(a) - def b = { - T{ - val n = 0 - arr(n)() - } - } - }""") - assert(err.msg == expectedMsg) - } - 'neg2 - { - - val expectedMsg = - "Target#apply() call cannot use `value x` defined within the T{...} block" - val err = compileError("""new mill.define.Task.Module{ - def a = T{ 1 } - val arr = Array(a) - def b = { - T{ - arr.map{x => x()} - } - } - }""") - assert(err.msg == expectedMsg) - } - 'neg3{ - val borkedCachedDiamond1 = utest.compileError(""" - object borkedCachedDiamond1 { - def up = T{ TestUtil.test() } - def left = T{ TestUtil.test(up) } - def right = T{ TestUtil.test(up) } - def down = T{ TestUtil.test(left, right) } - } - """) - assert(borkedCachedDiamond1.msg.contains("must be defs")) - } - } - } -} diff --git a/core/src/test/scala/mill/define/CacherTests.scala b/core/src/test/scala/mill/define/CacherTests.scala index f3d07a29..bb86ae65 100644 --- a/core/src/test/scala/mill/define/CacherTests.scala +++ b/core/src/test/scala/mill/define/CacherTests.scala @@ -27,7 +27,7 @@ object CacherTests extends TestSuite{ def eval[T: Discovered, V](base: T, v: Task[V])(implicit tp: TestPath) = { val workspace = ammonite.ops.pwd / 'target / 'workspace / tp.value - val evaluator = new Evaluator(workspace, Discovered.mapping(base)) + val evaluator = new Evaluator(workspace, Discovered.mapping(base), _ => ()) evaluator.evaluate(OSet(v)).values(0) } diff --git a/core/src/test/scala/mill/eval/EvaluationTests.scala b/core/src/test/scala/mill/eval/EvaluationTests.scala index 3b268911..ccb476e7 100644 --- a/core/src/test/scala/mill/eval/EvaluationTests.scala +++ b/core/src/test/scala/mill/eval/EvaluationTests.scala @@ -15,7 +15,7 @@ object EvaluationTests extends TestSuite{ val workspace = ammonite.ops.pwd / 'target / 'workspace / tp.value ammonite.ops.rm(ammonite.ops.Path(workspace, ammonite.ops.pwd)) // Make sure data is persisted even if we re-create the evaluator each time - def evaluator = new Evaluator(workspace, Discovered.mapping(base)) + def evaluator = new Evaluator(workspace, Discovered.mapping(base), _ => ()) def apply(target: Task[_], expValue: Any, expEvaled: OSet[Task[_]], diff --git a/core/src/test/scala/mill/eval/JavaCompileJarTests.scala b/core/src/test/scala/mill/eval/JavaCompileJarTests.scala index 6ec03cf3..72e8c858 100644 --- a/core/src/test/scala/mill/eval/JavaCompileJarTests.scala +++ b/core/src/test/scala/mill/eval/JavaCompileJarTests.scala @@ -49,7 +49,7 @@ object JavaCompileJarTests extends TestSuite{ val mapping = Discovered.mapping(Build) def eval[T](t: Task[T]): Either[Result.Failing, (T, Int)] = { - val evaluator = new Evaluator(workspacePath, mapping) + val evaluator = new Evaluator(workspacePath, mapping, _ => ()) val evaluated = evaluator.evaluate(OSet(t)) if (evaluated.failing.keyCount == 0){ @@ -66,7 +66,7 @@ object JavaCompileJarTests extends TestSuite{ } def check(targets: OSet[Task[_]], expected: OSet[Task[_]]) = { - val evaluator = new Evaluator(workspacePath, mapping) + val evaluator = new Evaluator(workspacePath, mapping, _ => ()) val evaluated = evaluator.evaluate(targets) .evaluated |