diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-12 22:27:39 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-12 22:27:39 -0800 |
commit | ec4486c3700c421311d190c36e01faf2fd011e4e (patch) | |
tree | 04c7ac1ccb7874d3e73a7c48ce57e7a3b03b3f74 /core/src/test | |
parent | 05a501369c8483f9743e5cecf5e5ba0949d47ddc (diff) | |
download | mill-ec4486c3700c421311d190c36e01faf2fd011e4e.tar.gz mill-ec4486c3700c421311d190c36e01faf2fd011e4e.tar.bz2 mill-ec4486c3700c421311d190c36e01faf2fd011e4e.zip |
Add namespace hierarchy discovery to the `Discovered` macro, in preparation for IntelliJ support
Diffstat (limited to 'core/src/test')
-rw-r--r-- | core/src/test/scala/mill/GraphTests.scala | 20 | ||||
-rw-r--r-- | core/src/test/scala/mill/JavaCompileJarTests.scala | 1 | ||||
-rw-r--r-- | core/src/test/scala/mill/TestUtil.scala | 1 |
3 files changed, 18 insertions, 4 deletions
diff --git a/core/src/test/scala/mill/GraphTests.scala b/core/src/test/scala/mill/GraphTests.scala index fe21a6de..a3eeb62f 100644 --- a/core/src/test/scala/mill/GraphTests.scala +++ b/core/src/test/scala/mill/GraphTests.scala @@ -3,7 +3,7 @@ package mill import utest._ import TestUtil.test import mill.define.Task -import mill.discover.Discovered +import mill.discover.{Discovered, Hierarchy} import mill.eval.Evaluator import mill.util.OSet @@ -31,13 +31,27 @@ object GraphTests extends TestSuite{ val classInstance = new CanNest } - val discovered = Discovered[outer.type].apply(outer).map(x => (x._1, x._3)) + val discovered = Discovered[outer.type] + + val mapped = discovered.apply(outer).map(x => (x._1, x._3)) + def flatten(h: Hierarchy[outer.type]): Seq[Any] = { + h.node(outer) :: h.children.flatMap(flatten) + } + val flattenedHierarchy = flatten(discovered.hierarchy) + + val expectedHierarchy = Seq( + outer, + outer.classInstance, + outer.nested, + ) + assert(flattenedHierarchy == expectedHierarchy) + val expected = Seq( (List("classInstance", "single"), outer.classInstance.single), (List("nested", "single"), outer.nested.single), (List("single"), outer.single) ) - assert(discovered == expected) + assert(mapped == expected) } 'failConsistencyChecks - { diff --git a/core/src/test/scala/mill/JavaCompileJarTests.scala b/core/src/test/scala/mill/JavaCompileJarTests.scala index 87fb55f0..39d3a93a 100644 --- a/core/src/test/scala/mill/JavaCompileJarTests.scala +++ b/core/src/test/scala/mill/JavaCompileJarTests.scala @@ -51,6 +51,7 @@ object JavaCompileJarTests extends TestSuite{ import Build._ val mapping = Discovered.mapping(Build) + def eval[T](t: Task[T]): (T, Int) = { val evaluator = new Evaluator(workspacePath, mapping) val evaluated = evaluator.evaluate(OSet(t)) diff --git a/core/src/test/scala/mill/TestUtil.scala b/core/src/test/scala/mill/TestUtil.scala index 59cda559..dfe0f3a0 100644 --- a/core/src/test/scala/mill/TestUtil.scala +++ b/core/src/test/scala/mill/TestUtil.scala @@ -34,5 +34,4 @@ object TestUtil { } } } - } |