From bbc46b4ad9aecd0998f0fa49f349a91f1d665ca8 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Sun, 23 Oct 2016 16:22:00 +0200 Subject: Add dotty-library to classpath in dottydoc tests --- test/dotc/tests.scala | 23 ++++++++++++++--------- test/test/CompilerTest.scala | 11 +++++++---- test/test/OtherEntryPointsTest.scala | 17 +++++++++++------ test/test/ShowClassTests.scala | 13 +++++++++++++ test/test/TestREPL.scala | 12 ++++++++++-- 5 files changed, 55 insertions(+), 21 deletions(-) (limited to 'test') diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 4d3e8e1dd..747396c73 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -19,22 +19,25 @@ class tests extends CompilerTest { // "-Xprompt", // "-explaintypes", // "-Yshow-suppressed-errors", - "-d", defaultOutputDir, - "-pagewidth", "80" + "-pagewidth", "120", + "-d", defaultOutputDir ) - implicit val defaultOptions = noCheckOptions ++ { - if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725 - else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") - } ++ List( + val classPath = List( "-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-color:never", "-classpath", - "./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" + "./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" + + ":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" ) + implicit val defaultOptions = noCheckOptions ++ { + if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725 + else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") + } ++ classPath + val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler", "-Yprintpos") val twice = List("#runs", "2") @@ -191,7 +194,9 @@ class tests extends CompilerTest { ".", List( "-deep", "-Ycheck-reentrant", "-strict", "-classpath", defaultOutputDir + - ":./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar" //WAT??? + ":./target/scala-2.11/dotty-compiler_2.11-0.1-SNAPSHOT.jar" + + ":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" + + ":./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" ) )(allowDeepSubtypes) // note the -deep argument @@ -214,7 +219,7 @@ class tests extends CompilerTest { @Test def dotc_ast = compileDir(dotcDir, "ast") @Test def dotc_config = compileDir(dotcDir, "config") @Test def dotc_core = compileDir(dotcDir, "core")(allowDeepSubtypes)// twice omitted to make tests run faster - @Test def dotc_core_nocheck = compileDir(dotcDir, "core")(noCheckOptions) + @Test def dotc_core_nocheck = compileDir(dotcDir, "core")(noCheckOptions ++ classPath) // This directory doesn't exist anymore // @Test def dotc_core_pickling = compileDir(coreDir, "pickling")(allowDeepSubtypes)// twice omitted to make tests run faster diff --git a/test/test/CompilerTest.scala b/test/test/CompilerTest.scala index fe63106b5..5a4a9830a 100644 --- a/test/test/CompilerTest.scala +++ b/test/test/CompilerTest.scala @@ -133,15 +133,18 @@ abstract class CompilerTest { } } - private def compileWithJavac(fs: Array[String], args: Array[String]): Unit = { + private def compileWithJavac( + fs: Array[String], + args: Array[String] + )(implicit defaultOptions: List[String]): Boolean = { val scalaLib = findJarFromRuntime("scala-library") val fullArgs = Array( "javac", "-classpath", s".:$scalaLib" - ) ++ args ++ fs ++ Array("-d", defaultOutputDir) + ) ++ args ++ defaultOptions.dropWhile("-d" != _).take(2) ++ fs - Runtime.getRuntime.exec(fullArgs).waitFor() + Runtime.getRuntime.exec(fullArgs).waitFor() == 0 } /** Compiles the code files in the given directory together. If args starts @@ -169,7 +172,7 @@ abstract class CompilerTest { log(s"WARNING: run tests can only be run by partest, JUnit just verifies compilation: $prefix$dirName") val (filePaths, javaFilePaths, normArgs, expErrors) = computeFilePathsAndExpErrors compileWithJavac(javaFilePaths, Array.empty) // javac needs to run first on dotty-library - compileArgs(filePaths ++ normArgs, expErrors) + compileArgs(javaFilePaths ++ filePaths ++ normArgs, expErrors) } else { val (sourceDir, flags, deep) = args match { case "-deep" :: args1 => (flattenDir(prefix, dirName), args1 ++ defaultOptions, "deep") diff --git a/test/test/OtherEntryPointsTest.scala b/test/test/OtherEntryPointsTest.scala index abaa043c0..ae46fa36f 100644 --- a/test/test/OtherEntryPointsTest.scala +++ b/test/test/OtherEntryPointsTest.scala @@ -17,10 +17,18 @@ import scala.collection.mutable.ListBuffer * @see [[InterfaceEntryPointTest]] */ class OtherEntryPointsTest { - @Test def runCompiler = { - val sources = List("./tests/pos/HelloWorld.scala").map(p => new java.io.File(p).getPath()) - val args = sources ++ List("-d", "./out/") + private val sources = + List("./tests/pos/HelloWorld.scala").map(p => new java.io.File(p).getPath()) + private val dottyInterfaces = + new java.io.File("./interfaces/dotty-interfaces-0.1-SNAPSHOT.jar").getPath + private val dottyLibrary = + new java.io.File("./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar").getPath + private val args = + sources ++ + List("-d", "./out/") ++ + List("-classpath", dottyInterfaces + ":" + dottyLibrary) + @Test def runCompiler = { val reporter = new CustomReporter val callback = new CustomCompilerCallback @@ -32,9 +40,6 @@ class OtherEntryPointsTest { } @Test def runCompilerWithContext = { - val sources = List("./tests/pos/HelloWorld.scala").map(p => new java.io.File(p).getPath()) - val args = sources ++ List("-d", "./out/") - val reporter = new CustomReporter val callback = new CustomCompilerCallback val context = (new ContextBase).initialCtx.fresh diff --git a/test/test/ShowClassTests.scala b/test/test/ShowClassTests.scala index d5e59c169..81e304296 100644 --- a/test/test/ShowClassTests.scala +++ b/test/test/ShowClassTests.scala @@ -11,6 +11,19 @@ import dotty.tools.dotc.core.Decorators._ import org.junit.Test class ShowClassTests extends DottyTest { + ctx = { + val base = new ContextBase + import base.settings._ + val ctx = base.initialCtx.fresh + ctx.setSetting(ctx.settings.encoding, "UTF8") + ctx.setSetting( + ctx.settings.classpath, + "./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" + + ":./interfaces/target/dotty-interfaces-0.1-SNAPSHOT.jar" + ) + base.initialize()(ctx) + ctx + } def debug_println(msg: => Any) = { if (sys.props.isDefinedAt("test.ShowClassTests.verbose")) diff --git a/test/test/TestREPL.scala b/test/test/TestREPL.scala index 9867cb4ec..cccfacc41 100644 --- a/test/test/TestREPL.scala +++ b/test/test/TestREPL.scala @@ -20,8 +20,16 @@ class TestREPL(script: String) extends REPL { override lazy val config = new REPL.Config { override val output = new NewLinePrintWriter(out) - override def context(ctx: Context) = - ctx.fresh.setSetting(ctx.settings.color, "never") + override def context(ctx: Context) = { + val fresh = ctx.fresh + fresh.setSetting(ctx.settings.color, "never") + fresh.setSetting( + ctx.settings.classpath, + "./library/target/scala-2.11/dotty-library_2.11-0.1-SNAPSHOT.jar" + ) + fresh.initialize()(fresh) + fresh + } override def input(in: Interpreter)(implicit ctx: Context) = new InteractiveReader { val lines = script.lines.buffered -- cgit v1.2.3