diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-06 20:53:29 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-06 20:54:04 -0800 |
commit | 7239d6bd64ec0d025686f5f97aaaf94b7ab43951 (patch) | |
tree | ada5a410d1ee7d658d98e3b57e4188d013109451 /scalaplugin/src | |
parent | 7a1b339b08a7e6b99da7d98b1856d534c207c99e (diff) | |
download | mill-7239d6bd64ec0d025686f5f97aaaf94b7ab43951.tar.gz mill-7239d6bd64ec0d025686f5f97aaaf94b7ab43951.tar.bz2 mill-7239d6bd64ec0d025686f5f97aaaf94b7ab43951.zip |
Explicitly pass built compiler-bridge jar locations from the build system into Mill as JVM properties.
This makes the dependency between the compiler-bridge jar and the Mill executable explicit, allowing us to swap out the locations compiler-bridge jars (which end up in different places, depending on whether you're building with SBT or Mill) or eventually making them load from Maven Central in a "release" Mill executable
Since Mill (and uTest) both do not support SBT-style test arguments, we need to use `forkTest` instead of `test` to run the Mill tests passing the compiler-jar locations as JVM props. This necessitated some fixes to make `forkTest` behave properly
Diffstat (limited to 'scalaplugin/src')
-rw-r--r-- | scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala | 21 | ||||
-rw-r--r-- | scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala | 5 |
2 files changed, 16 insertions, 10 deletions
diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala index 49d9660f..0686f131 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/ScalaModule.scala @@ -34,6 +34,7 @@ object ScalaModule{ } var scalaInstanceCache = Option.empty[(Long, ScalaInstance)] + def compileScala(scalaVersion: String, sources: Seq[Path], compileClasspath: Seq[Path], @@ -52,11 +53,10 @@ object ScalaModule{ } val compilerJars = compilerClasspath.toArray.map(_.toIO) - def binaryScalaVersion = scalaVersion.split('.').dropRight(1).mkString(".") - val compilerBridgeJar = new java.io.File( - s"bridge/${scalaVersion.replace('.', '_')}/target/scala-$binaryScalaVersion/mill-bridge_$scalaVersion-0.1-SNAPSHOT.jar" -// s"out/bridges/$scalaVersion/compile/classes" - ) + val compilerBridgeKey = "MILL_COMPILER_BRIDGE_"+scalaVersion.replace('.', '_') + val compilerBridgePath = sys.props(compilerBridgeKey) + assert(compilerBridgePath != null, "Cannot find compiler bridge " + compilerBridgeKey) + val compilerBridgeJar = new java.io.File(compilerBridgePath) val classloaderSig = compilerClasspath.map(p => p.toString().hashCode + p.mtime.toMillis).sum @@ -184,14 +184,15 @@ trait TestScalaModule extends ScalaModule with TaskModule { def testFramework: T[String] def forkWorkingDir = ammonite.ops.pwd + def forkArgs = T{ Seq.empty[String] } def forkTest(args: String*) = T.command{ val outputPath = tmp.dir()/"out.json" + Jvm.subprocess( - "mill.scalaplugin.TestRunner", - getClass.getClassLoader.asInstanceOf[URLClassLoader].getURLs.toList.map( - u => Path(new java.io.File(u.toURI)) - ), - Seq( + mainClass = "mill.scalaplugin.TestRunner", + classPath = Jvm.gatherClassloaderJars(), + jvmOptions = forkArgs(), + options = Seq( testFramework(), (runDepClasspath().map(_.path) :+ compile().path).mkString(" "), Seq(compile().path).mkString(" "), diff --git a/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala b/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala index 43e15974..bc36d9c7 100644 --- a/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala +++ b/scalaplugin/src/main/scala/mill/scalaplugin/TestRunner.scala @@ -50,6 +50,11 @@ object TestRunner { }) val outputPath = args(4) ammonite.ops.write(Path(outputPath), upickle.default.write(result)) + + // Tests are over, kill the JVM whether or not anyone's threads are still running + // Always return 0, even if tests fail. The caller can pick up the detailed test + // results from the outputPath + System.exit(0) } def apply(frameworkName: String, entireClasspath: Seq[Path], |