diff options
Diffstat (limited to 'core/src/test/scala/mill/eval/EvaluationTests.scala')
-rw-r--r-- | core/src/test/scala/mill/eval/EvaluationTests.scala | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/core/src/test/scala/mill/eval/EvaluationTests.scala b/core/src/test/scala/mill/eval/EvaluationTests.scala index 2b9dd102..31ae5ab9 100644 --- a/core/src/test/scala/mill/eval/EvaluationTests.scala +++ b/core/src/test/scala/mill/eval/EvaluationTests.scala @@ -7,7 +7,7 @@ import mill.{Module, T} import mill.discover.Discovered import mill.discover.Discovered.mapping import mill.util.{DummyLogger, TestGraphs, TestUtil} -import mill.util.Strict.OSet +import mill.util.Strict.Agg import utest._ import utest.framework.TestPath @@ -19,7 +19,7 @@ object EvaluationTests extends TestSuite{ def evaluator = new Evaluator(workspace, ammonite.ops.pwd, mapping, DummyLogger) def apply(target: Task[_], expValue: Any, - expEvaled: OSet[Task[_]], + expEvaled: Agg[Task[_]], // How many "other" tasks were evaluated other than those listed above. // Pass in -1 to skip the check entirely extraEvaled: Int = 0, @@ -28,7 +28,7 @@ object EvaluationTests extends TestSuite{ // are directly evaluating tasks which need to re-evaluate every time secondRunNoOp: Boolean = true) = { - val evaled = evaluator.evaluate(OSet(target)) + val evaled = evaluator.evaluate(Agg(target)) val (matchingReturnedEvaled, extra) = evaled.evaluated.indexed.partition(expEvaled.contains) @@ -40,8 +40,8 @@ object EvaluationTests extends TestSuite{ // Second time the value is already cached, so no evaluation needed if (secondRunNoOp){ - val evaled2 = evaluator.evaluate(OSet(target)) - val expecteSecondRunEvaluated = OSet() + val evaled2 = evaluator.evaluate(Agg(target)) + val expecteSecondRunEvaluated = Agg() assert( evaled2.values == evaled.values, evaled2.evaluated == expecteSecondRunEvaluated @@ -61,94 +61,94 @@ object EvaluationTests extends TestSuite{ import singleton._ val check = new Checker(mapping(singleton)) // First time the target is evaluated - check(single, expValue = 0, expEvaled = OSet(single)) + check(single, expValue = 0, expEvaled = Agg(single)) single.counter += 1 // After incrementing the counter, it forces re-evaluation - check(single, expValue = 1, expEvaled = OSet(single)) + check(single, expValue = 1, expEvaled = Agg(single)) } 'pair - { import pair._ val check = new Checker(mapping(pair)) - check(down, expValue = 0, expEvaled = OSet(up, down)) + check(down, expValue = 0, expEvaled = Agg(up, down)) down.counter += 1 - check(down, expValue = 1, expEvaled = OSet(down)) + check(down, expValue = 1, expEvaled = Agg(down)) up.counter += 1 - check(down, expValue = 2, expEvaled = OSet(up, down)) + check(down, expValue = 2, expEvaled = Agg(up, down)) } 'anonTriple - { import anonTriple._ val check = new Checker(mapping(anonTriple)) val middle = down.inputs(0) - check(down, expValue = 0, expEvaled = OSet(up, middle, down)) + check(down, expValue = 0, expEvaled = Agg(up, middle, down)) down.counter += 1 - check(down, expValue = 1, expEvaled = OSet(middle, down)) + check(down, expValue = 1, expEvaled = Agg(middle, down)) up.counter += 1 - check(down, expValue = 2, expEvaled = OSet(up, middle, down)) + check(down, expValue = 2, expEvaled = Agg(up, middle, down)) middle.asInstanceOf[TestUtil.Test].counter += 1 - check(down, expValue = 3, expEvaled = OSet(middle, down)) + check(down, expValue = 3, expEvaled = Agg(middle, down)) } 'diamond - { import diamond._ val check = new Checker(mapping(diamond)) - check(down, expValue = 0, expEvaled = OSet(up, left, right, down)) + check(down, expValue = 0, expEvaled = Agg(up, left, right, down)) down.counter += 1 - check(down, expValue = 1, expEvaled = OSet(down)) + check(down, expValue = 1, expEvaled = Agg(down)) up.counter += 1 // Increment by 2 because up is referenced twice: once by left once by right - check(down, expValue = 3, expEvaled = OSet(up, left, right, down)) + check(down, expValue = 3, expEvaled = Agg(up, left, right, down)) left.counter += 1 - check(down, expValue = 4, expEvaled = OSet(left, down)) + check(down, expValue = 4, expEvaled = Agg(left, down)) right.counter += 1 - check(down, expValue = 5, expEvaled = OSet(right, down)) + check(down, expValue = 5, expEvaled = Agg(right, down)) } 'anonDiamond - { import anonDiamond._ val check = new Checker(mapping(anonDiamond)) val left = down.inputs(0).asInstanceOf[TestUtil.Test] val right = down.inputs(1).asInstanceOf[TestUtil.Test] - check(down, expValue = 0, expEvaled = OSet(up, left, right, down)) + check(down, expValue = 0, expEvaled = Agg(up, left, right, down)) down.counter += 1 - check(down, expValue = 1, expEvaled = OSet(left, right, down)) + check(down, expValue = 1, expEvaled = Agg(left, right, down)) up.counter += 1 // Increment by 2 because up is referenced twice: once by left once by right - check(down, expValue = 3, expEvaled = OSet(up, left, right, down)) + check(down, expValue = 3, expEvaled = Agg(up, left, right, down)) left.counter += 1 - check(down, expValue = 4, expEvaled = OSet(left, right, down)) + check(down, expValue = 4, expEvaled = Agg(left, right, down)) right.counter += 1 - check(down, expValue = 5, expEvaled = OSet(left, right, down)) + check(down, expValue = 5, expEvaled = Agg(left, right, down)) } 'bigSingleTerminal - { import bigSingleTerminal._ val check = new Checker(mapping(bigSingleTerminal)) - check(j, expValue = 0, expEvaled = OSet(a, b, e, f, i, j), extraEvaled = 22) + check(j, expValue = 0, expEvaled = Agg(a, b, e, f, i, j), extraEvaled = 22) j.counter += 1 - check(j, expValue = 1, expEvaled = OSet(j), extraEvaled = 3) + check(j, expValue = 1, expEvaled = Agg(j), extraEvaled = 3) i.counter += 1 // increment value by 2 because `i` is used twice on the way to `j` - check(j, expValue = 3, expEvaled = OSet(j, i), extraEvaled = 8) + check(j, expValue = 3, expEvaled = Agg(j, i), extraEvaled = 8) b.counter += 1 // increment value by 4 because `b` is used four times on the way to `j` - check(j, expValue = 7, expEvaled = OSet(b, e, f, i, j), extraEvaled = 20) + check(j, expValue = 7, expEvaled = Agg(b, e, f, i, j), extraEvaled = 20) } } @@ -159,16 +159,16 @@ object EvaluationTests extends TestSuite{ import separateGroups._ val checker = new Checker(mapping(separateGroups)) - val evaled1 = checker.evaluator.evaluate(OSet(right, left)) + val evaled1 = checker.evaluator.evaluate(Agg(right, left)) val filtered1 = evaled1.evaluated.filter(_.isInstanceOf[Target[_]]) - assert(filtered1 == OSet(change, left, right)) - val evaled2 = checker.evaluator.evaluate(OSet(right, left)) + assert(filtered1 == Agg(change, left, right)) + val evaled2 = checker.evaluator.evaluate(Agg(right, left)) val filtered2 = evaled2.evaluated.filter(_.isInstanceOf[Target[_]]) - assert(filtered2 == OSet()) + assert(filtered2 == Agg()) change.counter += 1 - val evaled3 = checker.evaluator.evaluate(OSet(right, left)) + val evaled3 = checker.evaluator.evaluate(Agg(right, left)) val filtered3 = evaled3.evaluated.filter(_.isInstanceOf[Target[_]]) - assert(filtered3 == OSet(change, right)) + assert(filtered3 == Agg(change, right)) } @@ -176,16 +176,16 @@ object EvaluationTests extends TestSuite{ import triangleTask._ val checker = new Checker(mapping(triangleTask)) - checker(right, 3, OSet(left, right), extraEvaled = -1) - checker(left, 1, OSet(), extraEvaled = -1) + checker(right, 3, Agg(left, right), extraEvaled = -1) + checker(left, 1, Agg(), extraEvaled = -1) } 'multiTerminalGroup - { import multiTerminalGroup._ val checker = new Checker(mapping(multiTerminalGroup)) - checker(right, 1, OSet(right), extraEvaled = -1) - checker(left, 1, OSet(left), extraEvaled = -1) + checker(right, 1, Agg(right), extraEvaled = -1) + checker(left, 1, Agg(left), extraEvaled = -1) } 'multiTerminalBoundary - { @@ -193,15 +193,15 @@ object EvaluationTests extends TestSuite{ import multiTerminalBoundary._ val checker = new Checker(mapping(multiTerminalBoundary)) - checker(task2, 4, OSet(right, left), extraEvaled = -1, secondRunNoOp = false) - checker(task2, 4, OSet(), extraEvaled = -1, secondRunNoOp = false) + checker(task2, 4, Agg(right, left), extraEvaled = -1, secondRunNoOp = false) + checker(task2, 4, Agg(), extraEvaled = -1, secondRunNoOp = false) } 'overrideSuperTask - { import canOverrideSuper._ val checker = new Checker(mapping(canOverrideSuper)) - checker(foo, Seq("base", "object"), OSet(foo), extraEvaled = -1) + checker(foo, Seq("base", "object"), Agg(foo), extraEvaled = -1) } 'tasksAreUncached - { @@ -239,12 +239,12 @@ object EvaluationTests extends TestSuite{ // cached target val check = new Checker(mapping(build)) assert(leftCount == 0, rightCount == 0) - check(down, expValue = 10101, expEvaled = OSet(up, right, down), extraEvaled = 8) + check(down, expValue = 10101, expEvaled = Agg(up, right, down), extraEvaled = 8) assert(leftCount == 1, middleCount == 1, rightCount == 1) // If the upstream `up` doesn't change, the entire block of tasks // doesn't need to recompute - check(down, expValue = 10101, expEvaled = OSet()) + check(down, expValue = 10101, expEvaled = Agg()) assert(leftCount == 1, middleCount == 1, rightCount == 1) // But if `up` changes, the entire block of downstream tasks needs to @@ -252,19 +252,19 @@ object EvaluationTests extends TestSuite{ // because tasks have no cached value that can be used. `right`, which // is a cached Target, does not recompute up.inputs(0).asInstanceOf[Test].counter += 1 - check(down, expValue = 10102, expEvaled = OSet(up, down), extraEvaled = 6) + check(down, expValue = 10102, expEvaled = Agg(up, down), extraEvaled = 6) assert(leftCount == 2, middleCount == 2, rightCount == 1) // Running the tasks themselves results in them being recomputed every // single time, even if nothing changes - check(left, expValue = 2, expEvaled = OSet(), extraEvaled = 1, secondRunNoOp = false) + check(left, expValue = 2, expEvaled = Agg(), extraEvaled = 1, secondRunNoOp = false) assert(leftCount == 3, middleCount == 2, rightCount == 1) - check(left, expValue = 2, expEvaled = OSet(), extraEvaled = 1, secondRunNoOp = false) + check(left, expValue = 2, expEvaled = Agg(), extraEvaled = 1, secondRunNoOp = false) assert(leftCount == 4, middleCount == 2, rightCount == 1) - check(middle, expValue = 100, expEvaled = OSet(), extraEvaled = 2, secondRunNoOp = false) + check(middle, expValue = 100, expEvaled = Agg(), extraEvaled = 2, secondRunNoOp = false) assert(leftCount == 4, middleCount == 3, rightCount == 1) - check(middle, expValue = 100, expEvaled = OSet(), extraEvaled = 2, secondRunNoOp = false) + check(middle, expValue = 100, expEvaled = Agg(), extraEvaled = 2, secondRunNoOp = false) assert(leftCount == 4, middleCount == 4, rightCount == 1) } } |