diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-18 19:42:38 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-11-18 19:42:38 -0800 |
commit | c4ee67d3ea4e2e96fe09d5fcb21734902e6bfa56 (patch) | |
tree | f6fd01818e955452c0adf23bc7f5c57d5b9999de /core/src/test | |
parent | 2412bf2775676a9c09eb3d370a2bd9064c51822b (diff) | |
download | mill-c4ee67d3ea4e2e96fe09d5fcb21734902e6bfa56.tar.gz mill-c4ee67d3ea4e2e96fe09d5fcb21734902e6bfa56.tar.bz2 mill-c4ee67d3ea4e2e96fe09d5fcb21734902e6bfa56.zip |
First hack pass at cross-build discovery and command-running now works.
Can be tested out on our `build.sc` via `scalaplugin/target/mill run Core.cross[a].printIt`
Needs tons of cleanup...
Diffstat (limited to 'core/src/test')
-rw-r--r-- | core/src/test/scala/mill/discover/CrossModuleTests.scala | 82 | ||||
-rw-r--r-- | core/src/test/scala/mill/discover/DiscoveredTests.scala | 4 |
2 files changed, 84 insertions, 2 deletions
diff --git a/core/src/test/scala/mill/discover/CrossModuleTests.scala b/core/src/test/scala/mill/discover/CrossModuleTests.scala new file mode 100644 index 00000000..c4e075da --- /dev/null +++ b/core/src/test/scala/mill/discover/CrossModuleTests.scala @@ -0,0 +1,82 @@ +package mill.discover + +import mill.{Module, T} +import mill.define.Cross +import utest._ + +object CrossModuleTests extends TestSuite{ + + val tests = Tests{ + + 'cross - { + object outer{ + val crossed = + for(n <- Cross("2.10.6", "2.11.8", "2.12.4")) + yield new Module{ + def scalaVersion = n + } + } + + val Some((gen, innerMirror)) = Discovered[outer.type] + .mirror + .children + .head._2 + .asInstanceOf[Mirror[outer.type, outer.crossed.type]] + .crossChildren + + val keys = gen(outer.crossed) + assert(keys == List(List("2.10.6"), List("2.11.8"), List("2.12.4"))) + for(k <- keys){ + assert(outer.crossed(k).scalaVersion == k.head) + } + } + 'doubleCross - { + object outer{ + val crossed = + for{ + platform <- Cross("", "sjs0.6", "native0.3") + scalaVersion <- Cross("2.10.6", "2.11.8", "2.12.4") + if !(platform == "native0.3" && scalaVersion == "2.10.6") + } yield new Module{ + def suffix = Seq(scalaVersion, platform).filter(_.nonEmpty).map("_"+_).mkString + } + } + + val Some((gen, innerMirror)) = Discovered[outer.type] + .mirror + .children + .head._2 + .asInstanceOf[Mirror[outer.type, outer.crossed.type]] + .crossChildren + + val keys = gen(outer.crossed) + val expectedKeys = List( + List("2.10.6", ""), + List("2.11.8", ""), + List("2.12.4", ""), + List("2.10.6", "sjs0.6"), + List("2.11.8", "sjs0.6"), + List("2.12.4", "sjs0.6"), + List("2.11.8", "native0.3"), + List("2.12.4", "native0.3"), + ) + + assert(keys == expectedKeys) + for(k <- keys){ + val suffix = outer.crossed(k).suffix + val expected = k.map(_.toString).filter(_.nonEmpty).map("_"+_).mkString + assert(suffix == expected) + } + } + 'crossCommands - { + object outer { + val cross = for (c <- mill.define.Cross("a", "b", "c")) yield new mill.Module { + def printIt() = T.command { + println("PRINTING IT: " + c) + } + } + } + } + } +} + diff --git a/core/src/test/scala/mill/discover/DiscoveredTests.scala b/core/src/test/scala/mill/discover/DiscoveredTests.scala index e9170967..b09ff2de 100644 --- a/core/src/test/scala/mill/discover/DiscoveredTests.scala +++ b/core/src/test/scala/mill/discover/DiscoveredTests.scala @@ -33,7 +33,7 @@ object DiscoveredTests extends TestSuite{ def flatten(h: Mirror[outer.type, _]): Seq[Any] = { - h.node(outer) :: h.children.flatMap{case (label, c) => flatten(c)} + h.node(outer, Nil) :: h.children.flatMap{case (label, c) => flatten(c)} } val flattenedHierarchy = flatten(discovered.mirror) @@ -44,7 +44,7 @@ object DiscoveredTests extends TestSuite{ ) assert(flattenedHierarchy == expectedHierarchy) - val mapped = discovered.targets(outer).map(x => x.segments -> x.target) + val mapped = discovered.targets(outer, Nil).map(x => x.segments -> x.target) val expected = Seq( (List("classInstance", "single"), outer.classInstance.single), |