diff options
Diffstat (limited to 'core/src')
17 files changed, 184 insertions, 184 deletions
diff --git a/core/src/main/scala/mill/define/Graph.scala b/core/src/main/scala/mill/define/Graph.scala index 68fb65ed..f06dca11 100644 --- a/core/src/main/scala/mill/define/Graph.scala +++ b/core/src/main/scala/mill/define/Graph.scala @@ -2,17 +2,17 @@ package mill.define import mill.eval.Tarjans import mill.util.MultiBiMap -import mill.util.Strict.OSet +import mill.util.Strict.Agg object Graph { - class TopoSorted private[Graph](val values: OSet[Task[_]]) + class TopoSorted private[Graph](val values: Agg[Task[_]]) def groupAroundImportantTargets[T](topoSortedTargets: TopoSorted) (important: PartialFunction[Task[_], T]): MultiBiMap[T, Task[_]] = { val output = new MultiBiMap.Mutable[T, Task[_]]() for ((target, t) <- topoSortedTargets.values.flatMap(t => important.lift(t).map((t, _)))) { - val transitiveTargets = new OSet.Mutable[Task[_]] + val transitiveTargets = new Agg.Mutable[Task[_]] def rec(t: Task[_]): Unit = { if (transitiveTargets.contains(t)) () // do nothing else if (important.isDefinedAt(t) && t != target) () // do nothing @@ -27,8 +27,8 @@ object Graph { output } - def transitiveTargets(sourceTargets: OSet[Task[_]]): OSet[Task[_]] = { - val transitiveTargets = new OSet.Mutable[Task[_]] + def transitiveTargets(sourceTargets: Agg[Task[_]]): Agg[Task[_]] = { + val transitiveTargets = new Agg.Mutable[Task[_]] def rec(t: Task[_]): Unit = { if (transitiveTargets.contains(t)) () // do nothing else { @@ -44,7 +44,7 @@ object Graph { * Takes the given targets, finds all the targets they transitively depend * on, and sort them topologically. Fails if there are dependency cycles */ - def topoSorted(transitiveTargets: OSet[Task[_]]): TopoSorted = { + def topoSorted(transitiveTargets: Agg[Task[_]]): TopoSorted = { val indexed = transitiveTargets.indexed val targetIndices = indexed.zipWithIndex.toMap @@ -56,6 +56,6 @@ object Graph { val sortedClusters = Tarjans(numberedEdges) val nonTrivialClusters = sortedClusters.filter(_.length > 1) assert(nonTrivialClusters.isEmpty, nonTrivialClusters) - new TopoSorted(OSet.from(sortedClusters.flatten.map(indexed))) + new TopoSorted(Agg.from(sortedClusters.flatten.map(indexed))) } } diff --git a/core/src/main/scala/mill/discover/Discovered.scala b/core/src/main/scala/mill/discover/Discovered.scala index b7ec2140..98d4ebb9 100644 --- a/core/src/main/scala/mill/discover/Discovered.scala +++ b/core/src/main/scala/mill/discover/Discovered.scala @@ -5,7 +5,7 @@ import ammonite.main.Router import ammonite.main.Router.EntryPoint import mill.discover.Mirror.TargetPoint import mill.util.Ctx.Loader -import mill.util.Strict.OSet +import mill.util.Strict.Agg import scala.language.experimental.macros import scala.reflect.macros.blackbox.Context @@ -28,7 +28,7 @@ object Discovered { (mirror, segments, resolvedNode) => Seq(resolvedNode -> mirror) }.toMap - val targets = OSet.from( + val targets = Agg.from( Mirror.traverseNode(base, mirror){ (mirror, segmentsRev, resolvedNode) => for(target <- mirror.targets) yield target.asInstanceOf[TargetPoint[Any, Any]].run(resolvedNode) @@ -44,7 +44,7 @@ object Discovered { val targetsToSegments = segmentsToTargets.map(_.swap) } - def consistencyCheck[T](mapping: Discovered.Mapping[T]): OSet[Segments] = { + def consistencyCheck[T](mapping: Discovered.Mapping[T]): Agg[Segments] = { val mapping2 = Discovered.Mapping(mapping.mirror, mapping.base) for{ (t1, t2) <- mapping2.targets.zip(mapping.targets) diff --git a/core/src/main/scala/mill/eval/Evaluator.scala b/core/src/main/scala/mill/eval/Evaluator.scala index 2afaec6e..28d90fcf 100644 --- a/core/src/main/scala/mill/eval/Evaluator.scala +++ b/core/src/main/scala/mill/eval/Evaluator.scala @@ -9,7 +9,7 @@ import mill.discover.{Discovered, Mirror} import mill.define.Segment import mill.util import mill.util._ -import mill.util.Strict.OSet +import mill.util.Strict.Agg import scala.collection.mutable import scala.util.control.NonFatal @@ -35,7 +35,7 @@ class Evaluator[T](val workspacePath: Path, val workerCache = mutable.Map.empty[Ctx.Loader[_], Any] workerCache(Discovered.Mapping) = mapping - def evaluate(goals: OSet[Task[_]]): Evaluator.Results = { + def evaluate(goals: Agg[Task[_]]): Evaluator.Results = { mkdir(workspacePath) val transitive = Graph.transitiveTargets(goals) @@ -55,7 +55,7 @@ class Evaluator[T](val workspacePath: Path, case t if goals.contains(t) => Left(t) } - val evaluated = new OSet.Mutable[Task[_]] + val evaluated = new Agg.Mutable[Task[_]] val results = mutable.LinkedHashMap.empty[Task[_], Result[Any]] for (((terminal, group), i) <- sortedGroups.items().zipWithIndex){ @@ -84,7 +84,7 @@ class Evaluator[T](val workspacePath: Path, def evaluateGroupCached(terminal: Either[Task[_], Labelled[_]], - group: OSet[Task[_]], + group: Agg[Task[_]], results: collection.Map[Task[_], Result[Any]], counterMsg: String): (collection.Map[Task[_], Result[Any]], Seq[Task[_]]) = { @@ -168,7 +168,7 @@ class Evaluator[T](val workspacePath: Path, } - def evaluateGroup(group: OSet[Task[_]], + def evaluateGroup(group: Agg[Task[_]], results: collection.Map[Task[_], Result[Any]], groupBasePath: Option[Path], paths: Option[Evaluator.Paths], @@ -275,8 +275,8 @@ object Evaluator{ } case class Results(rawValues: Seq[Result[Any]], - evaluated: OSet[Task[_]], - transitive: OSet[Task[_]], + evaluated: Agg[Task[_]], + transitive: Agg[Task[_]], failing: MultiBiMap[Either[Task[_], Labelled[_]], Result.Failing], results: collection.Map[Task[_], Result[Any]]){ def values = rawValues.collect{case Result.Success(v) => v} diff --git a/core/src/main/scala/mill/main/ReplApplyHandler.scala b/core/src/main/scala/mill/main/ReplApplyHandler.scala index b83453ee..c239745a 100644 --- a/core/src/main/scala/mill/main/ReplApplyHandler.scala +++ b/core/src/main/scala/mill/main/ReplApplyHandler.scala @@ -5,7 +5,7 @@ import mill.define.Applicative.ApplyHandler import mill.define._ import mill.discover.{Discovered, Mirror} import mill.eval.{Evaluator, Result} -import mill.util.Strict.OSet +import mill.util.Strict.Agg import scala.collection.mutable object ReplApplyHandler{ @@ -34,7 +34,7 @@ class ReplApplyHandler(pprinter0: pprint.PPrinter, evaluator: Evaluator[_]) exte // as the user enters more REPL commands and changes the classpath val classLoaderSig = Evaluator.classLoaderSig override def apply[V](t: Task[V]) = { - val res = evaluator.evaluate(OSet(t)) + val res = evaluator.evaluate(Agg(t)) res.values match{ case Seq(head: V) => head case Nil => diff --git a/core/src/main/scala/mill/main/RunScript.scala b/core/src/main/scala/mill/main/RunScript.scala index 9f73fbc8..785db80e 100644 --- a/core/src/main/scala/mill/main/RunScript.scala +++ b/core/src/main/scala/mill/main/RunScript.scala @@ -12,7 +12,7 @@ import mill.define.Segment import mill.discover.Discovered import mill.eval.{Evaluator, Result} import mill.util.{EitherOps, Logger} -import mill.util.Strict.OSet +import mill.util.Strict.Agg import upickle.Js /** @@ -138,7 +138,7 @@ object RunScript{ def evaluate(evaluator: Evaluator[_], targets: Seq[Task[Any]]): (Seq[PathRef], Either[String, Seq[(Any, Option[upickle.Js.Value])]]) = { - val evaluated = evaluator.evaluate(OSet.from(targets)) + val evaluated = evaluator.evaluate(Agg.from(targets)) val watched = evaluated.results .iterator .collect { diff --git a/core/src/main/scala/mill/modules/Jvm.scala b/core/src/main/scala/mill/modules/Jvm.scala index 6e3fe45f..48f100b2 100644 --- a/core/src/main/scala/mill/modules/Jvm.scala +++ b/core/src/main/scala/mill/modules/Jvm.scala @@ -9,15 +9,15 @@ import ammonite.ops._ import mill.define.Task import mill.eval.PathRef import mill.util.Ctx -import mill.util.Loose.OSet +import mill.util.Loose.Agg import scala.annotation.tailrec import scala.collection.mutable object Jvm { - def gatherClassloaderJars(): OSet[Path] = { - val allJars = new OSet.Mutable[Path]() + def gatherClassloaderJars(): Agg[Path] = { + val allJars = new Agg.Mutable[Path]() var currentClassloader = Thread.currentThread().getContextClassLoader while(currentClassloader != null){ currentClassloader match{ @@ -30,14 +30,14 @@ object Jvm { } def interactiveSubprocess(mainClass: String, - classPath: OSet[Path], + classPath: Agg[Path], options: Seq[String] = Seq.empty): Unit = { import ammonite.ops.ImplicitWd._ %("java", "-cp", classPath.mkString(":"), mainClass, options) } def subprocess(mainClass: String, - classPath: OSet[Path], + classPath: Agg[Path], jvmOptions: Seq[String] = Seq.empty, options: Seq[String] = Seq.empty, workingDir: Path = null) @@ -101,7 +101,7 @@ object Jvm { m } - def createJar(inputPaths: OSet[Path], mainClass: Option[String] = None) + def createJar(inputPaths: Agg[Path], mainClass: Option[String] = None) (implicit ctx: Ctx.DestCtx): PathRef = { val outputPath = ctx.dest rm(outputPath) @@ -135,7 +135,7 @@ object Jvm { PathRef(outputPath) } - def createAssembly(inputPaths: OSet[Path], + def createAssembly(inputPaths: Agg[Path], mainClass: Option[String] = None, prependShellScript: String = "") (implicit ctx: Ctx.DestCtx): PathRef = { diff --git a/core/src/main/scala/mill/package.scala b/core/src/main/scala/mill/package.scala index 0b4f4873..78233cad 100644 --- a/core/src/main/scala/mill/package.scala +++ b/core/src/main/scala/mill/package.scala @@ -8,6 +8,6 @@ package object mill extends JsonFormatters{ type Module = define.Module val Module = define.Module type Cross[T] = define.Cross[T] - type OSet[T] = util.Loose.OSet[T] - val OSet = util.Loose.OSet + type Agg[T] = util.Loose.Agg[T] + val Agg = util.Loose.Agg } diff --git a/core/src/main/scala/mill/util/MultiBiMap.scala b/core/src/main/scala/mill/util/MultiBiMap.scala index abbaa752..2cb81944 100644 --- a/core/src/main/scala/mill/util/MultiBiMap.scala +++ b/core/src/main/scala/mill/util/MultiBiMap.scala @@ -1,7 +1,7 @@ package mill.util import scala.collection.mutable -import Strict.OSet +import Strict.Agg /** * A map from keys to collections of values: you can assign multiple values * to any particular key. Also allows lookups in both directions: what values @@ -9,22 +9,22 @@ import Strict.OSet */ trait MultiBiMap[K, V]{ def containsValue(v: V): Boolean - def lookupKey(k: K): OSet[V] + def lookupKey(k: K): Agg[V] def lookupValue(v: V): K def lookupValueOpt(v: V): Option[K] def add(k: K, v: V): Unit - def removeAll(k: K): OSet[V] + def removeAll(k: K): Agg[V] def addAll(k: K, vs: TraversableOnce[V]): Unit def keys(): Iterator[K] - def items(): Iterator[(K, OSet[V])] - def values(): Iterator[OSet[V]] + def items(): Iterator[(K, Agg[V])] + def values(): Iterator[Agg[V]] def keyCount: Int } object MultiBiMap{ class Mutable[K, V]() extends MultiBiMap[K, V]{ private[this] val valueToKey = mutable.LinkedHashMap.empty[V, K] - private[this] val keyToValues = mutable.LinkedHashMap.empty[K, OSet.Mutable[V]] + private[this] val keyToValues = mutable.LinkedHashMap.empty[K, Agg.Mutable[V]] def containsValue(v: V) = valueToKey.contains(v) def lookupKey(k: K) = keyToValues(k) def lookupKeyOpt(k: K) = keyToValues.get(k) @@ -32,10 +32,10 @@ object MultiBiMap{ def lookupValueOpt(v: V) = valueToKey.get(v) def add(k: K, v: V): Unit = { valueToKey(v) = k - keyToValues.getOrElseUpdate(k, new OSet.Mutable[V]()).append(v) + keyToValues.getOrElseUpdate(k, new Agg.Mutable[V]()).append(v) } - def removeAll(k: K): OSet[V] = keyToValues.get(k) match { - case None => OSet() + def removeAll(k: K): Agg[V] = keyToValues.get(k) match { + case None => Agg() case Some(vs) => vs.foreach(valueToKey.remove) diff --git a/core/src/main/scala/mill/util/OSet.scala b/core/src/main/scala/mill/util/OSet.scala index a4fcc406..d0f41777 100644 --- a/core/src/main/scala/mill/util/OSet.scala +++ b/core/src/main/scala/mill/util/OSet.scala @@ -3,46 +3,46 @@ package mill.util import scala.collection.mutable -object Strict extends OSetWrapper(true) -object Loose extends OSetWrapper(false) -sealed class OSetWrapper(strictUniqueness: Boolean){ +object Strict extends AggWrapper(true) +object Loose extends AggWrapper(false) +sealed class AggWrapper(strictUniqueness: Boolean){ /** * A collection with enforced uniqueness, fast contains and deterministic * ordering. Raises an exception if a duplicate is found; call * `toSeq.distinct` if you explicitly want to make it swallow duplicates */ - trait OSet[V] extends TraversableOnce[V]{ + trait Agg[V] extends TraversableOnce[V]{ def contains(v: V): Boolean def items: Iterator[V] def indexed: IndexedSeq[V] - def flatMap[T](f: V => TraversableOnce[T]): OSet[T] - def map[T](f: V => T): OSet[T] - def filter(f: V => Boolean): OSet[V] - def withFilter(f: V => Boolean): OSet[V] - def collect[T](f: PartialFunction[V, T]): OSet[T] - def zipWithIndex: OSet[(V, Int)] - def reverse: OSet[V] - def zip[T](other: OSet[T]): OSet[(V, T)] - def ++[T >: V](other: TraversableOnce[T]): OSet[T] + def flatMap[T](f: V => TraversableOnce[T]): Agg[T] + def map[T](f: V => T): Agg[T] + def filter(f: V => Boolean): Agg[V] + def withFilter(f: V => Boolean): Agg[V] + def collect[T](f: PartialFunction[V, T]): Agg[T] + def zipWithIndex: Agg[(V, Int)] + def reverse: Agg[V] + def zip[T](other: Agg[T]): Agg[(V, T)] + def ++[T >: V](other: TraversableOnce[T]): Agg[T] } - object OSet{ - def empty[V]: OSet[V] = new OSet.Mutable[V] - implicit def jsonFormat[T: upickle.default.ReadWriter]: upickle.default.ReadWriter[OSet[T]] = - upickle.default.ReadWriter[OSet[T]] ( + object Agg{ + def empty[V]: Agg[V] = new Agg.Mutable[V] + implicit def jsonFormat[T: upickle.default.ReadWriter]: upickle.default.ReadWriter[Agg[T]] = + upickle.default.ReadWriter[Agg[T]] ( oset => upickle.default.writeJs(oset.toList), - {case json => OSet.from(upickle.default.readJs[Seq[T]](json))} + {case json => Agg.from(upickle.default.readJs[Seq[T]](json))} ) def apply[V](items: V*) = from(items) - def from[V](items: TraversableOnce[V]): OSet[V] = { - val set = new OSet.Mutable[V]() + def from[V](items: TraversableOnce[V]): Agg[V] = { + val set = new Agg.Mutable[V]() items.foreach(set.append) set } - class Mutable[V]() extends OSet[V]{ + class Mutable[V]() extends Agg[V]{ private[this] val set0 = mutable.LinkedHashSet.empty[V] def contains(v: V) = set0.contains(v) @@ -57,22 +57,22 @@ sealed class OSetWrapper(strictUniqueness: Boolean){ def indexed: IndexedSeq[V] = items.toIndexedSeq def set: collection.Set[V] = set0 - def map[T](f: V => T): OSet[T] = { - val output = new OSet.Mutable[T] + def map[T](f: V => T): Agg[T] = { + val output = new Agg.Mutable[T] for(i <- items) output.append(f(i)) output } - def flatMap[T](f: V => TraversableOnce[T]): OSet[T] = { - val output = new OSet.Mutable[T] + def flatMap[T](f: V => TraversableOnce[T]): Agg[T] = { + val output = new Agg.Mutable[T] for(i <- items) for(i0 <- f(i)) output.append(i0) output } - def filter(f: V => Boolean): OSet[V] = { - val output = new OSet.Mutable[V] + def filter(f: V => Boolean): Agg[V] = { + val output = new Agg.Mutable[V] for(i <- items) if (f(i)) output.append(i) output } - def withFilter(f: V => Boolean): OSet[V] = filter(f) + def withFilter(f: V => Boolean): Agg[V] = filter(f) def collect[T](f: PartialFunction[V, T]) = this.filter(f.isDefinedAt).map(x => f(x)) @@ -84,10 +84,10 @@ sealed class OSetWrapper(strictUniqueness: Boolean){ } } - def reverse = OSet.from(indexed.reverseIterator) + def reverse = Agg.from(indexed.reverseIterator) - def zip[T](other: OSet[T]) = OSet.from(items.zip(other.items)) - def ++[T >: V](other: TraversableOnce[T]) = OSet.from(items ++ other) + def zip[T](other: Agg[T]) = Agg.from(items.zip(other.items)) + def ++[T >: V](other: TraversableOnce[T]) = Agg.from(items ++ other) // Members declared in scala.collection.GenTraversableOnce def isTraversableAgain: Boolean = items.isTraversableAgain @@ -107,10 +107,10 @@ sealed class OSetWrapper(strictUniqueness: Boolean){ override def hashCode() = items.map(_.hashCode()).sum override def equals(other: Any) = other match{ - case s: OSet[_] => items.sameElements(s.items) + case s: Agg[_] => items.sameElements(s.items) case _ => super.equals(other) } - override def toString = items.mkString("OSet(", ", ", ")") + override def toString = items.mkString("Agg(", ", ", ")") } } } diff --git a/core/src/test/scala/mill/define/CacherTests.scala b/core/src/test/scala/mill/define/CacherTests.scala index 4127a75b..5fca1ff0 100644 --- a/core/src/test/scala/mill/define/CacherTests.scala +++ b/core/src/test/scala/mill/define/CacherTests.scala @@ -3,7 +3,7 @@ package mill.define import mill.discover.Discovered import mill.eval.Evaluator import mill.util.{DummyLogger, TestUtil} -import mill.util.Strict.OSet +import mill.util.Strict.Agg import mill.T import mill.eval.Result.Success import utest._ @@ -31,7 +31,7 @@ object CacherTests extends TestSuite{ def eval[V](mapping: Discovered.Mapping[_], v: Task[V])(implicit tp: TestPath) = { val workspace = ammonite.ops.pwd / 'target / 'workspace / tp.value val evaluator = new Evaluator(workspace, ammonite.ops.pwd, mapping, DummyLogger) - evaluator.evaluate(OSet(v)).values(0) + evaluator.evaluate(Agg(v)).values(0) } 'simpleDefIsCached - assert( diff --git a/core/src/test/scala/mill/define/GraphTests.scala b/core/src/test/scala/mill/define/GraphTests.scala index 7241087a..3988328b 100644 --- a/core/src/test/scala/mill/define/GraphTests.scala +++ b/core/src/test/scala/mill/define/GraphTests.scala @@ -6,7 +6,7 @@ import Discovered.mapping import mill.eval.Evaluator import mill.util.{TestGraphs, TestUtil} import utest._ -import mill.util.Strict.OSet +import mill.util.Strict.Agg object GraphTests extends TestSuite{ val tests = Tests{ @@ -17,31 +17,31 @@ object GraphTests extends TestSuite{ import TestGraphs._ 'topoSortedTransitiveTargets - { - def check(targets: OSet[Task[_]], expected: OSet[Task[_]]) = { + def check(targets: Agg[Task[_]], expected: Agg[Task[_]]) = { val result = Graph.topoSorted(Graph.transitiveTargets(targets)).values TestUtil.checkTopological(result) assert(result == expected) } 'singleton - check( - targets = OSet(singleton.single), - expected = OSet(singleton.single) + targets = Agg(singleton.single), + expected = Agg(singleton.single) ) 'pair - check( - targets = OSet(pair.down), - expected = OSet(pair.up, pair.down) + targets = Agg(pair.down), + expected = Agg(pair.up, pair.down) ) 'anonTriple - check( - targets = OSet(anonTriple.down), - expected = OSet(anonTriple.up, anonTriple.down.inputs(0), anonTriple.down) + targets = Agg(anonTriple.down), + expected = Agg(anonTriple.up, anonTriple.down.inputs(0), anonTriple.down) ) 'diamond - check( - targets = OSet(diamond.down), - expected = OSet(diamond.up, diamond.left, diamond.right, diamond.down) + targets = Agg(diamond.down), + expected = Agg(diamond.up, diamond.left, diamond.right, diamond.down) ) 'anonDiamond - check( - targets = OSet(diamond.down), - expected = OSet( + targets = Agg(diamond.down), + expected = Agg( diamond.up, diamond.down.inputs(0), diamond.down.inputs(1), @@ -49,8 +49,8 @@ object GraphTests extends TestSuite{ ) ) 'defCachedDiamond - check( - targets = OSet(defCachedDiamond.down), - expected = OSet( + targets = Agg(defCachedDiamond.down), + expected = Agg( defCachedDiamond.up.inputs(0), defCachedDiamond.up, defCachedDiamond.down.inputs(0).inputs(0).inputs(0), @@ -62,7 +62,7 @@ object GraphTests extends TestSuite{ ) ) 'bigSingleTerminal - { - val result = Graph.topoSorted(Graph.transitiveTargets(OSet(bigSingleTerminal.j))).values + val result = Graph.topoSorted(Graph.transitiveTargets(Agg(bigSingleTerminal.j))).values TestUtil.checkTopological(result) assert(result.size == 28) } @@ -71,46 +71,46 @@ object GraphTests extends TestSuite{ 'groupAroundNamedTargets - { def check[T, R <: Target[Int]](base: T) (target: T => R, - important0: OSet[T => Target[_]], - expected: OSet[(R, Int)]) = { + important0: Agg[T => Target[_]], + expected: Agg[(R, Int)]) = { - val topoSorted = Graph.topoSorted(Graph.transitiveTargets(OSet(target(base)))) + val topoSorted = Graph.topoSorted(Graph.transitiveTargets(Agg(target(base)))) val important = important0.map(_ (base)) val grouped = Graph.groupAroundImportantTargets(topoSorted) { case t: Target[_] if important.contains(t) => t } - val flattened = OSet.from(grouped.values().flatMap(_.items)) + val flattened = Agg.from(grouped.values().flatMap(_.items)) TestUtil.checkTopological(flattened) for ((terminal, expectedSize) <- expected) { val grouping = grouped.lookupKey(terminal) assert( grouping.size == expectedSize, - grouping.flatMap(_.asTarget: Option[Target[_]]).filter(important.contains) == OSet(terminal) + grouping.flatMap(_.asTarget: Option[Target[_]]).filter(important.contains) == Agg(terminal) ) } } 'singleton - check(singleton)( _.single, - OSet(_.single), - OSet(singleton.single -> 1) + Agg(_.single), + Agg(singleton.single -> 1) ) 'pair - check(pair)( _.down, - OSet(_.up, _.down), - OSet(pair.up -> 1, pair.down -> 1) + Agg(_.up, _.down), + Agg(pair.up -> 1, pair.down -> 1) ) 'anonTriple - check(anonTriple)( _.down, - OSet(_.up, _.down), - OSet(anonTriple.up -> 1, anonTriple.down -> 2) + Agg(_.up, _.down), + Agg(anonTriple.up -> 1, anonTriple.down -> 2) ) 'diamond - check(diamond)( _.down, - OSet(_.up, _.left, _.right, _.down), - OSet( + Agg(_.up, _.left, _.right, _.down), + Agg( diamond.up -> 1, diamond.left -> 1, diamond.right -> 1, @@ -120,8 +120,8 @@ object GraphTests extends TestSuite{ 'defCachedDiamond - check(defCachedDiamond)( _.down, - OSet(_.up, _.left, _.right, _.down), - OSet( + Agg(_.up, _.left, _.right, _.down), + Agg( defCachedDiamond.up -> 2, defCachedDiamond.left -> 2, defCachedDiamond.right -> 2, @@ -131,16 +131,16 @@ object GraphTests extends TestSuite{ 'anonDiamond - check(anonDiamond)( _.down, - OSet(_.down, _.up), - OSet( + Agg(_.down, _.up), + Agg( anonDiamond.up -> 1, anonDiamond.down -> 3 ) ) 'bigSingleTerminal - check(bigSingleTerminal)( _.j, - OSet(_.a, _.b, _.e, _.f, _.i, _.j), - OSet( + Agg(_.a, _.b, _.e, _.f, _.i, _.j), + Agg( bigSingleTerminal.a -> 3, bigSingleTerminal.b -> 2, bigSingleTerminal.e -> 9, @@ -154,7 +154,7 @@ object GraphTests extends TestSuite{ def countGroups(mapping: Discovered.Mapping[_], goals: Task[_]*) = { val topoSorted = Graph.topoSorted( - Graph.transitiveTargets(OSet.from(goals)) + Graph.transitiveTargets(Agg.from(goals)) ) val grouped = Graph.groupAroundImportantTargets(topoSorted) { case t: NamedTask[Any] => t diff --git a/core/src/test/scala/mill/discover/ConsistencyTests.scala b/core/src/test/scala/mill/discover/ConsistencyTests.scala index 4a9ae843..f29273df 100644 --- a/core/src/test/scala/mill/discover/ConsistencyTests.scala +++ b/core/src/test/scala/mill/discover/ConsistencyTests.scala @@ -4,7 +4,7 @@ package mill.discover import mill.define.Segment.Label import mill.define.Segments import mill.util.{TestGraphs} -import mill.util.Strict.OSet +import mill.util.Strict.Agg import utest._ object ConsistencyTests extends TestSuite{ @@ -18,7 +18,7 @@ object ConsistencyTests extends TestSuite{ // // Maybe later we can convert them into compile errors somehow - val expected = OSet( + val expected = Agg( Segments(Label("down")), Segments(Label("right")), Segments(Label("left")), @@ -30,7 +30,7 @@ object ConsistencyTests extends TestSuite{ Discovered.mapping(diamond) ) - assert(inconsistent == OSet()) + assert(inconsistent == Agg()) } 'anonDiamond - { @@ -38,7 +38,7 @@ object ConsistencyTests extends TestSuite{ Discovered.mapping(anonDiamond) ) - assert(inconsistent == OSet()) + assert(inconsistent == Agg()) } 'borkedCachedDiamond2 - { 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) } } diff --git a/core/src/test/scala/mill/eval/FailureTests.scala b/core/src/test/scala/mill/eval/FailureTests.scala index ef206740..c1ca1533 100644 --- a/core/src/test/scala/mill/eval/FailureTests.scala +++ b/core/src/test/scala/mill/eval/FailureTests.scala @@ -4,7 +4,7 @@ import mill.define.Target import mill.discover.Discovered import mill.discover.Discovered.mapping import mill.util.DummyLogger -import mill.util.Strict.OSet +import mill.util.Strict.Agg import utest._ import utest.framework.TestPath @@ -19,7 +19,7 @@ object FailureTests extends TestSuite{ def apply(target: Target[_], expectedFailCount: Int, expectedRawValues: Seq[Result[_]]) = { - val res = evaluator.evaluate(OSet(target)) + val res = evaluator.evaluate(Agg(target)) val cleaned = res.rawValues.map{ case Result.Exception(ex, _) => Result.Exception(ex, Nil) diff --git a/core/src/test/scala/mill/eval/JavaCompileJarTests.scala b/core/src/test/scala/mill/eval/JavaCompileJarTests.scala index 8105f2fa..f40fb798 100644 --- a/core/src/test/scala/mill/eval/JavaCompileJarTests.scala +++ b/core/src/test/scala/mill/eval/JavaCompileJarTests.scala @@ -8,7 +8,7 @@ import mill.modules.Jvm import mill.util.Ctx.DestCtx import mill.{Module, T} import mill.util.{DummyLogger, Loose, TestUtil} -import mill.util.Strict.OSet +import mill.util.Strict.Agg import utest._ import mill._ @@ -41,7 +41,7 @@ object JavaCompileJarTests extends TestSuite{ def resourceRoot = T.source{ resourceRootPath } def allSources = T{ ls.rec(sourceRoot().path).map(PathRef(_)) } def classFiles = T{ compileAll(allSources()) } - def jar = T{ Jvm.createJar(Loose.OSet(resourceRoot().path, classFiles().path)) } + def jar = T{ Jvm.createJar(Loose.Agg(resourceRoot().path, classFiles().path)) } def run(mainClsName: String) = T.command{ %%('java, "-cp", classFiles().path, mainClsName) @@ -53,7 +53,7 @@ object JavaCompileJarTests extends TestSuite{ def eval[T](t: Task[T]) = { val evaluator = new Evaluator(workspacePath, pwd, mapping, DummyLogger) - val evaluated = evaluator.evaluate(OSet(t)) + val evaluated = evaluator.evaluate(Agg(t)) if (evaluated.failing.keyCount == 0){ Right(Tuple2( @@ -68,7 +68,7 @@ object JavaCompileJarTests extends TestSuite{ } } - def check(targets: OSet[Task[_]], expected: OSet[Task[_]]) = { + def check(targets: Agg[Task[_]], expected: Agg[Task[_]]) = { val evaluator = new Evaluator(workspacePath, pwd, mapping, DummyLogger) val evaluated = evaluator.evaluate(targets) @@ -83,47 +83,47 @@ object JavaCompileJarTests extends TestSuite{ check( - targets = OSet(jar), - expected = OSet(allSources, classFiles, jar) + targets = Agg(jar), + expected = Agg(allSources, classFiles, jar) ) // Re-running with no changes results in nothing being evaluated - check(targets = OSet(jar), expected = OSet()) + check(targets = Agg(jar), expected = Agg()) // Appending an empty string gets ignored due to file-content hashing append(sourceRootPath / "Foo.java", "") - check(targets = OSet(jar), expected = OSet()) + check(targets = Agg(jar), expected = Agg()) // Appending whitespace forces a recompile, but the classfilesend up // exactly the same so no re-jarring. append(sourceRootPath / "Foo.java", " ") // Note that `sourceRoot` and `resourceRoot` never turn up in the `expected` // list, because they are `Source`s not `Target`s - check(targets = OSet(jar), expected = OSet(/*sourceRoot, */allSources, classFiles)) + check(targets = Agg(jar), expected = Agg(/*sourceRoot, */allSources, classFiles)) // Appending a new class changes the classfiles, which forces us to // re-create the final jar append(sourceRootPath / "Foo.java", "\nclass FooTwo{}") - check(targets = OSet(jar), expected = OSet(allSources, classFiles, jar)) + check(targets = Agg(jar), expected = Agg(allSources, classFiles, jar)) // Tweaking the resources forces rebuild of the final jar, without // recompiling classfiles append(resourceRootPath / "hello.txt", " ") - check(targets = OSet(jar), expected = OSet(jar)) + check(targets = Agg(jar), expected = Agg(jar)) // Asking for an intermediate target forces things to be build up to that // target only; these are re-used for any downstream targets requested append(sourceRootPath / "Bar.java", "\nclass BarTwo{}") append(resourceRootPath / "hello.txt", " ") - check(targets = OSet(classFiles), expected = OSet(allSources, classFiles)) - check(targets = OSet(jar), expected = OSet(jar)) - check(targets = OSet(allSources), expected = OSet()) + check(targets = Agg(classFiles), expected = Agg(allSources, classFiles)) + check(targets = Agg(jar), expected = Agg(jar)) + check(targets = Agg(allSources), expected = Agg()) append(sourceRootPath / "Bar.java", "\nclass BarThree{}") append(resourceRootPath / "hello.txt", " ") - check(targets = OSet(resourceRoot), expected = OSet()) - check(targets = OSet(allSources), expected = OSet(allSources)) - check(targets = OSet(jar), expected = OSet(classFiles, jar)) + check(targets = Agg(resourceRoot), expected = Agg()) + check(targets = Agg(allSources), expected = Agg(allSources)) + check(targets = Agg(jar), expected = Agg(classFiles, jar)) val jarContents = %%('jar, "-tf", workspacePath/'jar/'dest)(workspacePath).out.string val expectedJarContents = diff --git a/core/src/test/scala/mill/util/TestEvaluator.scala b/core/src/test/scala/mill/util/TestEvaluator.scala index 3f6086ba..be486d4d 100644 --- a/core/src/test/scala/mill/util/TestEvaluator.scala +++ b/core/src/test/scala/mill/util/TestEvaluator.scala @@ -4,14 +4,14 @@ import ammonite.ops.Path import mill.define.{Input, Target, Task} import mill.discover.{Discovered, Mirror} import mill.eval.{Evaluator, Result} -import mill.util.Strict.OSet +import mill.util.Strict.Agg class TestEvaluator(mapping: Discovered.Mapping[_], workspacePath: Path, basePath: Path){ val evaluator = new Evaluator(workspacePath, basePath, mapping, DummyLogger) def apply[T](t: Task[T]): Either[Result.Failing, (T, Int)] = { - val evaluated = evaluator.evaluate(OSet(t)) + val evaluated = evaluator.evaluate(Agg(t)) if (evaluated.failing.keyCount == 0) { Right( diff --git a/core/src/test/scala/mill/util/TestUtil.scala b/core/src/test/scala/mill/util/TestUtil.scala index 3cc945db..ca6097a1 100644 --- a/core/src/test/scala/mill/util/TestUtil.scala +++ b/core/src/test/scala/mill/util/TestUtil.scala @@ -4,7 +4,7 @@ import ammonite.main.Router.Overrides import mill.define._ import mill.eval.Result import utest.assert -import mill.util.Strict.OSet +import mill.util.Strict.Agg import scala.collection.mutable object TestUtil { @@ -56,7 +56,7 @@ object TestUtil { } - def checkTopological(targets: OSet[Task[_]]) = { + def checkTopological(targets: Agg[Task[_]]) = { val seen = mutable.Set.empty[Task[_]] for(t <- targets.indexed.reverseIterator){ seen.add(t) |