diff options
author | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-20 08:00:16 -0800 |
---|---|---|
committer | Li Haoyi <haoyi.sg@gmail.com> | 2017-12-20 08:00:16 -0800 |
commit | 5f200e4a1037c2ce477096a8da58561e86a58f30 (patch) | |
tree | 6f6928041d61d401b4dfc70ba763181b1805e5fe /scalaplugin/src/test | |
parent | b83546cacea1292af3d4ae8e8c349f529b201ed2 (diff) | |
download | mill-5f200e4a1037c2ce477096a8da58561e86a58f30.tar.gz mill-5f200e4a1037c2ce477096a8da58561e86a58f30.tar.bz2 mill-5f200e4a1037c2ce477096a8da58561e86a58f30.zip |
Remove implicit `Discovered.apply[T]` method. This forces people to pass around their generated `Discovered.make` structures by hand, making it harder to accidentally generate the same `Discovered` twice and slow down runtime/compilation
Diffstat (limited to 'scalaplugin/src/test')
5 files changed, 25 insertions, 26 deletions
diff --git a/scalaplugin/src/test/scala/mill/scalaplugin/AcyclicTests.scala b/scalaplugin/src/test/scala/mill/scalaplugin/AcyclicTests.scala index 185cffc8..deaa766e 100644 --- a/scalaplugin/src/test/scala/mill/scalaplugin/AcyclicTests.scala +++ b/scalaplugin/src/test/scala/mill/scalaplugin/AcyclicTests.scala @@ -37,7 +37,7 @@ object AcyclicTests extends TestSuite{ mkdir(workspacePath/up) cp(srcPath, workspacePath) val mapping = Discovered.mapping(AcyclicBuild) - def eval[T](t: Task[T]) = TestEvaluator.eval(mapping, workspacePath)(t) + def eval[T](t: Task[T]) = TestEvaluator.eval(mapping.value, workspacePath)(t) val packageScala = workspacePath/'src/'main/'scala/'acyclic/"package.scala" diff --git a/scalaplugin/src/test/scala/mill/scalaplugin/BetterFilesTests.scala b/scalaplugin/src/test/scala/mill/scalaplugin/BetterFilesTests.scala index f4247094..c9c8618c 100644 --- a/scalaplugin/src/test/scala/mill/scalaplugin/BetterFilesTests.scala +++ b/scalaplugin/src/test/scala/mill/scalaplugin/BetterFilesTests.scala @@ -97,7 +97,7 @@ object BetterFilesTests extends TestSuite{ mkdir(workspacePath/up) cp(srcPath, workspacePath) val mapping = Discovered.mapping(BetterFilesBuild) - def eval[T](t: Task[T]) = TestEvaluator.eval(mapping, workspacePath)(t) + def eval[T](t: Task[T]) = TestEvaluator.eval(mapping.value, workspacePath)(t) 'test - { diff --git a/scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala b/scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala index 239f6871..a5e52330 100644 --- a/scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala +++ b/scalaplugin/src/test/scala/mill/scalaplugin/HelloWorldTests.scala @@ -47,7 +47,7 @@ object HelloWorldTests extends TestSuite { 'scalaVersion - { 'fromBuild - { val Right((result, evalCount)) = - eval(HelloWorld.scalaVersion, helloWorldMapping) + eval(HelloWorld.scalaVersion, helloWorldMapping.value) assert( result == "2.12.4", @@ -61,7 +61,7 @@ object HelloWorldTests extends TestSuite { val Right((result, evalCount)) = eval(HelloWorldScalaOverride.scalaVersion, - Discovered.mapping(HelloWorldScalaOverride)) + Discovered.mapping(HelloWorldScalaOverride).value) assert( result == "2.11.11", @@ -72,7 +72,7 @@ object HelloWorldTests extends TestSuite { 'scalacOptions - { 'emptyByDefault - { val Right((result, evalCount)) = - eval(HelloWorld.scalacOptions, helloWorldMapping) + eval(HelloWorld.scalacOptions, helloWorldMapping.value) assert( result.isEmpty, @@ -82,7 +82,7 @@ object HelloWorldTests extends TestSuite { 'override - { val Right((result, evalCount)) = eval(HelloWorldFatalWarnings.scalacOptions, - Discovered.mapping(HelloWorldFatalWarnings)) + Discovered.mapping(HelloWorldFatalWarnings).value) assert( result == Seq("-Ywarn-unused", "-Xfatal-warnings"), @@ -93,7 +93,7 @@ object HelloWorldTests extends TestSuite { 'compile - { 'fromScratch - { val Right((result, evalCount)) = - eval(HelloWorld.compile, helloWorldMapping) + eval(HelloWorld.compile, helloWorldMapping.value) val outPath = result.classes.path val analysisFile = result.analysisFile @@ -109,31 +109,31 @@ object HelloWorldTests extends TestSuite { // don't recompile if nothing changed val Right((_, unchangedEvalCount)) = - eval(HelloWorld.compile, helloWorldMapping) + eval(HelloWorld.compile, helloWorldMapping.value) assert(unchangedEvalCount == 0) } 'recompileOnChange - { val Right((_, freshCount)) = - eval(HelloWorld.compile, helloWorldMapping) + eval(HelloWorld.compile, helloWorldMapping.value) assert(freshCount > 0) write.append(mainObject, "\n") val Right((_, incCompileCount)) = - eval(HelloWorld.compile, helloWorldMapping) + eval(HelloWorld.compile, helloWorldMapping.value) assert(incCompileCount > 0, incCompileCount < freshCount) } 'failOnError - { write.append(mainObject, "val x: ") val Left(Result.Exception(err)) = - eval(HelloWorld.compile, helloWorldMapping) + eval(HelloWorld.compile, helloWorldMapping.value) assert(err.isInstanceOf[CompileFailed]) val (compilePath, compileMetadataPath) = TestEvaluator.resolveDestPaths(outputPath)( - helloWorldMapping(HelloWorld.compile)) + helloWorldMapping.value(HelloWorld.compile)) assert( ls.rec(compilePath / 'classes).isEmpty, @@ -144,7 +144,7 @@ object HelloWorldTests extends TestSuite { // compilation fails because of "-Xfatal-warnings" flag val Left(Result.Exception(err)) = eval(HelloWorldFatalWarnings.compile, - Discovered.mapping(HelloWorldFatalWarnings)) + Discovered.mapping(HelloWorldFatalWarnings).value) assert(err.isInstanceOf[CompileFailed]) } @@ -152,7 +152,7 @@ object HelloWorldTests extends TestSuite { 'runMain - { 'runMainObject - { val Right((_, evalCount)) = - eval(HelloWorld.runMain("Main"), helloWorldMapping) + eval(HelloWorld.runMain("Main"), helloWorldMapping.value) assert(evalCount > 0) @@ -164,7 +164,7 @@ object HelloWorldTests extends TestSuite { } 'notRunInvalidMainObject - { val Left(Result.Exception(err)) = - eval(HelloWorld.runMain("Invalid"), helloWorldMapping) + eval(HelloWorld.runMain("Invalid"), helloWorldMapping.value) assert( err.isInstanceOf[InteractiveShelloutException] @@ -174,7 +174,7 @@ object HelloWorldTests extends TestSuite { write.append(mainObject, "val x: ") val Left(Result.Exception(err)) = - eval(HelloWorld.runMain("Main"), helloWorldMapping) + eval(HelloWorld.runMain("Main"), helloWorldMapping.value) assert( err.isInstanceOf[CompileFailed] @@ -184,7 +184,7 @@ object HelloWorldTests extends TestSuite { 'run - { 'runIfMainClassProvided - { val Right((_, evalCount)) = - eval(HelloWorldWithMain.run(), helloWorldWithMainMapping) + eval(HelloWorldWithMain.run(), helloWorldWithMainMapping.value) assert(evalCount > 0) @@ -196,7 +196,7 @@ object HelloWorldTests extends TestSuite { } 'notRunWithoutMainClass - { val Left(Result.Exception(err)) = - eval(HelloWorld.run(), helloWorldMapping) + eval(HelloWorld.run(), helloWorldMapping.value) assert( err.isInstanceOf[RuntimeException] @@ -206,7 +206,7 @@ object HelloWorldTests extends TestSuite { 'jar - { 'nonEmpty - { val Right((result, evalCount)) = - eval(HelloWorld.jar, helloWorldMapping) + eval(HelloWorld.jar, helloWorldMapping.value) assert( exists(result.path), @@ -219,7 +219,7 @@ object HelloWorldTests extends TestSuite { val manifestFiles = Seq( unJarPath / "META-INF", - unJarPath / "META-INF" / "MANIFEST.MF", + unJarPath / "META-INF" / "MANIFEST.MF" ) val expectedFiles = compileClassfiles(unJarPath) ++ manifestFiles @@ -231,7 +231,7 @@ object HelloWorldTests extends TestSuite { } 'runJar - { val Right((result, evalCount)) = - eval(HelloWorldWithMain.jar, helloWorldWithMainMapping) + eval(HelloWorldWithMain.jar, helloWorldWithMainMapping.value) assert( exists(result.path), @@ -247,7 +247,7 @@ object HelloWorldTests extends TestSuite { ) } 'logOutputToFile { - eval(HelloWorld.compile, helloWorldMapping) + eval(HelloWorld.compile, helloWorldMapping.value) val logFile = outputPath / "compile.log" assert(exists(logFile)) diff --git a/scalaplugin/src/test/scala/mill/scalaplugin/JawnTests.scala b/scalaplugin/src/test/scala/mill/scalaplugin/JawnTests.scala index 0d876660..892857c9 100644 --- a/scalaplugin/src/test/scala/mill/scalaplugin/JawnTests.scala +++ b/scalaplugin/src/test/scala/mill/scalaplugin/JawnTests.scala @@ -74,7 +74,7 @@ object JawnTests extends TestSuite{ mkdir(workspacePath/up) cp(srcPath, workspacePath) val mapping = Discovered.mapping(JawnBuild) - def eval[T](t: Task[T]) = TestEvaluator.eval(mapping, workspacePath)(t) + def eval[T](t: Task[T]) = TestEvaluator.eval(mapping.value, workspacePath)(t) 'test - { def compileOutput = workspacePath / 'jawn / "2.12.3" / 'Parser / 'compile diff --git a/scalaplugin/src/test/scala/mill/scalaplugin/TestEvaluator.scala b/scalaplugin/src/test/scala/mill/scalaplugin/TestEvaluator.scala index f0593e2a..58e4f5f3 100644 --- a/scalaplugin/src/test/scala/mill/scalaplugin/TestEvaluator.scala +++ b/scalaplugin/src/test/scala/mill/scalaplugin/TestEvaluator.scala @@ -13,9 +13,8 @@ object TestEvaluator { new Evaluator(workspacePath, Map.empty, DummyLogger).resolveDestPaths(t) } - def eval[T]( - mapping: Map[Target[_], Mirror.LabelledTarget[_]], - workspacePath: Path)(t: Task[T]): Either[Result.Failing, (T, Int)] = { + def eval[T](mapping: Map[Target[_], Mirror.LabelledTarget[_]], + workspacePath: Path)(t: Task[T]): Either[Result.Failing, (T, Int)] = { val evaluator = new Evaluator(workspacePath, mapping, DummyLogger) val evaluated = evaluator.evaluate(OSet(t)) |