aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliu fengyun <liufengyunchina@gmail.com>2016-08-08 10:44:41 +0200
committerliu fengyun <liu@fengy.me>2016-10-13 11:00:22 +0200
commit92ebb46afedaba26dff0f579b78c704e7ded4b96 (patch)
tree99e7b71c0870aabe303710f2d9520ceb80f54ae7
parenta90a7845ef5fb44d842dc316de2c4fdc52946b41 (diff)
downloaddotty-92ebb46afedaba26dff0f579b78c704e7ded4b96.tar.gz
dotty-92ebb46afedaba26dff0f579b78c704e7ded4b96.tar.bz2
dotty-92ebb46afedaba26dff0f579b78c704e7ded4b96.zip
fix #1274: test for dotty bootstrap based on tasty
-rw-r--r--src/dotty/tools/dotc/config/PathResolver.scala7
-rw-r--r--src/dotty/tools/dotc/config/ScalaSettings.scala7
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala2
-rw-r--r--test/dotc/tests.scala46
4 files changed, 46 insertions, 16 deletions
diff --git a/src/dotty/tools/dotc/config/PathResolver.scala b/src/dotty/tools/dotc/config/PathResolver.scala
index f9f698e72..55d585e94 100644
--- a/src/dotty/tools/dotc/config/PathResolver.scala
+++ b/src/dotty/tools/dotc/config/PathResolver.scala
@@ -180,6 +180,7 @@ class PathResolver(implicit ctx: Context) {
case "extdirs" => settings.extdirs.value
case "classpath" | "cp" => settings.classpath.value
case "sourcepath" => settings.sourcepath.value
+ case "priorityclasspath" => settings.priorityclasspath.value
}
/** Calculated values based on any given command line options, falling back on
@@ -193,6 +194,7 @@ class PathResolver(implicit ctx: Context) {
def javaUserClassPath = if (useJavaClassPath) Defaults.javaUserClassPath else ""
def scalaBootClassPath = cmdLineOrElse("bootclasspath", Defaults.scalaBootClassPath)
def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs)
+ def priorityClassPath = cmdLineOrElse("prioritypath", "")
/** Scaladoc doesn't need any bootstrapping, otherwise will create errors such as:
* [scaladoc] ../scala-trunk/src/reflect/scala/reflect/macros/Reifiers.scala:89: error: object api is not a member of package reflect
* [scaladoc] case class ReificationException(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg)
@@ -220,7 +222,9 @@ class PathResolver(implicit ctx: Context) {
import context._
// Assemble the elements!
+ // priority class path takes precedence
def basis = List[Traversable[ClassPath]](
+ classesInExpandedPath(priorityClassPath), // 0. The priority class path (for testing).
classesInPath(javaBootClassPath), // 1. The Java bootstrap class path.
contentsOfDirsInPath(javaExtDirs), // 2. The Java extension class path.
classesInExpandedPath(javaUserClassPath), // 3. The Java application class path.
@@ -235,6 +239,7 @@ class PathResolver(implicit ctx: Context) {
override def toString = """
|object Calculated {
| scalaHome = %s
+ | priorityClassPath = %s
| javaBootClassPath = %s
| javaExtDirs = %s
| javaUserClassPath = %s
@@ -244,7 +249,7 @@ class PathResolver(implicit ctx: Context) {
| userClassPath = %s
| sourcePath = %s
|}""".trim.stripMargin.format(
- scalaHome,
+ scalaHome, ppcp(priorityClassPath),
ppcp(javaBootClassPath), ppcp(javaExtDirs), ppcp(javaUserClassPath),
useJavaClassPath,
ppcp(scalaBootClassPath), ppcp(scalaExtDirs), ppcp(userClassPath),
diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala
index 872cb0667..8f47e08bf 100644
--- a/src/dotty/tools/dotc/config/ScalaSettings.scala
+++ b/src/dotty/tools/dotc/config/ScalaSettings.scala
@@ -15,6 +15,10 @@ class ScalaSettings extends Settings.SettingGroup {
val javabootclasspath = PathSetting("-javabootclasspath", "Override java boot classpath.", Defaults.javaBootClassPath)
val javaextdirs = PathSetting("-javaextdirs", "Override java extdirs classpath.", Defaults.javaExtDirs)
val sourcepath = PathSetting("-sourcepath", "Specify location(s) of source files.", "") // Defaults.scalaSourcePath
+ val argfiles = BooleanSetting("@<file>", "A text file containing compiler arguments (options and source files)")
+ val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"
+ val d = StringSetting("-d", "directory|jar", "destination for generated classfiles.", ".")
+ val priorityclasspath = PathSetting("-priorityclasspath", "class path that takes precedence over all other paths (or testing only)", "")
/** Other settings.
*/
@@ -46,9 +50,6 @@ class ScalaSettings extends Settings.SettingGroup {
val nobootcp = BooleanSetting("-nobootcp", "Do not use the boot classpath for the scala jars.")
val strict = BooleanSetting("-strict", "Use strict type rules, which means some formerly legal code does not typecheck anymore.")
- val argfiles = BooleanSetting("@<file>", "A text file containing compiler arguments (options and source files)")
- val classpath = PathSetting("-classpath", "Specify where to find user class files.", defaultClasspath) withAbbreviation "-cp"
- val d = StringSetting("-d", "directory|jar", "destination for generated classfiles.", ".")
val nospecialization = BooleanSetting("-no-specialization", "Ignore @specialize annotations.")
val language = MultiStringSetting("-language", "feature", "Enable one or more language features.")
val rewrite = OptionSetting[Rewrites]("-rewrite", "When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax")
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index 5c9fdaf88..edc68588d 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -132,7 +132,7 @@ object Contexts {
def compilationUnit: CompilationUnit = _compilationUnit
/** The current tree */
- private[this] var _tree: Tree[_ >: Untyped] = _
+ private[this] var _tree: Tree[_ >: Untyped]= _
protected def tree_=(tree: Tree[_ >: Untyped]) = _tree = tree
def tree: Tree[_ >: Untyped] = _tree
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index 39e5f5ead..94b74d786 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -1,10 +1,9 @@
package dotc
import test._
-import dotty.partest._
-import org.junit.Test
-import org.junit.experimental.categories._
+import org.junit.{Before, Test}
+import scala.reflect.io.Directory
import scala.io.Source
// tests that match regex '(pos|dotc|run|java|compileStdLib)\.*' would be executed as benchmarks.
@@ -12,22 +11,22 @@ class tests extends CompilerTest {
def isRunByJenkins: Boolean = sys.props.isDefinedAt("dotty.jenkins.build")
+ val defaultOutputDir = "./out/"
+
val noCheckOptions = List(
// "-verbose",
// "-Ylog:frontend",
// "-Xprompt",
// "-explaintypes",
// "-Yshow-suppressed-errors",
+ "-d", defaultOutputDir,
"-pagewidth", "160")
- val defaultOutputDir = "./out/"
-
- implicit val defaultOptions = noCheckOptions ++ List(
- "-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-color:never",
- "-d", defaultOutputDir) ++ {
- if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
- else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
- }
+ implicit val defaultOptions = noCheckOptions ++
+ List("-Yno-deep-subtypes", "-Yno-double-bindings", "-Yforce-sbt-phases", "-color:never") ++ {
+ if (isRunByJenkins) List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725
+ else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef")
+ }
val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler")
@@ -60,6 +59,12 @@ class tests extends CompilerTest {
val dottyReplDir = dotcDir + "repl/"
val typerDir = dotcDir + "typer/"
+ @Before def cleanup(): Unit = {
+ // remove class files from stdlib and tests compilation
+ Directory(defaultOutputDir + "scala").deleteRecursively()
+ Directory(defaultOutputDir + "java").deleteRecursively()
+ }
+
@Test def pickle_pickleOK = compileDir(testsDir, "pickling", testPickling)
// This directory doesn't exist anymore
// @Test def pickle_pickling = compileDir(coreDir, "pickling", testPickling)
@@ -301,4 +306,23 @@ class tests extends CompilerTest {
@Test def tasty_dotc_util = compileDir(dotcDir, "util", testPickling)
@Test def tasty_tools_io = compileDir(toolsDir, "io", testPickling)
@Test def tasty_tests = compileDir(testsDir, "tasty", testPickling)
+
+ @Test def tasty_bootstrap = {
+ val opt = List("-priorityclasspath", defaultOutputDir, "-Ylog-classpath")
+ // first compile dotty
+ compileDir(dottyDir, ".", List("-deep", "-Ycheck-reentrant", "-strict"))(allowDeepSubtypes)
+
+ compileDir(dottyDir, "tools", opt)
+ compileDir(toolsDir, "dotc", opt)
+ compileDir(dotcDir, "ast", opt)
+ compileDir(dotcDir, "config", opt)
+ compileDir(dotcDir, "parsing", opt)
+ compileDir(dotcDir, "printing", opt)
+ compileDir(dotcDir, "repl", opt)
+ compileDir(dotcDir, "reporting", opt)
+ compileDir(dotcDir, "rewrite", opt)
+ compileDir(dotcDir, "transform", opt)
+ compileDir(dotcDir, "typer", opt)
+ compileDir(dotcDir, "util", opt)
+ }
}