summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-01-14 05:14:28 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-01-14 05:22:37 -0800
commit16d98bbbf1a29a00c06e694a4eeb088842380c2c (patch)
tree3962395b144bcbeb94462800a1c5fb8c38cc0fa8
parentde96a55c3267bb1508e77a6815007807e3fd73fb (diff)
downloadmill-16d98bbbf1a29a00c06e694a4eeb088842380c2c.tar.gz
mill-16d98bbbf1a29a00c06e694a4eeb088842380c2c.tar.bz2
mill-16d98bbbf1a29a00c06e694a4eeb088842380c2c.zip
more work to get tests passing...
-rwxr-xr-xbuild.sc4
-rw-r--r--core/src/main/scala/mill/define/Discover.scala14
-rw-r--r--core/src/main/scala/mill/define/Module.scala1
-rw-r--r--core/src/main/scala/mill/main/Resolve.scala19
-rw-r--r--integration/src/test/scala/mill/integration/IntegrationTestSuite.scala2
5 files changed, 28 insertions, 12 deletions
diff --git a/build.sc b/build.sc
index e780aad6..96f7d8c5 100755
--- a/build.sc
+++ b/build.sc
@@ -30,7 +30,7 @@ trait MillModule extends SbtModule{ outer =>
def testArgs = T{ Seq.empty[String] }
val test = new Tests(implicitly)
- class Tests(ctx0: mill.mill.define.Ctx) extends mill.Module()(ctx0) with super.Tests{
+ class Tests(ctx0: mill.define.Ctx) extends mill.Module()(ctx0) with super.Tests{
def defaultCommandName() = "forkTest"
def forkArgs = T{ testArgs() }
def projectDeps =
@@ -65,7 +65,7 @@ object core extends MillModule {
}
val test = new Tests(implicitly)
- class Tests(ctx0: mill.mill.define.Ctx) extends super.Tests(ctx0){
+ class Tests(ctx0: mill.define.Ctx) extends super.Tests(ctx0){
def generatedSources = T {
mkdir(T.ctx().dest)
shared.generateCoreTestSources(T.ctx().dest)
diff --git a/core/src/main/scala/mill/define/Discover.scala b/core/src/main/scala/mill/define/Discover.scala
index 0db2d617..52f4ab77 100644
--- a/core/src/main/scala/mill/define/Discover.scala
+++ b/core/src/main/scala/mill/define/Discover.scala
@@ -11,6 +11,7 @@ object Discover {
def applyImpl[T: c.WeakTypeTag](c: blackbox.Context): c.Expr[Discover] = {
import c.universe._
+ import compat._
val seen = mutable.Set.empty[Type]
def rec(tpe: Type): Unit = {
if (!seen(tpe)){
@@ -20,6 +21,19 @@ object Discover {
memberTpe = m.typeSignature
if memberTpe.resultType <:< typeOf[mill.define.Module] && memberTpe.paramLists.isEmpty
} rec(memberTpe.resultType)
+
+ if (tpe <:< typeOf[mill.define.Cross[_]]){
+ val inner = typeOf[Cross[_]]
+ .typeSymbol
+ .asClass
+ .typeParams
+ .head
+ .asType
+ .toType
+ .asSeenFrom(tpe, typeOf[Cross[_]].typeSymbol)
+
+ rec(inner)
+ }
}
}
rec(weakTypeOf[T])
diff --git a/core/src/main/scala/mill/define/Module.scala b/core/src/main/scala/mill/define/Module.scala
index 4634b9a3..77bc7e36 100644
--- a/core/src/main/scala/mill/define/Module.scala
+++ b/core/src/main/scala/mill/define/Module.scala
@@ -52,6 +52,7 @@ class Module(implicit ctx0: mill.define.Ctx) extends mill.moduledefs.Cacher{
this
.getClass
.getMethods
+ .filter(!_.getName.contains('$'))
.filter(_.getParameterCount == 0)
.filter(x => (x.getModifiers & Modifier.STATIC) == 0)
.filter(implicitly[ClassTag[T]].runtimeClass isAssignableFrom _.getReturnType)
diff --git a/core/src/main/scala/mill/main/Resolve.scala b/core/src/main/scala/mill/main/Resolve.scala
index df3c250d..aedcc619 100644
--- a/core/src/main/scala/mill/main/Resolve.scala
+++ b/core/src/main/scala/mill/main/Resolve.scala
@@ -16,21 +16,22 @@ object Resolve {
remainingSelector match{
case Segment.Cross(_) :: Nil => Left("Selector cannot start with a [cross] segment")
case Segment.Label(last) :: Nil =>
- def target =
+ val target =
obj
.reflect[Target[_]]
.find(_.label == last)
.map(Right(_))
- def invokeCommand[V](target: mill.Module, name: String) = for{
- cmd <- discover.value.get(target.getClass).toSeq.flatten.find(_.name == name)
- } yield cmd.asInstanceOf[EntryPoint[mill.Module]].invoke(target, ammonite.main.Scripts.groupArgs(rest.toList)) match {
- case Router.Result.Success(v) => Right(v)
- case _ => Left(s"Command failed $last")
+ def invokeCommand[V](target: mill.Module, name: String) = {
+ for(cmd <- discover.value.get(target.getClass).toSeq.flatten.find(_.name == name))
+ yield cmd.asInstanceOf[EntryPoint[mill.Module]].invoke(target, ammonite.main.Scripts.groupArgs(rest.toList)) match {
+ case Router.Result.Success(v) => Right(v)
+ case _ => Left(s"Command failed $last")
+ }
}
- def runDefault = for{
- child <- obj.reflect[mill.Module]
+ val runDefault = for{
+ child <- obj.reflectNestedObjects[mill.Module]
if child.ctx.segment == Segment.Label(last)
res <- child match{
case taskMod: TaskModule => Some(invokeCommand(child, taskMod.defaultCommandName()))
@@ -38,7 +39,7 @@ object Resolve {
}
} yield res
- def command = invokeCommand(obj, last)
+ val command = invokeCommand(obj, last)
command orElse target orElse runDefault.headOption.flatten match{
case None => Left("Cannot resolve task " +
diff --git a/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala b/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala
index ba4415fa..82f4de72 100644
--- a/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala
+++ b/integration/src/test/scala/mill/integration/IntegrationTestSuite.scala
@@ -8,7 +8,7 @@ import utest._
abstract class IntegrationTestSuite(repoKey: String, workspaceSlug: String) extends TestSuite{
val workspacePath = pwd / 'target / 'workspace / workspaceSlug
val buildFilePath = pwd / 'integration / 'src / 'test / 'resources / workspaceSlug
- val stdOutErr = new PrintStream(new ByteArrayOutputStream())
+ val stdOutErr = System.out//new PrintStream(new ByteArrayOutputStream())
val stdIn = new ByteArrayInputStream(Array())
val runner = new mill.main.MainRunner(
ammonite.main.Cli.Config(wd = workspacePath), false,