diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-03 09:52:00 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-03 11:37:40 -0800 |
commit | 45fbcbb71b991335d84069b45bbcff3961c1ba15 (patch) | |
tree | 8da416d2f2e4faa66e2403301dc2d1fa50b2bcff /core/test/src | |
parent | bfd64f104a283b70ad57a66c8ac7d4dc3bda9e6f (diff) | |
download | mill-45fbcbb71b991335d84069b45bbcff3961c1ba15.tar.gz mill-45fbcbb71b991335d84069b45bbcff3961c1ba15.tar.bz2 mill-45fbcbb71b991335d84069b45bbcff3961c1ba15.zip |
fix scalalib tests
Diffstat (limited to 'core/test/src')
-rw-r--r-- | core/test/src/mill/define/BasePathTests.scala | 33 | ||||
-rw-r--r-- | core/test/src/mill/eval/JavaCompileJarTests.scala | 2 | ||||
-rw-r--r-- | core/test/src/mill/util/TestEvaluator.scala | 16 | ||||
-rw-r--r-- | core/test/src/mill/util/TestUtil.scala | 20 |
4 files changed, 42 insertions, 29 deletions
diff --git a/core/test/src/mill/define/BasePathTests.scala b/core/test/src/mill/define/BasePathTests.scala index f7a1afa7..1f5b4037 100644 --- a/core/test/src/mill/define/BasePathTests.scala +++ b/core/test/src/mill/define/BasePathTests.scala @@ -7,41 +7,42 @@ import mill.{Module, T} object BasePathTests extends TestSuite{ val testGraphs = new TestGraphs val tests = Tests{ - def check(m: Module, segments: String*) = { - val remaining = m.millSourcePath.relativeTo(pwd).segments.drop(1) + def check[T <: Module](m: T)(f: T => Module, segments: String*) = { + val remaining = f(m).millSourcePath.relativeTo(m.millSourcePath).segments assert(remaining == segments) } 'singleton - { - check(testGraphs.singleton) + check(testGraphs.singleton)(identity) } 'separateGroups - { - check(TestGraphs.triangleTask) + check(TestGraphs.triangleTask)(identity) } 'TraitWithModuleObject - { - check(TestGraphs.TraitWithModuleObject.TraitModule, + check(TestGraphs.TraitWithModuleObject)( + _.TraitModule, "TraitModule" ) } 'nestedModuleNested - { - check(TestGraphs.nestedModule.nested, "nested") + check(TestGraphs.nestedModule)(_.nested, "nested") } 'nestedModuleInstance - { - check(TestGraphs.nestedModule.classInstance, "classInstance") + check(TestGraphs.nestedModule)(_.classInstance, "classInstance") } 'singleCross - { - check(TestGraphs.singleCross.cross, "cross") - check(TestGraphs.singleCross.cross("210"), "cross", "210") - check(TestGraphs.singleCross.cross("211"), "cross", "211") + check(TestGraphs.singleCross)(_.cross, "cross") + check(TestGraphs.singleCross)(_.cross("210"), "cross", "210") + check(TestGraphs.singleCross)(_.cross("211"), "cross", "211") } 'doubleCross - { - check(TestGraphs.doubleCross.cross, "cross") - check(TestGraphs.doubleCross.cross("210", "jvm"), "cross", "210", "jvm") - check(TestGraphs.doubleCross.cross("212", "js"), "cross", "212", "js") + check(TestGraphs.doubleCross)(_.cross, "cross") + check(TestGraphs.doubleCross)(_.cross("210", "jvm"), "cross", "210", "jvm") + check(TestGraphs.doubleCross)(_.cross("212", "js"), "cross", "212", "js") } 'nestedCrosses - { - check(TestGraphs.nestedCrosses.cross, "cross") - check( - TestGraphs.nestedCrosses.cross("210").cross2("js"), + check(TestGraphs.nestedCrosses)(_.cross, "cross") + check(TestGraphs.nestedCrosses)( + _.cross("210").cross2("js"), "cross", "210", "cross2", "js" ) } diff --git a/core/test/src/mill/eval/JavaCompileJarTests.scala b/core/test/src/mill/eval/JavaCompileJarTests.scala index 9d1134b8..a67d669d 100644 --- a/core/test/src/mill/eval/JavaCompileJarTests.scala +++ b/core/test/src/mill/eval/JavaCompileJarTests.scala @@ -22,7 +22,7 @@ object JavaCompileJarTests extends TestSuite{ val tests = Tests{ 'javac { val javacSrcPath = pwd / 'core / 'test / 'resources / 'examples / 'javac - val javacDestPath = TestEvaluator.getOutPath() / 'src + val javacDestPath = TestUtil.getOutPath() / 'src mkdir(javacDestPath / up) cp(javacSrcPath, javacDestPath) diff --git a/core/test/src/mill/util/TestEvaluator.scala b/core/test/src/mill/util/TestEvaluator.scala index 5684b4fd..ee92c2c2 100644 --- a/core/test/src/mill/util/TestEvaluator.scala +++ b/core/test/src/mill/util/TestEvaluator.scala @@ -13,13 +13,6 @@ object TestEvaluator{ implicit def implicitDisover[T]: Discover[T] = macro applyImpl[T] val externalOutPath = pwd / 'target / 'external - def getOutPath()(implicit fullName: sourcecode.FullName, - tp: TestPath) = { - pwd / 'target / 'workspace / (fullName.value.split('.') ++ tp.value) - } - def getOutPathStatic()(implicit fullName: sourcecode.FullName) = { - pwd / 'target / 'workspace / fullName.value.split('.') - } def static[T <: TestUtil.TestBuild](module: T) (implicit discover: Discover[T], @@ -32,10 +25,10 @@ class TestEvaluator[T <: TestUtil.TestBuild](module: T) (implicit discover: Discover[T], fullName: sourcecode.FullName, tp: TestPath){ - val outPath = TestEvaluator.getOutPath() + val outPath = TestUtil.getOutPath() -// val logger = DummyLogger - val logger = new PrintLogger(true, ammonite.util.Colors.Default, System.out, System.out, System.err) + val logger = DummyLogger +// val logger = new PrintLogger(true, ammonite.util.Colors.Default, System.out, System.out, System.err) val evaluator = new Evaluator(outPath, TestEvaluator.externalOutPath, module, discover, logger) def apply[T](t: Task[T]): Either[Result.Failing, (T, Int)] = { @@ -48,7 +41,8 @@ class TestEvaluator[T <: TestUtil.TestBuild](module: T) evaluated.evaluated.collect { case t: Target[_] if module.millInternal.targets.contains(t) - && !t.isInstanceOf[Input[_]] => t + && !t.isInstanceOf[Input[_]] + && !t.ctx.external => t case t: mill.define.Command[_] => t }.size )) diff --git a/core/test/src/mill/util/TestUtil.scala b/core/test/src/mill/util/TestUtil.scala index 3a025a91..1413e9c6 100644 --- a/core/test/src/mill/util/TestUtil.scala +++ b/core/test/src/mill/util/TestUtil.scala @@ -1,19 +1,37 @@ package mill.util import ammonite.main.Router.Overrides +import ammonite.ops.pwd import mill.define._ import mill.eval.Result import utest.assert import mill.util.Strict.Agg +import utest.framework.TestPath + import scala.collection.mutable object TestUtil { + def getOutPath()(implicit fullName: sourcecode.FullName, + tp: TestPath) = { + pwd / 'target / 'workspace / (fullName.value.split('.') ++ tp.value) + } + def getOutPathStatic()(implicit fullName: sourcecode.FullName) = { + pwd / 'target / 'workspace / fullName.value.split('.') + } + + def getSrcPathStatic()(implicit fullName: sourcecode.FullName) = { + pwd / 'target / 'worksources / fullName.value.split('.') + } + def getSrcPathBase() = { + pwd / 'target / 'worksources + } + trait TestBuild extends mill.define.Module class BaseModule(implicit millModuleEnclosing0: sourcecode.Enclosing, millModuleLine0: sourcecode.Line, millName0: sourcecode.Name, overrides: Overrides) - extends mill.define.BaseModule(ammonite.ops.pwd / millModuleEnclosing0.value) + extends mill.define.BaseModule(getSrcPathBase() / millModuleEnclosing0.value.split("\\.| |#")) with TestBuild object test{ |