summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-02-03 09:52:00 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-03 11:37:40 -0800
commit45fbcbb71b991335d84069b45bbcff3961c1ba15 (patch)
tree8da416d2f2e4faa66e2403301dc2d1fa50b2bcff /core
parentbfd64f104a283b70ad57a66c8ac7d4dc3bda9e6f (diff)
downloadmill-45fbcbb71b991335d84069b45bbcff3961c1ba15.tar.gz
mill-45fbcbb71b991335d84069b45bbcff3961c1ba15.tar.bz2
mill-45fbcbb71b991335d84069b45bbcff3961c1ba15.zip
fix scalalib tests
Diffstat (limited to 'core')
-rw-r--r--core/src/mill/eval/Evaluator.scala5
-rw-r--r--core/src/mill/modules/Jvm.scala8
-rw-r--r--core/test/src/mill/define/BasePathTests.scala33
-rw-r--r--core/test/src/mill/eval/JavaCompileJarTests.scala2
-rw-r--r--core/test/src/mill/util/TestEvaluator.scala16
-rw-r--r--core/test/src/mill/util/TestUtil.scala20
6 files changed, 47 insertions, 37 deletions
diff --git a/core/src/mill/eval/Evaluator.scala b/core/src/mill/eval/Evaluator.scala
index 78317474..9d65e95f 100644
--- a/core/src/mill/eval/Evaluator.scala
+++ b/core/src/mill/eval/Evaluator.scala
@@ -45,6 +45,7 @@ class Evaluator[T](val outPath: Path,
val finalTaskOverrides = t match{
case t: Target[_] =>
rootModule.millInternal.segmentsToTargets.get(segments).fold(0)(_.ctx.overrides)
+
case c: mill.define.Command[_] =>
def findMatching(cls: Class[_]): Option[Seq[(Int, EntryPoint[_])]] = {
discover.value.get(cls) match{
@@ -56,8 +57,8 @@ class Evaluator[T](val outPath: Path,
}
}
}
- val public = findMatching(c.cls).get.find(_._2.name == c.ctx.segment.pathSegments.head).get._1
- public
+ findMatching(c.cls).get.find(_._2.name == c.ctx.segment.pathSegments.head).get._1
+
case c: mill.define.Worker[_] => 0
}
diff --git a/core/src/mill/modules/Jvm.scala b/core/src/mill/modules/Jvm.scala
index 4ac03a97..297dcf1f 100644
--- a/core/src/mill/modules/Jvm.scala
+++ b/core/src/mill/modules/Jvm.scala
@@ -67,9 +67,7 @@ object Jvm {
body: ClassLoader => T): T = {
val cl = if (classLoaderOverrideSbtTesting) {
val outerClassLoader = getClass.getClassLoader
- new URLClassLoader(
- classPath.map(_.toIO.toURI.toURL).toArray,
- ClassLoader.getSystemClassLoader().getParent()){
+ new URLClassLoader(classPath.map(_.toIO.toURI.toURL).toArray, null){
override def findClass(name: String) = {
if (name.startsWith("sbt.testing.")){
outerClassLoader.loadClass(name)
@@ -79,9 +77,7 @@ object Jvm {
}
}
} else {
- new URLClassLoader(
- classPath.map(_.toIO.toURI.toURL).toArray,
- ClassLoader.getSystemClassLoader().getParent())
+ new URLClassLoader(classPath.map(_.toIO.toURI.toURL).toArray, null)
}
val oldCl = Thread.currentThread().getContextClassLoader
Thread.currentThread().setContextClassLoader(cl)
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{