summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2017-11-25 07:39:53 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2017-11-25 07:39:53 -0800
commitac62721c10cc61d3913cf71c3ef2e9e0680ddeb9 (patch)
tree7df76fecba79ee2b7313fc01a3d562efaa92500b
parent624fff48422b8c74b48c2dda86a55a82a754d5a2 (diff)
downloadmill-ac62721c10cc61d3913cf71c3ef2e9e0680ddeb9.tar.gz
mill-ac62721c10cc61d3913cf71c3ef2e9e0680ddeb9.tar.bz2
mill-ac62721c10cc61d3913cf71c3ef2e9e0680ddeb9.zip
First pass at simplifying test suite definition & running
Fixed `GenIdea` to fix reversing of module path in generating module name
-rwxr-xr-xbuild.sc21
-rw-r--r--core/src/main/scala/mill/Main.scala5
-rw-r--r--readme.md2
-rw-r--r--scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala13
-rw-r--r--scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala17
5 files changed, 34 insertions, 24 deletions
diff --git a/build.sc b/build.sc
index 08a5f3b9..494d13b1 100755
--- a/build.sc
+++ b/build.sc
@@ -35,25 +35,16 @@ object Core extends ScalaModule {
PathRef(dest)
}
}
-}
-object CoreTests extends ScalaModule {
- def scalaVersion = "2.12.4"
- override def projectDeps = Seq(Core)
- def basePath = pwd / 'scalaplugin
- override def sources = pwd/'core/'src/'test/'scala
- override def ivyDeps = Seq(
- Dep("com.lihaoyi", "utest", "0.6.0")
- )
- def test() = T.command{
- TestRunner.apply(
- "mill.UTestFramework",
- runDepClasspath().map(_.path) :+ compile().path,
- Seq(compile().path)
- )
+ object tests extends this.Tests{
+ def basePath = pwd / 'core
+ override def ivyDeps = Seq(Dep("com.lihaoyi", "utest", "0.6.0"))
+ override def sources = pwd/'core/'src/'test/'scala
+ def testFramework = "mill.UTestFramework"
}
}
+
object ScalaPlugin extends ScalaModule {
def scalaVersion = "2.12.4"
override def projectDeps = Seq(Core)
diff --git a/core/src/main/scala/mill/Main.scala b/core/src/main/scala/mill/Main.scala
index ef4a78a6..6f1d3bd3 100644
--- a/core/src/main/scala/mill/Main.scala
+++ b/core/src/main/scala/mill/Main.scala
@@ -225,7 +225,10 @@ class Main(config: Main.Config){
} else {
val interp = ammonite.Main(
predefFile = Some(pwd / "build.sc")
- ).instantiateInterpreter().right.get
+ ).instantiateInterpreter()match{
+ case Left(x) => println(x); ???
+ case Right(x) => x
+ }
interp.initializePredef()
val syntheticPath = pwd / 'out / "run.sc"
diff --git a/readme.md b/readme.md
index 7398d3f0..f17341ef 100644
--- a/readme.md
+++ b/readme.md
@@ -23,7 +23,7 @@ core unit tests
e.g.:
```bash
./scalaplugin/target/mill run Core.compile
-./scalaplugin/target/mill run CoreTests.test
+./scalaplugin/target/mill run Core.tests.run
./scalaplugin/target/mill run ScalaPlugin.assembly
```
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala b/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala
index 02dbbc91..7bfe14e1 100644
--- a/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala
+++ b/scalaplugin/src/main/scala/mill/scalaplugin/GenIdea.scala
@@ -24,12 +24,15 @@ object GenIdea {
val workspacePath = pwd / 'out
val evaluator = new Evaluator(workspacePath, mapping, _ => ())
- val modules = Mirror.traverse(obj, discovered.mirror){ (h, p) =>
- h.node(obj, p.map{case Mirror.Segment.Cross(vs) => vs case _ => Nil}.toList) match {
- case m: ScalaModule => Seq(p -> m)
- case _ => Nil
+ val modules = Mirror
+ .traverse(obj, discovered.mirror){ (h, p) =>
+ h.node(obj, p.map{case Mirror.Segment.Cross(vs) => vs case _ => Nil}.toList) match {
+ case m: ScalaModule => Seq(p -> m)
+ case _ => Nil
+ }
}
- }
+ .map{case (p, v) => (p.reverse, v)}
+
val resolved = for((path, mod) <- modules) yield {
val Seq(resolvedCp: Seq[PathRef], resolvedSrcs: Seq[PathRef]) =
evaluator.evaluate(OSet(mod.externalCompileDepClasspath, mod.externalCompileDepSources))
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
index e1b3c130..d2c37782 100644
--- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
+++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala
@@ -161,8 +161,21 @@ object ScalaModule{
)
}
import ScalaModule._
-
-trait ScalaModule extends Module{
+trait TestScalaModule extends ScalaModule{
+ def testFramework: T[String]
+ def run() = T.command{
+ TestRunner(
+ testFramework(),
+ runDepClasspath().map(_.path) :+ compile().path,
+ Seq(compile().path)
+ )
+ }
+}
+trait ScalaModule extends Module{ outer =>
+ trait Tests extends TestScalaModule{
+ def scalaVersion = outer.scalaVersion()
+ override def projectDeps = Seq(outer)
+ }
def scalaVersion: T[String]
def scalaBinaryVersion = T{ scalaVersion().split('.').dropRight(1).mkString(".") }