diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 10:23:12 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2018-02-02 10:23:12 -0800 |
commit | 4d79af93f907264a16abe3661ea417a268b0ef67 (patch) | |
tree | 54d2cfd7e7ba63121eb2f733733876249fe3838f /core/test | |
parent | f1153f8fff92be3711fd238cd2c7c06ac2a7a5bc (diff) | |
download | mill-4d79af93f907264a16abe3661ea417a268b0ef67.tar.gz mill-4d79af93f907264a16abe3661ea417a268b0ef67.tar.bz2 mill-4d79af93f907264a16abe3661ea417a268b0ef67.zip |
Move `ScalaWorkerApi`/`ScalaJSBridge` over to new `ExternalModule` class
Also add a simple unit to validate that you can use `ExternalModule`s as part of a build, and that the
Diffstat (limited to 'core/test')
-rw-r--r-- | core/test/src/mill/eval/ModuleTests.scala | 47 | ||||
-rw-r--r-- | core/test/src/mill/util/TestEvaluator.scala | 8 | ||||
-rw-r--r-- | core/test/src/mill/util/TestUtil.scala | 2 |
3 files changed, 53 insertions, 4 deletions
diff --git a/core/test/src/mill/eval/ModuleTests.scala b/core/test/src/mill/eval/ModuleTests.scala new file mode 100644 index 00000000..110e8c79 --- /dev/null +++ b/core/test/src/mill/eval/ModuleTests.scala @@ -0,0 +1,47 @@ +package mill.eval + +import ammonite.ops._ +import mill.util.{TestEvaluator, TestUtil} +import mill.T +import mill.util.TestEvaluator.implicitDisover +import utest._ + + +object ModuleTests extends TestSuite{ + object ExternalModule extends mill.define.ExternalModule { + def x = T{13} + object inner extends mill.Module{ + def y = T{17} + } + } + object Build extends TestUtil.BaseModule{ + def z = T{ ExternalModule.x() + ExternalModule.inner.y() } + } + val tests = Tests { + 'externalModuleTargetsAreNamespacedByModulePackagePath - { + val check = new TestEvaluator( + Build, + pwd / 'target / 'workspace / "module-tests" / "externalModule", + pwd + ) + + val Right((30, 1)) = check.apply(Build.z) + val base = check.evaluator.workspacePath + assert( + read(base / 'z / "meta.json").contains("30"), + read(base / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'x / "meta.json").contains("13"), + read(base / 'mill / 'eval / 'ModuleTests / 'ExternalModule / 'inner / 'y / "meta.json").contains("17") + ) + } + 'externalModuleMustBeGlobalStatic - { + + + object Build extends mill.define.ExternalModule { + + def z = T{ ExternalModule.x() + ExternalModule.inner.y() } + } + + intercept[java.lang.AssertionError]{ Build } + } + } +} diff --git a/core/test/src/mill/util/TestEvaluator.scala b/core/test/src/mill/util/TestEvaluator.scala index 2301efe6..41830d48 100644 --- a/core/test/src/mill/util/TestEvaluator.scala +++ b/core/test/src/mill/util/TestEvaluator.scala @@ -9,10 +9,10 @@ import language.experimental.macros object TestEvaluator{ implicit def implicitDisover[T]: Discover[T] = macro applyImpl[T] } -class TestEvaluator[T <: TestUtil.BaseModule](module: T, - workspacePath: Path, - basePath: Path) - (implicit discover: Discover[T]){ +class TestEvaluator[T <: TestUtil.TestBuild](module: T, + workspacePath: Path, + basePath: Path) + (implicit discover: Discover[T]){ val evaluator = new Evaluator(workspacePath, basePath, module, discover, DummyLogger) // val evaluator = new Evaluator(workspacePath, basePath, module, discover, new PrintLogger(true, ammonite.util.Colors.Default, System.out, System.out, System.err)) def apply[T](t: Task[T]): Either[Result.Failing, (T, Int)] = { diff --git a/core/test/src/mill/util/TestUtil.scala b/core/test/src/mill/util/TestUtil.scala index 1af12a74..3a025a91 100644 --- a/core/test/src/mill/util/TestUtil.scala +++ b/core/test/src/mill/util/TestUtil.scala @@ -8,11 +8,13 @@ import mill.util.Strict.Agg import scala.collection.mutable object TestUtil { + 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) + with TestBuild object test{ |