summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLi Haoyi <haoyi.sg@gmail.com>2018-02-04 10:35:59 -0800
committerLi Haoyi <haoyi.sg@gmail.com>2018-02-04 10:35:59 -0800
commit0e7a30ef554cf5b2725af4a7afc73b9e11287547 (patch)
tree22c8e7d05142a83ee829cee8f63ccf42253b5ee0
parente34b2cd25ced6dfef6dbcbcadcfed978494f2630 (diff)
downloadmill-0e7a30ef554cf5b2725af4a7afc73b9e11287547.tar.gz
mill-0e7a30ef554cf5b2725af4a7afc73b9e11287547.tar.bz2
mill-0e7a30ef554cf5b2725af4a7afc73b9e11287547.zip
catch compile-failure exceptions to avoid showing the stack trace
-rw-r--r--core/test/src/mill/eval/CrossTests.scala2
-rw-r--r--core/test/src/mill/util/TestEvaluator.scala4
-rw-r--r--scalalib/src/mill/scalalib/ScalaWorkerApi.scala2
-rw-r--r--scalaworker/src/mill/scalaworker/ScalaWorker.scala92
4 files changed, 51 insertions, 49 deletions
diff --git a/core/test/src/mill/eval/CrossTests.scala b/core/test/src/mill/eval/CrossTests.scala
index 753cf369..c9f7cb70 100644
--- a/core/test/src/mill/eval/CrossTests.scala
+++ b/core/test/src/mill/eval/CrossTests.scala
@@ -26,7 +26,7 @@ object CrossTests extends TestSuite{
val Right(("2.12", 1)) = check.apply(crossResolved.foo("2.12").suffix)
val Right(("_2.10", 1)) = check.apply(crossResolved.bar("2.10").longSuffix)
- val Right(("_211", 1)) = check.apply(crossResolved.bar("2.11").longSuffix)
+ val Right(("_2.11", 1)) = check.apply(crossResolved.bar("2.11").longSuffix)
val Right(("_2.12", 1)) = check.apply(crossResolved.bar("2.12").longSuffix)
}
diff --git a/core/test/src/mill/util/TestEvaluator.scala b/core/test/src/mill/util/TestEvaluator.scala
index 8ef12417..3fdd7c63 100644
--- a/core/test/src/mill/util/TestEvaluator.scala
+++ b/core/test/src/mill/util/TestEvaluator.scala
@@ -28,8 +28,8 @@ class TestEvaluator[T <: TestUtil.TestBuild](module: T)
tp: TestPath){
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)] = {
diff --git a/scalalib/src/mill/scalalib/ScalaWorkerApi.scala b/scalalib/src/mill/scalalib/ScalaWorkerApi.scala
index fa815bb2..0a9e8f5d 100644
--- a/scalalib/src/mill/scalalib/ScalaWorkerApi.scala
+++ b/scalalib/src/mill/scalalib/ScalaWorkerApi.scala
@@ -55,7 +55,7 @@ trait ScalaWorkerApi {
scalacPluginClasspath: Agg[Path],
javacOptions: Seq[String],
upstreamCompileOutput: Seq[CompilationResult])
- (implicit ctx: mill.util.Ctx): CompilationResult
+ (implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult]
def apply(frameworkInstance: ClassLoader => sbt.testing.Framework,
entireClasspath: Agg[Path],
diff --git a/scalaworker/src/mill/scalaworker/ScalaWorker.scala b/scalaworker/src/mill/scalaworker/ScalaWorker.scala
index 634f9e02..40923309 100644
--- a/scalaworker/src/mill/scalaworker/ScalaWorker.scala
+++ b/scalaworker/src/mill/scalaworker/ScalaWorker.scala
@@ -109,7 +109,7 @@ class ScalaWorker(ctx0: mill.util.Ctx,
scalacPluginClasspath: Agg[Path],
javacOptions: Seq[String],
upstreamCompileOutput: Seq[CompilationResult])
- (implicit ctx: mill.util.Ctx): CompilationResult = {
+ (implicit ctx: mill.util.Ctx): mill.eval.Result[CompilationResult] = {
val compileClasspathFiles = compileClasspath.map(_.toIO).toArray
val compilerJars = compilerClasspath.toArray.map(_.toIO)
@@ -179,53 +179,55 @@ class ScalaWorker(ctx0: mill.util.Ctx,
val store = FileAnalysisStore.binary(zincIOFile)
- val newResult = ic.compile(
- ic.inputs(
- classpath = classesIODir +: compileClasspathFiles,
- sources = for{
- root <- sources.toArray
- if exists(root)
- path <- ls.rec(root)
- if path.isFile && (path.ext == "scala" || path.ext == "java")
- } yield path.toIO,
- classesDirectory = classesIODir,
- scalacOptions = (scalacPluginClasspath.map(jar => s"-Xplugin:${jar}") ++ scalacOptions).toArray,
- javacOptions = javacOptions.toArray,
- maxErrors = 10,
- sourcePositionMappers = Array(),
- order = CompileOrder.Mixed,
- compilers = ic.compilers(
- scalaInstance,
- ClasspathOptionsUtil.boot,
- None,
- ZincUtil.scalaCompiler(scalaInstance, compilerBridge.toIO)
+ try {
+ val newResult = ic.compile(
+ ic.inputs(
+ classpath = classesIODir +: compileClasspathFiles,
+ sources = for {
+ root <- sources.toArray
+ if exists(root)
+ path <- ls.rec(root)
+ if path.isFile && (path.ext == "scala" || path.ext == "java")
+ } yield path.toIO,
+ classesDirectory = classesIODir,
+ scalacOptions = (scalacPluginClasspath.map(jar => s"-Xplugin:${jar}") ++ scalacOptions).toArray,
+ javacOptions = javacOptions.toArray,
+ maxErrors = 10,
+ sourcePositionMappers = Array(),
+ order = CompileOrder.Mixed,
+ compilers = ic.compilers(
+ scalaInstance,
+ ClasspathOptionsUtil.boot,
+ None,
+ ZincUtil.scalaCompiler(scalaInstance, compilerBridge.toIO)
+ ),
+ setup = ic.setup(
+ lookup,
+ skip = false,
+ zincIOFile,
+ new FreshCompilerCache,
+ IncOptions.of(),
+ new ManagedLoggedReporter(10, logger),
+ None,
+ Array()
+ ),
+ pr = {
+ val prev = store.get()
+ PreviousResult.of(prev.map(_.getAnalysis), prev.map(_.getMiniSetup))
+ }
),
- setup = ic.setup(
- lookup,
- skip = false,
- zincIOFile,
- new FreshCompilerCache,
- IncOptions.of(),
- new ManagedLoggedReporter(10, logger),
- None,
- Array()
- ),
- pr = {
- val prev = store.get()
- PreviousResult.of(prev.map(_.getAnalysis), prev.map(_.getMiniSetup))
- }
- ),
- logger = logger
- )
-
- store.set(
- AnalysisContents.create(
- newResult.analysis(),
- newResult.setup()
+ logger = logger
+ )
+
+ store.set(
+ AnalysisContents.create(
+ newResult.analysis(),
+ newResult.setup()
+ )
)
- )
- CompilationResult(zincFile, PathRef(classesDir))
+ mill.eval.Result.Success(CompilationResult(zincFile, PathRef(classesDir)))
+ }catch{case e: CompileFailed => mill.eval.Result.Failure(e.toString)}
}
def apply(frameworkInstance: ClassLoader => sbt.testing.Framework,