diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-15 11:28:15 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-01-15 11:28:15 -0800 |
commit | 09bdc885cf6d07a531e78827f168affb31fa90b5 (patch) | |
tree | fe9e5458e9df9fe49154c9564b443f44ade29eae /core/src | |
parent | 39bfb3f02cc539def76c7df69073c62bb6e5dc96 (diff) | |
download | mill-09bdc885cf6d07a531e78827f168affb31fa90b5.tar.gz mill-09bdc885cf6d07a531e78827f168affb31fa90b5.tar.bz2 mill-09bdc885cf6d07a531e78827f168affb31fa90b5.zip |
- Test cases for `basePath` behavior in cross-builds
- Avoid reversing the order of cross values when there are more than one provided
- Remove now-duplicate `indirectNestedCross` test case
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/scala/mill/define/Cross.scala | 2 | ||||
-rw-r--r-- | core/src/test/scala/mill/define/BasePathTests.scala | 48 | ||||
-rw-r--r-- | core/src/test/scala/mill/main/MainTests.scala | 68 | ||||
-rw-r--r-- | core/src/test/scala/mill/util/TestGraphs.scala | 10 |
4 files changed, 57 insertions, 71 deletions
diff --git a/core/src/main/scala/mill/define/Cross.scala b/core/src/main/scala/mill/define/Cross.scala index 58f9a158..8af8e2e3 100644 --- a/core/src/main/scala/mill/define/Cross.scala +++ b/core/src/main/scala/mill/define/Cross.scala @@ -55,7 +55,7 @@ class Cross[T](cases: Any*) case p: Product => p case v => Tuple1(v) } - val crossValues = c.productIterator.toList.reverse + val crossValues = c.productIterator.toList val relPath = ctx.segment match{ case Segment.Label(s) => ammonite.ops.empty / s case Segment.Cross(vs) => ammonite.ops.empty / vs.map(_.toString) diff --git a/core/src/test/scala/mill/define/BasePathTests.scala b/core/src/test/scala/mill/define/BasePathTests.scala index 67b6dc3c..df528cc4 100644 --- a/core/src/test/scala/mill/define/BasePathTests.scala +++ b/core/src/test/scala/mill/define/BasePathTests.scala @@ -2,38 +2,48 @@ package mill.define import mill.util.TestGraphs import utest._ -import ammonite.ops.pwd +import ammonite.ops._ object BasePathTests extends TestSuite{ val testGraphs = new TestGraphs val tests = Tests{ + def check(m: Module, segments: String*) = { + val remaining = m.basePath.relativeTo(pwd).segments.drop(1) + assert(remaining == segments) + } 'singleton - { - assert( - testGraphs.singleton.millModuleBasePath == - BasePath(pwd / "mill.util.TestGraphs#singleton" / "singleton") - ) + check(testGraphs.singleton, "singleton") + check(testGraphs.singleton, "singleton") + } 'separateGroups - { - assert( - TestGraphs.separateGroups.millModuleBasePath == - BasePath(pwd / "mill.util.TestGraphs.separateGroups" / "separateGroups") - ) + check(TestGraphs.separateGroups, "separateGroups") } 'TraitWithModuleObject - { - assert( - TestGraphs.TraitWithModuleObject.TraitModule.millModuleBasePath == - BasePath(pwd / "mill.util.TestGraphs.TraitWithModuleObject" / "TraitWithModuleObject" / "TraitModule") + check(TestGraphs.TraitWithModuleObject.TraitModule, + "TraitWithModuleObject", "TraitModule" ) } 'nestedModuleNested - { - assert( - TestGraphs.nestedModule.nested.millModuleBasePath == - BasePath(pwd / "mill.util.TestGraphs.nestedModule" / "nestedModule" / "nested") - ) + check(TestGraphs.nestedModule.nested, "nestedModule", "nested") } 'nestedModuleInstance - { - assert( - TestGraphs.nestedModule.classInstance.millModuleBasePath == - BasePath(pwd / "mill.util.TestGraphs.nestedModule" / "nestedModule" / "classInstance") + check(TestGraphs.nestedModule.classInstance, "nestedModule", "classInstance") + } + 'singleCross - { + check(TestGraphs.singleCross.cross, "singleCross", "cross") + check(TestGraphs.singleCross.cross("210"), "singleCross", "cross", "210") + check(TestGraphs.singleCross.cross("211"), "singleCross", "cross", "211") + } + 'doubleCross - { + check(TestGraphs.doubleCross.cross, "doubleCross", "cross") + check(TestGraphs.doubleCross.cross("210", "jvm"), "doubleCross", "cross", "210", "jvm") + check(TestGraphs.doubleCross.cross("212", "js"), "doubleCross", "cross", "212", "js") + } + 'nestedCrosses - { + check(TestGraphs.nestedCrosses.cross, "nestedCrosses", "cross") + check( + TestGraphs.nestedCrosses.cross("210").cross2("js"), + "nestedCrosses", "cross", "210", "cross2", "js" ) } diff --git a/core/src/test/scala/mill/main/MainTests.scala b/core/src/test/scala/mill/main/MainTests.scala index 62d87fce..c2499835 100644 --- a/core/src/test/scala/mill/main/MainTests.scala +++ b/core/src/test/scala/mill/main/MainTests.scala @@ -46,48 +46,34 @@ object MainTests extends TestSuite{ 'neg2 - check(singleCross, Discover[singleCross.type], "cross[doesntExist].doesntExist", Left("Cannot resolve cross cross[doesntExist]")) 'neg2 - check(singleCross, Discover[singleCross.type], "cross[doesntExist].suffix", Left("Cannot resolve cross cross[doesntExist]")) } -// 'double - { -// -// 'pos1 - check( -// doubleCross, -// "cross[jvm,210].suffix", -// Right(doubleCross.cross("jvm", "210").suffix) -// ) -// 'pos2 - check( -// doubleCross, -// "cross[jvm,211].suffix", -// Right(doubleCross.cross("jvm", "211").suffix) -// ) -// } + 'double - { + + 'pos1 - check( + doubleCross, + Discover[doubleCross.type], + "cross[210,jvm].suffix", + Right(doubleCross.cross("210", "jvm").suffix) + ) + 'pos2 - check( + doubleCross, + Discover[doubleCross.type], + "cross[211,jvm].suffix", + Right(doubleCross.cross("211", "jvm").suffix) + ) + } 'nested - { - 'indirect - { - 'pos1 - check( - indirectNestedCrosses, - Discover[indirectNestedCrosses.type], - "cross[210].cross2[js].suffix", - Right(indirectNestedCrosses.cross("210").cross2("js").suffix) - ) - 'pos2 - check( - indirectNestedCrosses, - Discover[indirectNestedCrosses.type], - "cross[211].cross2[jvm].suffix", - Right(indirectNestedCrosses.cross("211").cross2("jvm").suffix) - ) - } - 'direct - { - 'pos1 - check( - nestedCrosses, - Discover[nestedCrosses.type], - "cross[210].cross2[js].suffix", - Right(nestedCrosses.cross("210").cross2("js").suffix) - ) - 'pos2 - check( - nestedCrosses, - Discover[nestedCrosses.type], - "cross[211].cross2[jvm].suffix", - Right(nestedCrosses.cross("211").cross2("jvm").suffix) - ) - } + 'pos1 - check( + nestedCrosses, + Discover[nestedCrosses.type], + "cross[210].cross2[js].suffix", + Right(nestedCrosses.cross("210").cross2("js").suffix) + ) + 'pos2 - check( + nestedCrosses, + Discover[nestedCrosses.type], + "cross[211].cross2[jvm].suffix", + Right(nestedCrosses.cross("211").cross2("jvm").suffix) + ) } } diff --git a/core/src/test/scala/mill/util/TestGraphs.scala b/core/src/test/scala/mill/util/TestGraphs.scala index f2c67583..2a1a966b 100644 --- a/core/src/test/scala/mill/util/TestGraphs.scala +++ b/core/src/test/scala/mill/util/TestGraphs.scala @@ -209,16 +209,6 @@ object TestGraphs{ } } - object indirectNestedCrosses extends TestUtil.BaseModule { - object cross extends mill.Cross[Cross]("210", "211", "212") - class Cross(scalaVersion: String) extends mill.Module{ - object cross2 extends mill.Cross[Cross]("jvm", "js", "native") - class Cross(platform: String) extends mill.Module{ - def suffix = T{ scalaVersion + "_" + platform } - } - } - } - object nestedCrosses extends TestUtil.BaseModule { object cross extends mill.Cross[Cross]("210", "211", "212") class Cross(scalaVersion: String) extends mill.Module{ |